コード例 #1
0
 def ok_method(self):
     username_text = self.username_lineEdit.text()
     password_text = self.password_lineEdit.text()
     if username_text == '' and password_text == '':
         self.close()
         self.gradeLevelWindow = Grade_Level()
         self.gradeLevelWindow.show()
     else:
         msg = QMessageBox()
         msg.setWindowIcon(QIcon('logo/sacred_logo.png'))
         msg.setWindowTitle('SHHS')
         msg.setText('Invalid Credentials')
         msg.setIcon(QMessageBox.Critical)
         x = msg.exec_()
         self.password_lineEdit.clear()
コード例 #2
0
class Kinder2_table(QMainWindow):
    def __init__(self):
        super(Kinder2_table, self).__init__()
        self.setWindowIcon(QIcon('logo/sacred_logo.png'))
        self.setWindowTitle('Kinder2 Table')
        self.ui()

    def ui(self):
        # menubar
        menuBar = self.menuBar()
        self.file_menu = menuBar.addMenu("File")
        self.edit_menu = menuBar.addMenu('Edit')

        # action for menubar
        self.refresh_action = QtWidgets.QAction('Main Table',self)
        self.refresh_action.setShortcut('F1')
        self.refresh_action.triggered.connect(self.main_table)
        self.file_menu.addAction(self.refresh_action)

        self.refresh_action = QtWidgets.QAction('Refresh',self)
        self.refresh_action.setShortcut('F5')
        self.refresh_action.triggered.connect(self.load_data)
        self.file_menu.addAction(self.refresh_action)

        self.close_action = QtWidgets.QAction('Close',self)
        self.close_action.setShortcut('Esc')
        self.close_action.triggered.connect(self.close_window)
        self.file_menu.addAction(self.close_action)

        self.add_record = QtWidgets.QAction('Add Record', self)
        self.add_record.triggered.connect(self.add_record_func)
        self.edit_menu.addAction(self.add_record)

        self.search_record = QtWidgets.QAction('Search Record', self)
        self.search_record.triggered.connect(self.search_record_func)
        self.edit_menu.addAction(self.search_record)

        self.delete_record = QtWidgets.QAction('Delete Record', self)
        self.delete_record.triggered.connect(self.delete_record_func)
        self.edit_menu.addAction(self.delete_record)

        # Create a Database
        self.conn = sqlite3.connect('kinder2_database.db')
        self.c = self.conn.cursor()
        self.c.execute("CREATE TABLE IF NOT EXISTS record(id TEXT, name TEXT, status TEXT, balance TEXT, amount_due TEXT)")

        # create table widget
        self.table_widget = QtWidgets.QTableWidget()
        self.setCentralWidget(self.table_widget)
        self.table_widget.setAlternatingRowColors(True)
        self.table_widget.setColumnCount(5)
        self.table_widget.horizontalHeader().setCascadingSectionResizes(False)
        self.table_widget.horizontalHeader().setSortIndicatorShown(False)
        self.table_widget.horizontalHeader().setStretchLastSection(True)
        self.table_widget.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
        self.table_widget.verticalHeader().setVisible(False)
        self.table_widget.verticalHeader().setCascadingSectionResizes(False)
        self.table_widget.verticalHeader().setStretchLastSection(False)
        self.table_widget.setHorizontalHeaderLabels(('ID#','Name','Status','Balance','Amount Due'))

        # setting a font size for table widget
        font = QtGui.QFont()
        font.setPointSize(12)
        self.table_widget.setFont(font)

        # function for loading data
    def load_data(self):
        self.conn = sqlite3.connect("database.db")
        query = "SELECT * FROM record"
        result = self.conn.execute(query)
        self.table_widget.setRowCount(0)
        self.table_widget.setRowCount(0)
        for row_number, row_data in enumerate(result):
            self.table_widget.insertRow(row_number)
            for column_number, data in enumerate(row_data):
                self.table_widget.setItem(row_number, column_number,QTableWidgetItem(str(data)))

    # Return back to table window class
    def main_table(self):
        from grade_level import Grade_Level
        self.window = Grade_Level()
        self.window.exec_()
        self.close()

        # function for menubar close
    def close_window(self):
        self.close()

        # function for add record menu
    def add_record_func(self):
        dialog = AddRecord()
        dialog.exec_()

        # function for search menu
    def search_record_func(self):
        dialog = Search()
        dialog.exec_()

        # function for delete menu
    def delete_record_func(self):
        dialog = Delete()
        dialog.exec_()
コード例 #3
0
 def main_table(self):
     from grade_level import Grade_Level
     self.window = Grade_Level()
     self.window.exec_()
     self.close()
コード例 #4
0
class Login_window(QWidget):
    def __init__(self):
        super(Login_window, self).__init__()
        self.setWindowIcon(QIcon('logo/sacred_logo.png'))
        self.setWindowTitle('SHHS Log In')
        self.ui()

    def ui(self):
        # layout
        self.main_layout = QVBoxLayout()
        self.form_layout = QFor = QFormLayout()
        self.button_Layout = QHBoxLayout()

        # create label and label font size
        labelFont = QtGui.QFont()
        labelFont.setPointSize(15)

        self.username_label = QtWidgets.QLabel()
        self.username_label.setText('Username')
        self.username_label.setFont(labelFont)

        self.password_label = QtWidgets.QLabel()
        self.password_label.setText('Password')
        self.password_label.setFont(labelFont)

        # create lineEdit
        lineEdit_font = QtGui.QFont()
        lineEdit_font.setPointSize(15)

        self.username_lineEdit = QtWidgets.QLineEdit()
        self.username_lineEdit.setFont(lineEdit_font)

        self.password_lineEdit = QtWidgets.QLineEdit()
        self.password_lineEdit.setEchoMode(QLineEdit.Password)
        self.password_lineEdit.setFont(lineEdit_font)

        # create Button widget
        button_font = QtGui.QFont()
        button_font.setPointSize(12)

        self.okbtn = QtWidgets.QPushButton('Ok')
        self.okbtn.setFont(button_font)
        self.okbtn.clicked.connect(self.ok_method)

        self.cancelbtn = QtWidgets.QPushButton('Cancel')
        self.cancelbtn.setFont(button_font)
        self.cancelbtn.clicked.connect(self.cancel_function)

        # add label and lineEdit widget to the layout
        self.form_layout.addRow(self.username_label, self.username_lineEdit)
        self.form_layout.addRow(self.password_label, self.password_lineEdit)

        # add button widget to the layout
        self.button_Layout.addWidget(self.okbtn)
        self.button_Layout.addWidget(self.cancelbtn)

        # nested layout
        self.main_layout.addLayout(self.form_layout)
        self.main_layout.addLayout(self.button_Layout)

        # set application layout
        self.setLayout(self.main_layout)

    def ok_method(self):
        username_text = self.username_lineEdit.text()
        password_text = self.password_lineEdit.text()
        if username_text == '' and password_text == '':
            self.close()
            self.gradeLevelWindow = Grade_Level()
            self.gradeLevelWindow.show()
        else:
            msg = QMessageBox()
            msg.setWindowIcon(QIcon('logo/sacred_logo.png'))
            msg.setWindowTitle('SHHS')
            msg.setText('Invalid Credentials')
            msg.setIcon(QMessageBox.Critical)
            x = msg.exec_()
            self.password_lineEdit.clear()

    def cancel_function(self):
        sys.exit()