-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathButtonGroup.py
32 lines (27 loc) · 1014 Bytes
/
ButtonGroup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
class ButtonGroup:
def __init__(self, buttonList=None, selected=0, space=70, top=0, left=0):
if buttonList is None:
buttonList = []
self.buttonList = buttonList
self.selected = selected
self.buttonList[self.selected].selected = True
self.top = top
self.left = left
currentLeft = self.left
for button in self.buttonList:
button.top = self.top
button.left = currentLeft
button.updateRectangle()
currentLeft += space + button.width
def selectByCoord(self, coord):
for btnIndex, button in enumerate(self.buttonList):
if button.selectByCoord(coord):
self.buttonList[self.selected].select(False)
self.selected = btnIndex
return True
return False
def draw(self):
for button in self.buttonList:
button.draw()
def getValue(self):
return self.buttonList[self.selected].value