diff options
| author | Moisis <moisis.george@yahoo.com> | 2023-05-17 14:04:38 +0300 |
|---|---|---|
| committer | Moisis <moisis.george@yahoo.com> | 2023-05-17 14:04:38 +0300 |
| commit | 3d7e3d1eba26cc57b31337b0708fce3747f8a988 (patch) | |
| tree | e9f47e18b3a6365ca383a6da0cbbc424e8b6d3fd /src/GUIbutton.py | |
| parent | 8eeb31dba61e8c9b29704c5988f95dcba4338fca (diff) | |
| download | Macpan-3d7e3d1eba26cc57b31337b0708fce3747f8a988.tar.xz Macpan-3d7e3d1eba26cc57b31337b0708fce3747f8a988.zip | |
Improved GUI
Settings added (Debug , Sound)
SoundSystem added (Become sometimes laggy)
Diffstat (limited to 'src/GUIbutton.py')
| -rw-r--r-- | src/GUIbutton.py | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/src/GUIbutton.py b/src/GUIbutton.py index 794f693..2c75a9c 100644 --- a/src/GUIbutton.py +++ b/src/GUIbutton.py @@ -1,3 +1,5 @@ + + class Button(): def __init__(self, image, pos, text_input, font, base_color, hovering_color): self.image = image @@ -26,4 +28,41 @@ class Button(): if position[0] in range(self.rect.left, self.rect.right) and position[1] in range(self.rect.top, self.rect.bottom): self.text = self.font.render(self.text_input, True, self.hovering_color) else: - self.text = self.font.render(self.text_input, True, self.base_color)
\ No newline at end of file + self.text = self.font.render(self.text_input, True, self.base_color) + +class ToggleSwitch(): + def __init__(self, image, pos, text_input, font, base_color, hovering_color): + self.image = image + self.x_pos = pos[0] + self.y_pos = pos[1] + self.font = font + self.base_color, self.hovering_color = base_color, hovering_color + self.text_input = text_input + self.text = self.font.render(self.text_input, True, self.base_color) + if self.image is None: + self.image = self.text + self.rect = self.image.get_rect(center=(self.x_pos, self.y_pos)) + self.text_rect = self.text.get_rect(center=(self.x_pos, self.y_pos)) + + def update(self, screen): + if self.image is not None: + screen.blit(self.image, self.rect) + screen.blit(self.text, self.text_rect) + + def checkForInput(self, position): + if position[0] in range(self.rect.left, self.rect.right) and position[1] in range(self.rect.top, + self.rect.bottom): + return True + return False + + def changeColor(self, position): + if position[0] in range(self.rect.left, self.rect.right) and position[1] in range(self.rect.top, + self.rect.bottom): + self.text = self.font.render(self.text_input, True, self.hovering_color) + else: + self.text = self.font.render(self.text_input, True, self.base_color) + + def changeimage(self, image): + self.image = image + + |
