forked from UmSenhorQualquer/pyforms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPeopleWindow.py
More file actions
71 lines (55 loc) · 1.85 KB
/
Copy pathPeopleWindow.py
File metadata and controls
71 lines (55 loc) · 1.85 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
from __init__ import *
from People import People
from PersonWindow import PersonWindow
from AddMenuFuntionality import AddMenuFuntionality
from pyforms.controls import ControlDockWidget
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')
AddMenuFuntionality.__init__(self)
self._panel = ControlDockWidget()
#Definition of the forms fields
self._peopleList = ControlList('People',
add_function = self.__addPersonBtnAction,
remove_function = self.__rmPersonBtnAction)
self._peopleList.horizontalHeaders = ['First name', 'Middle name', 'Last name']
def closeEvent(self, event):
print "called on close"
def initForm(self):
super(PeopleWindow, self).initForm()
self.mainmenu[0]['File'][0]['Save as'].setEnabled(False)
def addPerson(self, person):
"""
Redefines 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()
def removePerson(self, index):
"""
Redefines the addPerson 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()
self._panel.value = win
def __rmPersonBtnAction(self):
"""
Remove person button event
"""
self.removePerson( self._peopleList.selected_row_index )
#Execute the application
if __name__ == "__main__": pyforms.start_app( PeopleWindow )