1 from PyQt4 import QtCore
2 from PyQt4.QtGui import *
3 from newpersonwizard import NewPersonWizard
4 from editperson import EditPerson
6 class ChooseAction (QWidget):
7 def __init__(self, parent=None, db=None):
8 """Sets up the list of buttons and associated actions"""
9 QWidget.__init__(self,parent)
11 self.l1 = QLabel("<h1>Hall Directory</h1><h1>Select a task:</h1>")
12 self.l1.setAlignment(QtCore.Qt.AlignCenter)
13 self.pb1 = QCommandLinkButton("&Add a person to the directory","If you haven't seen this program before, hit this button.")
14 self.pb2 = QCommandLinkButton("&Edit a directory record","If you've already added your data, but want to edit it, hit this button.")
15 self.pb3 = QCommandLinkButton("&Import photos","To match picture from a camera to entered data, hit this button.")
16 self.pb4 = QCommandLinkButton("E&xport as document","To export the directory as a document for printing, hit this button.")
17 self.pb5 = QCommandLinkButton("&Perform Analytics","To analyze the data you have (and are lacking), hit this button.")
18 self.layout = QGridLayout()
19 self.layout.addWidget(self.l1,0,0,1,3)
20 self.layout.addWidget(self.pb1,1,1,1,1)
21 self.layout.addWidget(self.pb2,2,1,1,1)
22 self.layout.addWidget(self.pb3,3,1,1,1)
23 self.layout.addWidget(self.pb4,4,1,1,1)
24 self.layout.addWidget(self.pb5,5,1,1,1)
25 QtCore.QObject.connect(self.pb1, QtCore.SIGNAL("clicked()"), self.addPerson)
26 QtCore.QObject.connect(self.pb2, QtCore.SIGNAL("clicked()"), self.editPerson)
27 QtCore.QObject.connect(self.pb3, QtCore.SIGNAL("clicked()"), self.importPhotos)
28 QtCore.QObject.connect(self.pb4, QtCore.SIGNAL("clicked()"), self.exportDocument)
29 QtCore.QObject.connect(self.pb5, QtCore.SIGNAL("clicked()"), self.runAnalytics)
30 self.setLayout(self.layout)
32 """Slot triggered to add a person. Runs the NewPersonWizard."""
33 wiz = NewPersonWizard(self,self.db)
37 """Emits the signal editPerson(), so parent can swap to the EditPerson widget"""
38 self.emit(QtCore.SIGNAL("editPerson()"))
39 def importPhotos(self):
40 """Emits the signal mergePhotos(), so parent can swap to the MergePhotos widget"""
41 self.emit(QtCore.SIGNAL("mergePhotos()"))
42 def exportDocument(self):
43 """Gets a filename to export the current database to, then emits the exportDocument(QString) signal so parent can pass it to the document exporter"""
44 fileName = QFileDialog.getSaveFileName(self, "Save new file as:", ".", "OpenDocument Text Documents (*.odt)")
45 if not fileName.isEmpty():
46 if not fileName.endsWith(".odt"): # if they leave off the extension, add it
47 fileName = fileName.append(".odt")
48 self.emit(QtCore.SIGNAL("exportDocument(QString)"),fileName)
49 def runAnalytics(self):
50 """Emits the signal runAnalytics(), so parent can swap to Analytics widget"""
51 self.emit(QtCore.SIGNAL("runAnalytics()"))