aboutsummaryrefslogtreecommitdiff
path: root/src/GUIbutton.py
diff options
context:
space:
mode:
authorMoisis <moisis.george@yahoo.com>2023-05-19 23:41:23 +0300
committerGitHub <noreply@github.com>2023-05-19 23:41:23 +0300
commit271af3b2b85ac05aa8061cef0f35e7540f90b778 (patch)
treea0475e1d88be01716e76f2e75c495a4284290bb9 /src/GUIbutton.py
parent8eeb31dba61e8c9b29704c5988f95dcba4338fca (diff)
parent6a351ed2d6a554ed6d338abba234527705d1040f (diff)
downloadMacpan-271af3b2b85ac05aa8061cef0f35e7540f90b778.tar.xz
Macpan-271af3b2b85ac05aa8061cef0f35e7540f90b778.zip
Merge pull request #7 from omagdy7/FinalMISOHEADmaster
Final Touches
Diffstat (limited to 'src/GUIbutton.py')
-rw-r--r--src/GUIbutton.py67
1 files changed, 38 insertions, 29 deletions
diff --git a/src/GUIbutton.py b/src/GUIbutton.py
index 794f693..eebcf77 100644
--- a/src/GUIbutton.py
+++ b/src/GUIbutton.py
@@ -1,29 +1,38 @@
-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
+
+
+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 , text , text2 ):
+ 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(text, True, self.hovering_color)
+ else:
+ self.text = self.font.render(text2, True, self.base_color)
+
+
+
+
+