Skip to content

Commit 64ba9f2

Browse files
author
Bhavye Mathur
committed
v1.1.316a25
* Fixed bug with the `Rectangle` class's `copy()` function not creating a copy of the position lists and just creating a new reference * Fixed bug with the `Colour` class's `__eq__()` and `__nq__()` functions raising an `AttributeError` when comparing against a non-`Colour` object * Fixed the `hex_to_rgb()` and `_hex_to_rgb()` functions to return a tuple, not generator * Fixed bug with the `hex_to_hsl()` and `hex_to_hsv()` functions both returning CMYK values * Created new colour converter testing functions * Changed `Window` `__repr__()` function to use `"Window"` and not `"GraphWin"` * Renamed the `Window` `is_resizable()`, `is_width_resizable()`, and `is_height_resizable()` to use `get` instead * The `Window` `get_resizable()` function now returns a `tuple` not a `list` * Removed the `Window` `__str__()` function since `__repr__()` defined the same thing * Added `Window` getter function testing functions * Fixed bugs with all the CMYK colour conversion functions * Changed the `GraphicsError` in the `Window`'s `__check_open()` function to include the string `"GraphicsError"` at the start and return `True` if the window is open * Added `_check__check_open()` and `_check__autoflush()` methods to the `Window` class to check the functionality of private methods * Removed the `Window` `start_move()` and `stop_move()` methods until I can figure out what they do * Removed the `Window` `draw_bounds()` function because it wasn't required. * Fixed the `Window` `get_pos()`, `get_x_pos()`, and `get_y_pos()` functions to return the value relative to 0, 0 * Replaced all instances of the deprecated `Point` class usages with lists in `Window.py` * The `Window` `set_background()` method no longer uses styles * Changed `Window` `get_bk_colour()` method to `get_background()` to be consistent with the setter * `Window` background colours can not be inputted as hex strings * Removed all auto-flush checks in the `Window` methods because its private method `__autoflush()` also does that * Renamed the variable `RELIEF` to `BORDER_RELIEFS` * The `Window` `set_icon()` method now accepts icons in the local folder too * Added 3 getter methods to the `Window` class: `get_draggable()`, `get_x_draggable_x()`, `get_y_draggable()` * Added 5 getter methods to the `Window` class: `get_top_right()`, `get_top_left()`, `get_bottom_right()`, `get_bottom_left()`, and `get_center()` * Fixed bug with the `GraphicsObject` get animation time left functions raising a `TypeError` * Fixed error with the `Text` `clone()` method trying to clone a `None` type bounds object * Added 5 getter methods to the `_BBox` classes: `get_top_right()`, `get_top_left()`, `get_bottom_right()`, `get_bottom_left()`, `get_left()`, `get_right()`, `get_bottom()`, `get_top()` * Fixed the colour definition of `DARKISH_TURQUOISE` from a purple colour to a turquoise colour * Internally changed how the button `Button` class keeps a track of its current state (normal, hover, or clicked) * Redefined the `_update_lasttime` variable which was removed for an unknown reason * Renamed the base colour conversion functions, like `_rgb_to_hex()` to `rgb_to_hex_nocheck()` * Added a `__version__` variable that keeps track of the goopyplib version * Added American (spelled with color) colour conversion tests to `goopylib_tests.py`
1 parent 664ee6e commit 64ba9f2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1112
-840
lines changed

Examples/CalendarDateSelector/Calendar.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
# These import statements can also be replaced by from goopylib.imports import * which imports everything
2323

24+
2425
def date_selector():
2526

2627
# Creating a Window on which the calendar is drawn with a width of 450 and height of 480.
File renamed without changes.
Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
1-
IMPORTANT NOTICE: This license only applies if you downloaded this content as
2-
an unsubscribed user. If you are a premium user (ie, you pay a subscription)
3-
you are bound to the license terms described in the accompanying file
4-
"License premium.txt".
5-
6-
---------------------
7-
8-
You must attribute the image to its author:
9-
10-
In order to use a content or a part of it, you must attribute it to Freepik,
11-
so we will be able to continue creating new graphic resources every day.
12-
13-
14-
How to attribute it?
15-
16-
For websites:
17-
18-
Please, copy this code on your website to accredit the author:
19-
<a href="http://www.freepik.com">Designed by Freepik</a>
20-
21-
For printing:
22-
23-
Paste this text on the final work so the authorship is known.
24-
- For example, in the acknowledgements chapter of a book:
25-
"Designed by Freepik"
26-
27-
28-
You are free to use this image:
29-
30-
- For both personal and commercial projects and to modify it.
31-
- In a website or presentation template or application or as part of your design.
32-
33-
You are not allowed to:
34-
35-
- Sub-license, resell or rent it.
36-
- Include it in any online or offline archive or database.
37-
38-
The full terms of the license are described in section 7 of the Freepik
39-
terms of use, available online in the following link:
40-
41-
http://www.freepik.com/terms_of_use
42-
43-
The terms described in the above link have precedence over the terms described
44-
in the present document. In case of disagreement, the Freepik Terms of Use
45-
will prevail.
1+
IMPORTANT NOTICE: This license only applies if you downloaded this content as
2+
an unsubscribed user. If you are a premium user (ie, you pay a subscription)
3+
you are bound to the license terms described in the accompanying file
4+
"License premium.txt".
5+
6+
---------------------
7+
8+
You must attribute the image to its author:
9+
10+
In order to use a content or a part of it, you must attribute it to Freepik,
11+
so we will be able to continue creating new graphic resources every day.
12+
13+
14+
How to attribute it?
15+
16+
For websites:
17+
18+
Please, copy this code on your website to accredit the author:
19+
<a href="http://www.freepik.com">Designed by Freepik</a>
20+
21+
For printing:
22+
23+
Paste this text on the final work so the authorship is known.
24+
- For example, in the acknowledgements chapter of a book:
25+
"Designed by Freepik"
26+
27+
28+
You are free to use this image:
29+
30+
- For both personal and commercial projects and to modify it.
31+
- In a website or presentation template or application or as part of your design.
32+
33+
You are not allowed to:
34+
35+
- Sub-license, resell or rent it.
36+
- Include it in any online or offline archive or database.
37+
38+
The full terms of the license are described in section 7 of the Freepik
39+
terms of use, available online in the following link:
40+
41+
http://www.freepik.com/terms_of_use
42+
43+
The terms described in the above link have precedence over the terms described
44+
in the present document. In case of disagreement, the Freepik Terms of Use
45+
will prevail.
Lines changed: 89 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,89 @@
1-
from goopylib.imports import *
2-
3-
"""
4-
textures have been designed by Freepik, https://www.freepik.com/free-vector/modern-web-design-button-collection-with-flat-design_3099377.htm
5-
6-
This is a very simple program that creates a modern, light, login page which demonstrates the
7-
capabilities of using Checkboxes, Entries, and Buttons.
8-
9-
To run this, simply download the entire folder in which this is placed, and run the program!
10-
11-
"""
12-
13-
# Creating a window
14-
# We set the dimensions relative to the height of the screen because resolutions across screen can vary.
15-
window = Window(title="Example GUI Design", width=800, height=1000)
16-
17-
background = Checkbox(Image([400, 500], "RegisterPage.png"),
18-
Image([400, 500], "LoginPage.png"), autoflush=False).draw() # This is the background image
19-
20-
# Creating the entry boxes
21-
email_entry = Entry([360, 465], 24, fill=WHITE, font_face="century gothic", justify="left", font_colour=LIGHT_GREY,
22-
font_size=30, prompt_text="Email Address").draw()
23-
password_entry = Entry([360, 600], 24, fill=WHITE, font_face="century gothic", justify="left", font_colour=LIGHT_GREY,
24-
font_size=30, prompt_text="Password", password=True).draw()
25-
26-
# Creating the options tab. The Enter & Settings button are checkboxes too because we want to display different textures_other based on 2 states: register or signin
27-
# A checkbox takes 2 graphics: true & false
28-
29-
# Here, we specify the first graphic (true) to be a button. A button also takes in a graphic to display which can be any other Graphics Object.
30-
# The 2nd parameter of the button (optional) is the graphic to display while hovering. In this case, we take the same image and resize it to 102%
31-
options_tab = Checkbox(Button(Image([415, 320], "OptionsTab-Register.png"),
32-
Image([415, 320], "OptionsTab-Register.png").resize_factor(1.02)),
33-
34-
# The false graphic is very similar
35-
Button(Image([415, 320], "OptionsTab-SignIn.png"),
36-
Image([415, 320], "OptionsTab-SignIn.png").resize_factor(1.02)), layer=1).draw()
37-
38-
# Setting autoflush to false for the Checkbox means that it will not automatically update its state (go from True->False, or vice-versa)
39-
# We want this because we want to control the state to be that of the options page.
40-
# If the options page is True (Register Page) then this should be Register Button, if it is False, this should be the Login Button
41-
42-
enter_button = Checkbox(Button(Image([365, 750], "RegisterButton.png"),
43-
Image([365, 750], "RegisterButton.png").resize_height_factor(1.05)),
44-
45-
Button(Image([365, 750], "LoginButton.png"),
46-
Image([365, 750], "LoginButton.png").resize_height_factor(1.05)),
47-
autoflush=False, layer=1).draw()
48-
49-
settings_button = Checkbox(Button(Image([698, 750], "SettingsButton-Light.png"),
50-
Image([698, 750], "SettingsButton-Light.png").resize_height_factor(1.05)),
51-
52-
Button(Image([698, 750], "SettingsButton-Dark.png"),
53-
Image([698, 750], "SettingsButton-Dark.png").resize_height_factor(1.05)),
54-
autoflush=False, layer=1).draw()
55-
56-
# We are creating a blank text object to display information to the user if needed
57-
info_text = Text([400, 850], "", font_size=15, font_face="century gothic", font_colour=DARK_NAVY_BLUE, layer=1).draw()
58-
59-
next_page = "Home Page"
60-
61-
# The mainloop
62-
while True:
63-
background.set_state(options_tab.get_state())
64-
enter_button.set_state(options_tab.get_state()) # Updating the textures_other of these checkboxes to be that of the OptionsTab
65-
settings_button.set_state(options_tab.get_state())
66-
67-
mouse_pos = window.check_left_mouse_click() # Getting the position of a mouse click if there was one
68-
69-
if enter_button.is_clicked(mouse_pos): # Checking if the enter button was clicked
70-
email = email_entry.get_text()
71-
password = password_entry.get_text()
72-
if email != "Email Address" and password != "Password": # Checking if the details are valid.
73-
break
74-
else:
75-
info_text.set_text("Invalid Details Entered...") # If the details are invalid, we tell the user!
76-
77-
elif settings_button.is_clicked(mouse_pos):
78-
next_page = "Settings Page"
79-
break
80-
81-
window.update() # Updating the window
82-
83-
window.close() # Closing the window
84-
85-
if next_page == "Home Page":
86-
print(
87-
f"User has {['Signed-In', 'Registered'][enter_button.get_state()]} with the email: {email} and password: {password}")
88-
else:
89-
print("Settings Page")
1+
from goopylib.imports import *
2+
3+
"""
4+
textures have been designed by Freepik, https://www.freepik.com/free-vector/modern-web-design-button-collection-with-flat-design_3099377.htm
5+
6+
This is a very simple program that creates a modern, light, login page which demonstrates the
7+
capabilities of using Checkboxes, Entries, and Buttons.
8+
9+
To run this, simply download the entire folder in which this is placed, and run the program!
10+
11+
"""
12+
13+
# Creating a window
14+
# We set the dimensions relative to the height of the screen because resolutions across screen can vary.
15+
window = Window(title="Example GUI Design", width=800, height=1000)
16+
17+
background = Checkbox(Image([400, 500], "RegisterPage.png"),
18+
Image([400, 500], "LoginPage.png"), autoflush=False).draw() # This is the background image
19+
20+
# Creating the entry boxes
21+
email_entry = Entry([360, 465], 24, fill=WHITE, font_face="century gothic", justify="left", font_colour=LIGHT_GREY,
22+
font_size=30, prompt_text="Email Address").draw()
23+
password_entry = Entry([360, 600], 24, fill=WHITE, font_face="century gothic", justify="left", font_colour=LIGHT_GREY,
24+
font_size=30, prompt_text="Password", password=True).draw()
25+
26+
# Creating the options tab. The Enter & Settings button are checkboxes too because we want to display different textures_other based on 2 states: register or signin
27+
# A checkbox takes 2 graphics: true & false
28+
29+
# Here, we specify the first graphic (true) to be a button. A button also takes in a graphic to display which can be any other Graphics Object.
30+
# The 2nd parameter of the button (optional) is the graphic to display while hovering. In this case, we take the same image and resize it to 102%
31+
options_tab = Checkbox(Button(Image([415, 320], "OptionsTab-Register.png"),
32+
Image([415, 320], "OptionsTab-Register.png").resize_factor(1.02)),
33+
34+
# The false graphic is very similar
35+
Button(Image([415, 320], "OptionsTab-SignIn.png"),
36+
Image([415, 320], "OptionsTab-SignIn.png").resize_factor(1.02)), layer=1).draw()
37+
38+
# Setting autoflush to false for the Checkbox means that it will not automatically update its state (go from True->False, or vice-versa)
39+
# We want this because we want to control the state to be that of the options page.
40+
# If the options page is True (Register Page) then this should be Register Button, if it is False, this should be the Login Button
41+
42+
enter_button = Checkbox(Button(Image([365, 750], "RegisterButton.png"),
43+
Image([365, 750], "RegisterButton.png").resize_height_factor(1.05)),
44+
45+
Button(Image([365, 750], "LoginButton.png"),
46+
Image([365, 750], "LoginButton.png").resize_height_factor(1.05)),
47+
autoflush=False, layer=1).draw()
48+
49+
settings_button = Checkbox(Button(Image([698, 750], "SettingsButton-Light.png"),
50+
Image([698, 750], "SettingsButton-Light.png").resize_height_factor(1.05)),
51+
52+
Button(Image([698, 750], "SettingsButton-Dark.png"),
53+
Image([698, 750], "SettingsButton-Dark.png").resize_height_factor(1.05)),
54+
autoflush=False, layer=1).draw()
55+
56+
# We are creating a blank text object to display information to the user if needed
57+
info_text = Text([400, 850], "", font_size=15, font_face="century gothic", font_colour=DARK_NAVY_BLUE, layer=1).draw()
58+
59+
next_page = "Home Page"
60+
61+
# The mainloop
62+
while True:
63+
background.set_state(options_tab.get_state())
64+
enter_button.set_state(options_tab.get_state()) # Updating the textures_other of these checkboxes to be that of the OptionsTab
65+
settings_button.set_state(options_tab.get_state())
66+
67+
mouse_pos = window.check_left_mouse_click() # Getting the position of a mouse click if there was one
68+
69+
if enter_button.is_clicked(mouse_pos): # Checking if the enter button was clicked
70+
email = email_entry.get_text()
71+
password = password_entry.get_text()
72+
if email != "Email Address" and password != "Password": # Checking if the details are valid.
73+
break
74+
else:
75+
info_text.set_text("Invalid Details Entered...") # If the details are invalid, we tell the user!
76+
77+
elif settings_button.is_clicked(mouse_pos):
78+
next_page = "Settings Page"
79+
break
80+
81+
window.update() # Updating the window
82+
83+
window.close() # Closing the window
84+
85+
if next_page == "Home Page":
86+
print(
87+
f"User has {['Signed-In', 'Registered'][enter_button.get_state()]} with the email: {email} and password: {password}")
88+
else:
89+
print("Settings Page")
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)