aboutsummaryrefslogtreecommitdiff
path: root/src/GUIbutton.py
diff options
context:
space:
mode:
authorMoisis <moisis.george@yahoo.com>2023-05-09 10:53:19 +0300
committerGitHub <noreply@github.com>2023-05-09 10:53:19 +0300
commit8eeb31dba61e8c9b29704c5988f95dcba4338fca (patch)
treea1e9497fe359613f29164c589a499f727ef71d5c /src/GUIbutton.py
parent439ae67f933ee85bd425566cabac64815db4096e (diff)
parent1c409760e93ce1641a7d1bcd5cd09a34ff86fe6b (diff)
downloadMacpan-8eeb31dba61e8c9b29704c5988f95dcba4338fca.tar.xz
Macpan-8eeb31dba61e8c9b29704c5988f95dcba4338fca.zip
Merge pull request #6 from omagdy7/TryatGUI
Added Basic GUI
Diffstat (limited to 'src/GUIbutton.py')
-rw-r--r--src/GUIbutton.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/GUIbutton.py b/src/GUIbutton.py
new file mode 100644
index 0000000..794f693
--- /dev/null
+++ b/src/GUIbutton.py
@@ -0,0 +1,29 @@
+class Button():
+ 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) \ No newline at end of file