-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpeople.py
57 lines (48 loc) · 1.91 KB
/
people.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import pyforms
from pyforms import BaseWidget
from pyforms.Controls import ControlList
from People import People
from PersonWindow import PersonWindow
from AddMenuFuntionality import AddMenuFuntionality
class PeopleWindow(AddMenuFuntionality, People, BaseWidget):
"""
This applications is a GUI implementation of the People class
"""
def __init__(self):
People.__init__(self)
BaseWidget.__init__(self,'People window')
#Definition of the forms fields
self._peopleList = ControlList('People',
plusFunction = self.__addPersonBtnAction,
minusFunction = self.__rmPersonBtnAction)
self._peopleList.horizontalHeaders = ['First name', 'Middle name', 'Last name']
def addPerson(self, person):
"""
Reimplement the addPerson function from People class to update the GUI
everytime a new person is added.
"""
super(PeopleWindow, self).addPerson(person)
self._peopleList += [person._firstName, person._middleName, person._lastName]
person.close() #After adding the person close the window
def removePerson(self, index):
"""
Reimplement the removePerson function from People class to update the GUI
everytime a person is removed.
"""
super(PeopleWindow, self).removePerson(index)
self._peopleList -= index
def __addPersonBtnAction(self):
"""
Add person button event.
"""
# A new instance of the PersonWindow is opened and shown to the user.
win = PersonWindow()
win.parent = self
win.show()
def __rmPersonBtnAction(self):
"""
Remove person button event
"""
self.removePerson( self._peopleList.mouseSelectedRowIndex )
#Execute the application
if __name__ == "__main__": pyforms.startApp( PeopleWindow )