def load_table(self): self.clientsTable.clear() cursor.execute("SELECT * FROM clients") data = cursor.fetchall() if len(data) < 10: self.clientsTable.setRowCount(10) else: self.clientsTable.setRowCount(len(data)) self.clientsTable.setColumnCount(4) self.clientsTable.setHorizontalHeaderLabels( (u"ID", u"Nome Completo", u"E-mail", u"CPF")) self.clientsTable.horizontalHeader().setResizeMode( QtGui.QHeaderView.Stretch) self.clientsTable.verticalHeader().setResizeMode( QtGui.QHeaderView.Stretch) r, c = 0, 0 for item in data: for i in range(4): newitem = QtGui.QTableWidgetItem(unicode(item[i])) self.clientsTable.setItem(r, c, newitem) c += 1 r += 1 c = 0
def load_list(self): """ Loads all subscriptions of the selected event and insert them in the subscriptionList widget. """ # Get the subscripted clients if self.events: cursor.execute( "SELECT id,client_id FROM subscriptions WHERE event_id=?", str(self.events[self.eventsList.currentIndex()][0]) ) self.clients = cursor.fetchall() else: self.clients = [] # Clears the widget to insert updated info self.subscriptionList.clear() # Select all subscripted clients and add them # to the subscriptionList widget for client in self.clients: cursor.execute( "SELECT name FROM clients WHERE id=?", str(client[1]) ) client_name = cursor.fetchone() if client: self.subscriptionList.addItem(unicode(client_name[0]))
def __init__(self, certificates_instance, event_id): super(AddClientDialog,self).__init__() self.setWindowTitle(u"Adicionar cliente") self.event_id = event_id self.certificates_instance = certificates_instance cursor.execute("SELECT * FROM clients ORDER BY name ASC") self.clients = cursor.fetchall() self.mainLayout = QtGui.QVBoxLayout() self.titleLabel = QtGui.QLabel(u"Selecione um cliente") self.titleLabel.setFont(titleFont) self.clientsList = QtGui.QComboBox() for client in self.clients: self.clientsList.addItem(unicode(client[1])) self.saveBtn = QtGui.QPushButton(u"Selecionar") self.saveBtn.clicked.connect(self.add_client) self.mainLayout.addWidget(self.titleLabel) self.mainLayout.addWidget(self.clientsList) self.mainLayout.addWidget(self.saveBtn) self.setLayout(self.mainLayout)
def load_table(self): self.eventsTable.clear() cursor.execute("SELECT * FROM events ORDER BY id DESC") data = cursor.fetchall() if len(data) < 10: self.eventsTable.setRowCount(10) else: self.eventsTable.setRowCount(len(data)) self.eventsTable.setColumnCount(4) self.eventsTable.setHorizontalHeaderLabels((u"ID", u"Título", u"Data de Início", u"Data de Término")) self.eventsTable.horizontalHeader().setResizeMode(QtGui.QHeaderView.Stretch) self.eventsTable.verticalHeader().setResizeMode(QtGui.QHeaderView.Stretch) r,c=0,0 for item in data: for i in range(4): newitem = QtGui.QTableWidgetItem(unicode(item[i])) self.eventsTable.setItem(r,c,newitem) c += 1 r += 1 c = 0
def load_list(self): """ Loads all subscriptions of the selected event and insert them in the subscriptionList widget. """ # Get the subscripted clients if self.events: cursor.execute( "SELECT id,client_id FROM subscriptions WHERE event_id=?", (str(self.events[self.eventsList.currentIndex()][0]),) ) self.clients = cursor.fetchall() else: self.clients = [] # Clears the widget to insert updated info self.subscriptionList.clear() # Select all subscripted clients and add them # to the subscriptionList widget for client in self.clients: cursor.execute( "SELECT name FROM clients WHERE id=?", (str(client[1]),) ) client_name = cursor.fetchone() if client: self.subscriptionList.addItem(unicode(client_name[0]))
def load_table(self): self.clientsTable.clear() cursor.execute("SELECT * FROM clients") data = cursor.fetchall() if len(data) < 10: self.clientsTable.setRowCount(10) else: self.clientsTable.setRowCount(len(data)) self.clientsTable.setColumnCount(4) self.clientsTable.setHorizontalHeaderLabels((u"ID", u"Nome Completo", u"E-mail", u"CPF")) self.clientsTable.horizontalHeader().setResizeMode(QtGui.QHeaderView.Stretch) self.clientsTable.verticalHeader().setResizeMode(QtGui.QHeaderView.Stretch) r,c=0,0 for item in data: for i in range(4): newitem = QtGui.QTableWidgetItem(unicode(item[i])) self.clientsTable.setItem(r,c,newitem) c += 1 r += 1 c = 0
def load_table(self): self.eventsTable.clear() cursor.execute("SELECT * FROM events") data = cursor.fetchall() if len(data) < 10: self.eventsTable.setRowCount(10) else: self.eventsTable.setRowCount(len(data)) self.eventsTable.setColumnCount(4) self.eventsTable.setHorizontalHeaderLabels((u"ID", u"Título", u"Data de Início", u"Data de Término")) self.eventsTable.horizontalHeader().setResizeMode(QtGui.QHeaderView.Stretch) self.eventsTable.verticalHeader().setResizeMode(QtGui.QHeaderView.Stretch) r,c=0,0 for item in data: for i in range(4): newitem = QtGui.QTableWidgetItem(str(item[i])) self.eventsTable.setItem(r,c,newitem) c += 1 r += 1 c = 0
def __init__(self, certificates_instance, event_id): super(AddClientDialog, self).__init__() self.event_id = event_id self.certificates_instance = certificates_instance cursor.execute("SELECT * FROM clients") self.clients = cursor.fetchall() self.mainLayout = QtGui.QVBoxLayout() self.titleLabel = QtGui.QLabel("Selecione um cliente") self.titleLabel.setFont(titleFont) self.clientsList = QtGui.QComboBox() for client in self.clients: self.clientsList.addItem(str(client[1])) self.saveBtn = QtGui.QPushButton("Selecionar") self.saveBtn.clicked.connect(self.add_client) self.mainLayout.addWidget(self.titleLabel) self.mainLayout.addWidget(self.clientsList) self.mainLayout.addWidget(self.saveBtn) self.setLayout(self.mainLayout)
def load_list(self): self.signaturesList.clear() cursor.execute("SELECT * FROM signatures ORDER BY name ASC") self.signatures = cursor.fetchall() for sig in self.signatures: self.signaturesList.addItem(unicode(sig[1]))
def load_list(self): self.signaturesList.clear() cursor.execute("SELECT * FROM signatures") self.signatures = cursor.fetchall() for sig in self.signatures: self.signaturesList.addItem(sig[1])
def select(table: str, values: Dict) -> List: """ todo add try/except and exceptions processing; for now it's suitable only for login case """ values_ToSelect = values['select_values'] condition = values['condition'] cursor.execute(f"SELECT {values_ToSelect} " f"FROM {table} " f"WHERE username =\'{condition['username']}\';") result = cursor.fetchall() return result
def load_list(self): if self.events: cursor.execute("SELECT id,client_id FROM subscriptions WHERE event_id=?", str(self.events[self.eventsList.currentIndex()][0])) self.clients = cursor.fetchall() else: self.clients = [] self.subscriptionList.clear() for client in self.clients: cursor.execute("SELECT name FROM clients WHERE id=?",str(client[1])) client_name = unicode(cursor.fetchone()[0]) self.subscriptionList.addItem(client_name)
def load_list(self): """ Updates the list widget with the signatures data. """ # Clear the list widget to add new data self.signaturesList.clear() # Select all signatures cursor.execute("SELECT * FROM signatures ORDER BY name ASC") self.signatures = cursor.fetchall() # Add all signatures to the list widget for sig in self.signatures: self.signaturesList.addItem(unicode(sig[1]))
def load_list(self): if self.events: cursor.execute( "SELECT id,client_id FROM subscriptions WHERE event_id=?", str(self.events[self.eventsList.currentIndex()][0])) self.clients = cursor.fetchall() else: self.clients = [] self.subscriptionList.clear() for client in self.clients: cursor.execute("SELECT name FROM clients WHERE id=?", str(client[1])) client_name = cursor.fetchone()[0] self.subscriptionList.addItem(str(client_name))
def load_table(self): """ Populates the events table with the existing events. """ # Clears the table to show new records self.eventsTable.clear() # Select the records to show cursor.execute("SELECT * FROM events ORDER BY id DESC") data = cursor.fetchall() # Set the table default number of rows to 10 # If there is more than 10 records, set to the len # of the records if len(data) < 10: self.eventsTable.setRowCount(10) else: self.eventsTable.setRowCount(len(data)) # Set columns quantity and name self.eventsTable.setColumnCount(4) self.eventsTable.setHorizontalHeaderLabels( (u"ID", u"Título", u"Data de Início", u"Data de Término") ) # Make columns and rows fit sizes to the window self.eventsTable.horizontalHeader().setResizeMode( QtGui.QHeaderView.Stretch ) self.eventsTable.verticalHeader().setResizeMode( QtGui.QHeaderView.Stretch ) # Updates the table with the selected records r,c = 0,0 for item in data: for i in range(4): newitem = QtGui.QTableWidgetItem(unicode(item[i])) self.eventsTable.setItem(r, c, newitem) c += 1 r += 1 c = 0
def load_table(self): """ Populates the events table with the existing events. """ # Clears the table to show new records self.eventsTable.clear() # Select the records to show cursor.execute("SELECT * FROM events ORDER BY id DESC") data = cursor.fetchall() # Set the table default number of rows to 10 # If there is more than 10 records, set to the len # of the records if len(data) < 10: self.eventsTable.setRowCount(10) else: self.eventsTable.setRowCount(len(data)) # Set columns quantity and name self.eventsTable.setColumnCount(4) self.eventsTable.setHorizontalHeaderLabels( (u"ID", u"Título", u"Data de Início", u"Data de Término")) # Make columns and rows fit sizes to the window self.eventsTable.horizontalHeader().setResizeMode( QtGui.QHeaderView.Stretch) self.eventsTable.verticalHeader().setResizeMode( QtGui.QHeaderView.Stretch) # Updates the table with the selected records r, c = 0, 0 for item in data: for i in range(4): newitem = QtGui.QTableWidgetItem(unicode(item[i])) self.eventsTable.setItem(r, c, newitem) c += 1 r += 1 c = 0
def __init__(self, certificates_instance, event_id): """ Setup widgets and select data from database. """ super(AddClientDialog, self).__init__() # Window config self.setWindowTitle(u"Adicionar cliente") self.certificates_instance = certificates_instance self.event_id = event_id # Select clients in alphabetical order cursor.execute("SELECT * FROM clients ORDER BY name ASC") self.clients = cursor.fetchall() # Define layouts self.mainLayout = QtGui.QVBoxLayout() # Frame config self.titleLabel = QtGui.QLabel(u"Selecione um cliente") self.titleLabel.setFont(titleFont) # Fill combo with clients info self.clientsList = QtGui.QComboBox() for client in self.clients: self.clientsList.addItem(unicode(client[1])) # Create the main button self.saveBtn = QtGui.QPushButton(u"Selecionar") self.saveBtn.clicked.connect(self.add_client) # Add all widgets to the mainLayout self.mainLayout.addWidget(self.titleLabel) self.mainLayout.addWidget(self.clientsList) self.mainLayout.addWidget(self.saveBtn) # Set mainLayout as the visible layout self.setLayout(self.mainLayout)
def __init__(self): super(CertificatesWidget, self).__init__() self.Config = ConfigParser.ConfigParser() self.Config.read(os.path.join(app_dir,"institution.ini")) cursor.execute("SELECT * FROM events ORDER BY id DESC") self.events = cursor.fetchall() cursor.execute("SELECT * FROM signatures ORDER BY name ASC") self.signatures = cursor.fetchall() self.mainLayout = QtGui.QVBoxLayout() self.listLayout = QtGui.QHBoxLayout() self.btnsLayout = QtGui.QVBoxLayout() self.respLayout = QtGui.QVBoxLayout() self.instLayout = QtGui.QVBoxLayout() self.combosLayoutH = QtGui.QHBoxLayout() self.generateBtnsLayout = QtGui.QHBoxLayout() self.titleLabel = QtGui.QLabel(u"Certificados",self) self.titleLabel.setFont(titleFont) self.addBtn = QtGui.QPushButton(u"Adicionar") self.addBtn.clicked.connect(self.add_client) self.removeBtn = QtGui.QPushButton(u"Remover") self.removeBtn.clicked.connect(self.remove_client) self.btnsLayout.addWidget(self.addBtn) self.btnsLayout.addWidget(self.removeBtn) self.btnsLayout.addStretch() self.eventsListName = QtGui.QLabel(u"Selecione um evento:", self) self.eventsList = QtGui.QComboBox() for event in self.events: self.eventsList.addItem(unicode(event[1])) self.eventsList.currentIndexChanged.connect(self.load_list) self.subscriptionListName = QtGui.QLabel(u"Inscritos", self) self.subscriptionList = QtGui.QListWidget() self.load_list() self.responsibleListName = QtGui.QLabel(u"Selecione um responsável/ministrante:",self) self.responsibleList = QtGui.QComboBox() self.institutionListName = QtGui.QLabel(u"Assinatura da instituição:", self) self.institutionList = QtGui.QComboBox() for sig in self.signatures: self.responsibleList.addItem(unicode(sig[1])) self.institutionList.addItem(unicode(sig[1])) self.errorMsg = QtGui.QLabel(u"",self) self.errorMsg.setStyleSheet("color: red; font-weight: bold;") self.previewBtn = QtGui.QPushButton(u"Preview") self.previewBtn.clicked.connect(self.preview_certificate) self.generateBtn = QtGui.QPushButton(u"Gerar!") self.generateBtn.clicked.connect(self.generate) self.generateSendBtn = QtGui.QPushButton(u"Gerar e enviar por email!") self.generateSendBtn.clicked.connect(self.generate_send) self.generateBtnsLayout.addWidget(self.previewBtn) self.generateBtnsLayout.addWidget(self.generateBtn) self.generateBtnsLayout.addWidget(self.generateSendBtn) self.listLayout.addWidget(self.subscriptionList) self.listLayout.addLayout(self.btnsLayout) self.respLayout.addWidget(self.responsibleListName) self.respLayout.addWidget(self.responsibleList) self.instLayout.addWidget(self.institutionListName) self.instLayout.addWidget(self.institutionList) self.combosLayoutH.addLayout(self.respLayout) self.combosLayoutH.addLayout(self.instLayout) self.mainLayout.addWidget(self.titleLabel) self.mainLayout.addWidget(self.eventsListName) self.mainLayout.addWidget(self.eventsList) self.mainLayout.addWidget(self.subscriptionListName) self.mainLayout.addLayout(self.listLayout) self.mainLayout.addLayout(self.combosLayoutH) self.mainLayout.addWidget(self.errorMsg) self.mainLayout.addLayout(self.generateBtnsLayout) self.setLayout(self.mainLayout)
def __init__(self): """ Setup widgets and select data from database. """ super(CertificatesWidget, self).__init__() # Window settings self.save_folder = "" # Connects with configuration file to get info self.Config = ConfigParser.ConfigParser() self.Config.read(os.path.join(app_dir, "institution.ini")) cursor.execute("SELECT * FROM events ORDER BY id DESC") self.events = cursor.fetchall() cursor.execute("SELECT * FROM signatures ORDER BY name ASC") self.signatures = cursor.fetchall() # Defines all layouts self.mainLayout = QtGui.QVBoxLayout() self.listLayout = QtGui.QHBoxLayout() self.btnsLayout = QtGui.QVBoxLayout() self.respLayout = QtGui.QVBoxLayout() self.instLayout = QtGui.QVBoxLayout() self.combosLayoutH = QtGui.QHBoxLayout() self.generateBtnsLayout = QtGui.QHBoxLayout() # Window config self.titleLabel = QtGui.QLabel(u"Certificados", self) self.titleLabel.setFont(titleFont) # Make buttons layout self.addBtn = QtGui.QPushButton(u"Adicionar") self.addBtn.clicked.connect(self.add_client) self.removeBtn = QtGui.QPushButton(u"Remover") self.removeBtn.clicked.connect(self.remove_client) self.btnsLayout.addWidget(self.addBtn) self.btnsLayout.addWidget(self.removeBtn) self.btnsLayout.addStretch() # Fill combobox with event info self.eventsListName = QtGui.QLabel(u"Selecione um evento:", self) self.eventsList = QtGui.QComboBox() for event in self.events: self.eventsList.addItem(unicode(event[1])) self.eventsList.currentIndexChanged.connect(self.load_list) # Fill listwidget with subscriptions info self.subscriptionListName = QtGui.QLabel(u"Inscritos", self) self.subscriptionList = QtGui.QListWidget() self.load_list() # Fill both responsible and institution combos # with signatures info self.responsibleListName = QtGui.QLabel( u"Selecione um responsável/ministrante:", self ) self.responsibleList = QtGui.QComboBox() self.institutionListName = QtGui.QLabel( u"Assinatura da instituição:", self ) self.institutionList = QtGui.QComboBox() for sig in self.signatures: self.responsibleList.addItem(unicode(sig[1])) self.institutionList.addItem(unicode(sig[1])) # A label for showing errors self.errorMsg = QtGui.QLabel(u"", self) self.errorMsg.setStyleSheet("color: red; font-weight: bold;") # Defines buttons for preview, generate and mail certificates self.previewBtn = QtGui.QPushButton(u"Preview") self.previewBtn.clicked.connect(self.preview_certificate) self.generateBtn = QtGui.QPushButton(u"Gerar!") self.generateBtn.clicked.connect(self.generate) self.generateSendBtn = QtGui.QPushButton(u"Gerar e enviar por email!") self.generateSendBtn.clicked.connect(self.generate_send) # Add them to generateBtnsLayout self.generateBtnsLayout.addWidget(self.previewBtn) self.generateBtnsLayout.addWidget(self.generateBtn) self.generateBtnsLayout.addWidget(self.generateSendBtn) # Add subscriptions list to listLayout self.listLayout.addWidget(self.subscriptionList) self.listLayout.addLayout(self.btnsLayout) # Add signatures info to their specific layouts self.respLayout.addWidget(self.responsibleListName) self.respLayout.addWidget(self.responsibleList) self.instLayout.addWidget(self.institutionListName) self.instLayout.addWidget(self.institutionList) self.combosLayoutH.addLayout(self.respLayout) self.combosLayoutH.addLayout(self.instLayout) # Add everything to the mainLayout self.mainLayout.addWidget(self.titleLabel) self.mainLayout.addWidget(self.eventsListName) self.mainLayout.addWidget(self.eventsList) self.mainLayout.addWidget(self.subscriptionListName) self.mainLayout.addLayout(self.listLayout) self.mainLayout.addLayout(self.combosLayoutH) self.mainLayout.addWidget(self.errorMsg) self.mainLayout.addLayout(self.generateBtnsLayout) # Set the mainLayout as the visible layout self.setLayout(self.mainLayout)
def __init__(self): super(CertificatesWidget, self).__init__() self.Config = ConfigParser.ConfigParser() self.Config.read("institution.ini") cursor.execute("SELECT * FROM events") self.events = cursor.fetchall() cursor.execute("SELECT * FROM signatures") self.signatures = cursor.fetchall() self.mainLayout = QtGui.QVBoxLayout() self.listLayout = QtGui.QHBoxLayout() self.btnsLayout = QtGui.QVBoxLayout() self.respLayout = QtGui.QVBoxLayout() self.instLayout = QtGui.QVBoxLayout() self.combosLayoutH = QtGui.QHBoxLayout() self.generateBtnsLayout = QtGui.QHBoxLayout() self.titleLabel = QtGui.QLabel("Certificados", self) self.titleLabel.setFont(titleFont) self.addBtn = QtGui.QPushButton("Adicionar") self.addBtn.clicked.connect(self.add_client) self.removeBtn = QtGui.QPushButton("Remover") self.removeBtn.clicked.connect(self.remove_client) self.btnsLayout.addWidget(self.addBtn) self.btnsLayout.addWidget(self.removeBtn) self.btnsLayout.addStretch() self.eventsListName = QtGui.QLabel("Selecione um evento:", self) self.eventsList = QtGui.QComboBox() for event in self.events: self.eventsList.addItem(event[1]) self.eventsList.currentIndexChanged.connect(self.load_list) self.subscriptionListName = QtGui.QLabel("Inscritos", self) self.subscriptionList = QtGui.QListWidget() self.load_list() self.responsibleListName = QtGui.QLabel( u"Selecione um responsável/ministrante:", self) self.responsibleList = QtGui.QComboBox() self.institutionListName = QtGui.QLabel(u"Assinatura da instituição:", self) self.institutionList = QtGui.QComboBox() for sig in self.signatures: self.responsibleList.addItem(str(sig[1])) self.institutionList.addItem(str(sig[1])) self.errorMsg = QtGui.QLabel("", self) self.errorMsg.setStyleSheet("color: red; font-weight: bold;") self.generateBtn = QtGui.QPushButton("Gerar!") self.generateBtn.clicked.connect(self.generate) self.generateSendBtn = QtGui.QPushButton("Gerar e enviar por email!") self.generateSendBtn.clicked.connect(self.generate_send) self.generateBtnsLayout.addWidget(self.generateBtn) self.generateBtnsLayout.addWidget(self.generateSendBtn) self.listLayout.addWidget(self.subscriptionList) self.listLayout.addLayout(self.btnsLayout) self.respLayout.addWidget(self.responsibleListName) self.respLayout.addWidget(self.responsibleList) self.instLayout.addWidget(self.institutionListName) self.instLayout.addWidget(self.institutionList) self.combosLayoutH.addLayout(self.respLayout) self.combosLayoutH.addLayout(self.instLayout) self.mainLayout.addWidget(self.titleLabel) self.mainLayout.addWidget(self.eventsListName) self.mainLayout.addWidget(self.eventsList) self.mainLayout.addWidget(self.subscriptionListName) self.mainLayout.addLayout(self.listLayout) self.mainLayout.addLayout(self.combosLayoutH) self.mainLayout.addWidget(self.errorMsg) self.mainLayout.addLayout(self.generateBtnsLayout) self.setLayout(self.mainLayout)