-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathapp.py
196 lines (158 loc) · 6.3 KB
/
app.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# -*- coding: utf-8 -*-a
import sys
import os.path
from PyQt4 import QtGui, QtCore
from controllers import *
from models import *
from global_functions import images_dir
class Window(QtGui.QMainWindow):
"""
Main window of the app.
"""
def __init__(self):
"""
Setup widgets.
"""
super(Window, self).__init__()
# Window config
self.setGeometry(350, 200, 600, 500)
self.setWindowTitle("Certifica!")
self.central_widget = QtGui.QStackedWidget()
self.setCentralWidget(self.central_widget)
self.setWindowIcon(QtGui.QIcon(
os.path.join(images_dir, "favicon.ico")
))
# Institution menu #
dataAction = QtGui.QAction("&Dados", self)
dataAction.setStatusTip(u"Modificar dados da instituição")
dataAction.triggered.connect(self.show_institution_data)
mailAction = QtGui.QAction("&Email", self)
mailAction.setStatusTip(u"Configurar envio de emails")
mailAction.triggered.connect(self.config_mail)
listSignatureAction = QtGui.QAction("&Assinaturas", self)
listSignatureAction.setStatusTip(u"Ver todas as assinaturas")
listSignatureAction.triggered.connect(self.list_signatures)
# Events menu #
eventsAction = QtGui.QAction("&Ver todos", self)
eventsAction.setStatusTip("Ver todos os eventos")
eventsAction.triggered.connect(self.list_events)
# Clients menu #
clientsAction = QtGui.QAction("&Ver todos", self)
clientsAction.setStatusTip("Ver todos os clientes")
clientsAction.triggered.connect(self.list_clients)
# Certificates menu #
certificatesAction = QtGui.QAction("&Gerar novos", self)
certificatesAction.setStatusTip("Gerenciar certificados.")
certificatesAction.triggered.connect(self.list_certificates)
# Help menu #
licenseAction = QtGui.QAction(u"&Licença", self)
licenseAction.setStatusTip(u"Licença do app")
licenseAction.triggered.connect(self.show_license)
aboutAction = QtGui.QAction("&Sobre", self)
aboutAction.setStatusTip(u"Mais informações sobre o app")
aboutAction.triggered.connect(self.show_about)
self.statusBar()
# Menu
mainMenu = self.menuBar()
# Institution Menu #
institutionMenu = mainMenu.addMenu(u"&Instituição")
institutionMenu.addAction(dataAction)
institutionMenu.addAction(mailAction)
institutionMenu.addAction(listSignatureAction)
# Events Menu #
eventsMenu = mainMenu.addMenu(u"&Eventos")
eventsMenu.addAction(eventsAction)
# Clients Menu #
clientsMenu = mainMenu.addMenu(u"&Clientes")
clientsMenu.addAction(clientsAction)
# Certificates Menu #
certificatesMenu = mainMenu.addMenu(u"&Certificados")
certificatesMenu.addAction(certificatesAction)
# Help Menu #
helpMenu = mainMenu.addMenu("&Ajuda")
helpMenu.addAction(licenseAction)
helpMenu.addAction(aboutAction)
self.list_certificates()
def show_institution_data(self):
"""
Switches to the institution frame.
"""
inst_data_widget = InstitutionDataWidget()
self.central_widget.addWidget(inst_data_widget)
self.central_widget.setCurrentWidget(inst_data_widget)
def config_mail(self):
"""
Switches to the mail frame.
"""
config_mail_widget = ConfigMailWidget()
self.central_widget.addWidget(config_mail_widget)
self.central_widget.setCurrentWidget(config_mail_widget)
def list_signatures(self):
"""
Switches to the signatures frame.
"""
signatures_widget = SignaturesListWidget()
self.central_widget.addWidget(signatures_widget)
self.central_widget.setCurrentWidget(signatures_widget)
def list_events(self):
"""
Switches to the events frame.
"""
events_widget = EventsListWidget()
self.central_widget.addWidget(events_widget)
self.central_widget.setCurrentWidget(events_widget)
def list_clients(self):
"""
Switches to the clients frame.
"""
clients_widget = ClientsListWidget()
self.central_widget.addWidget(clients_widget)
self.central_widget.setCurrentWidget(clients_widget)
def list_certificates(self):
"""
Switches to the certificates frame.
"""
certificates_widget = CertificatesWidget()
self.central_widget.addWidget(certificates_widget)
self.central_widget.setCurrentWidget(certificates_widget)
def show_about(self):
"""
Shows the about dialog.
"""
msg = u"""Um gerador de certificados para cursos livres e eventos feito em Python para gerar certificados em PDF e, inclusive, enviá-los por e-mail. É só cadastrar seu evento e logo em seguida seus participantes e, voilà, certificados emitidos!\n\nMais informações em: https://github.com/juliarizza/certificate_generator
"""
about = QtGui.QMessageBox()
about.setGeometry(450, 300, 200, 200)
about.setIcon(QtGui.QMessageBox.Information)
about.setText(u"Sobre o Certifica!")
about.setInformativeText(msg)
about.setWindowTitle(u"Sobre o Certifica!")
about.setStandardButtons(QtGui.QMessageBox.Ok)
about.exec_()
def show_license(self):
"""
Shows the license dialog.
"""
msg = u"""Copyright (c) 2016 Júlia Rizza & licensed under GNU GPLv3\n\nMais informações em: https://github.com/juliarizza/certificate_generator"""
license = QtGui.QMessageBox()
license.setGeometry(450, 300, 200, 200)
license.setIcon(QtGui.QMessageBox.Information)
license.setText(u"Licença")
license.setInformativeText(msg)
license.setWindowTitle(u"Licença")
license.setStandardButtons(QtGui.QMessageBox.Ok)
license.exec_()
def run():
"""
Main function that executes the app.
"""
app = QtGui.QApplication(sys.argv)
# Initialize the database
createDB()
# Start the app
GUI = Window()
GUI.show()
sys.exit(app.exec_())
# Run the app
if __name__ == '__main__':
run()