forked from UmSenhorQualquer/pyforms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddMenuFuntionality.py
More file actions
46 lines (35 loc) · 1.03 KB
/
Copy pathAddMenuFuntionality.py
File metadata and controls
46 lines (35 loc) · 1.03 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
from PyQt4 import QtGui
class AddMenuFuntionality(object):
"""
This class is a module of the application PeopleWindow.py
It is a simple a example of how applications can be devided in modules with pyforms.
It adds the Open and Save functionality
"""
def __init__(self):
#It adds the next options to the main menu
self.mainmenu.append(
{ 'File': [
{'Save as': self.__savePeople},
{'Open as': self.__loadPeople},
'-',
{'Exit': self.__exit},
]
}
)
def __savePeople(self):
filename = QtGui.QFileDialog.getSaveFileName(parent=self,
caption="Save file",
directory=".",
filter="*.dat")
if filename!=None and filename!='': self.save(filename)
def __loadPeople(self):
filename = QtGui.QFileDialog.getOpenFileName(parent=self,
caption="Import file",
directory=".",
filter="*.dat")
if filename!=None and filename!='':
self.load(filename)
for person in self._people:
self._peopleList += [person._firstName, person._middleName, person._lastName]
def __exit(self):
exit()