HOME/Articles/

connectSQL_mainWindow

Article Outline

Example Python program connectSQL_mainWindow.py

Modules

  • from PyQt5 import QtCore, QtGui, QtWidgets

Classes

  • class Ui_MainWindow(object):

Methods

  • def setupUi(self, MainWindow):
  • def retranslateUi(self, MainWindow):

Code

Example Python PyQt program :

# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'mainWindow.ui'
#
# Created by: PyQt5 UI code generator 5.9.2
#
# WARNING! All changes made in this file will be lost!

from PyQt5 import QtCore, QtGui, QtWidgets

class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(700, 359)
        MainWindow.setMinimumSize(QtCore.QSize(700, 359))
        MainWindow.setMaximumSize(QtCore.QSize(700, 359))
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.systemView = QtWidgets.QTabWidget(self.centralwidget)
        self.systemView.setGeometry(QtCore.QRect(10, 10, 681, 301))
        self.systemView.setMinimumSize(QtCore.QSize(681, 301))
        self.systemView.setMaximumSize(QtCore.QSize(681, 301))
        self.systemView.setObjectName("systemView")
        self.inoutview = QtWidgets.QWidget()
        self.inoutview.setObjectName("inoutview")
        self.input_Button = QtWidgets.QPushButton(self.inoutview)
        self.input_Button.setGeometry(QtCore.QRect(220, 210, 111, 31))
        self.input_Button.setObjectName("input_Button")
        self.formLayoutWidget = QtWidgets.QWidget(self.inoutview)
        self.formLayoutWidget.setGeometry(QtCore.QRect(280, 40, 321, 141))
        self.formLayoutWidget.setObjectName("formLayoutWidget")
        self.formLayout = QtWidgets.QFormLayout(self.formLayoutWidget)
        self.formLayout.setContentsMargins(0, 0, 0, 0)
        self.formLayout.setObjectName("formLayout")
        self.name_label = QtWidgets.QLabel(self.formLayoutWidget)
        font = QtGui.QFont()
        font.setFamily("微软雅黑")
        self.name_label.setFont(font)
        self.name_label.setObjectName("name_label")
        self.formLayout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.name_label)
        self.name_lineEdit = QtWidgets.QLineEdit(self.formLayoutWidget)
        self.name_lineEdit.setObjectName("name_lineEdit")
        self.formLayout.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.name_lineEdit)
        self.number_label = QtWidgets.QLabel(self.formLayoutWidget)
        font = QtGui.QFont()
        font.setFamily("微软雅黑")
        self.number_label.setFont(font)
        self.number_label.setObjectName("number_label")
        self.formLayout.setWidget(3, QtWidgets.QFormLayout.LabelRole, self.number_label)
        self.number_lineEdit = QtWidgets.QLineEdit(self.formLayoutWidget)
        self.number_lineEdit.setObjectName("number_lineEdit")
        self.formLayout.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.number_lineEdit)
        self.no_label = QtWidgets.QLabel(self.formLayoutWidget)
        font = QtGui.QFont()
        font.setFamily("微软雅黑")
        self.no_label.setFont(font)
        self.no_label.setObjectName("no_label")
        self.formLayout.setWidget(5, QtWidgets.QFormLayout.LabelRole, self.no_label)
        self.no_lineEdit = QtWidgets.QLineEdit(self.formLayoutWidget)
        self.no_lineEdit.setObjectName("no_lineEdit")
        self.formLayout.setWidget(5, QtWidgets.QFormLayout.FieldRole, self.no_lineEdit)
        self.output_Button = QtWidgets.QPushButton(self.inoutview)
        self.output_Button.setGeometry(QtCore.QRect(340, 210, 111, 31))
        self.output_Button.setObjectName("output_Button")
        self.INOUT_Display = QtWidgets.QTextBrowser(self.inoutview)
        self.INOUT_Display.setGeometry(QtCore.QRect(45, 40, 221, 121))
        self.INOUT_Display.setObjectName("INOUT_Display")
        self.systemView.addTab(self.inoutview, "")
        self.searchview = QtWidgets.QWidget()
        self.searchview.setObjectName("searchview")
        self.search_Button = QtWidgets.QPushButton(self.searchview)
        self.search_Button.setGeometry(QtCore.QRect(400, 20, 93, 21))
        self.search_Button.setObjectName("search_Button")
        self.search_lineEdit = QtWidgets.QLineEdit(self.searchview)
        self.search_lineEdit.setGeometry(QtCore.QRect(230, 20, 151, 21))
        self.search_lineEdit.setObjectName("search_lineEdit")
        self.search_label = QtWidgets.QLabel(self.searchview)
        self.search_label.setGeometry(QtCore.QRect(140, 20, 81, 20))
        font = QtGui.QFont()
        font.setFamily("微软雅黑")
        self.search_label.setFont(font)
        self.search_label.setObjectName("search_label")
        self.searchView = QtWidgets.QTableWidget(self.searchview)
        self.searchView.setGeometry(QtCore.QRect(70, 50, 521, 221))
        font = QtGui.QFont()
        font.setFamily("微软雅黑")
        self.searchView.setFont(font)
        self.searchView.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.searchView.setLayoutDirection(QtCore.Qt.LeftToRight)
        self.searchView.setAutoFillBackground(False)
        self.searchView.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
        self.searchView.setAlternatingRowColors(False)
        self.searchView.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
        self.searchView.setTextElideMode(QtCore.Qt.ElideRight)
        self.searchView.setShowGrid(True)
        self.searchView.setGridStyle(QtCore.Qt.SolidLine)
        self.searchView.setWordWrap(True)
        self.searchView.setRowCount(5)
        self.searchView.setObjectName("searchView")
        self.searchView.setColumnCount(4)
        item = QtWidgets.QTableWidgetItem()
        self.searchView.setVerticalHeaderItem(0, item)
        item = QtWidgets.QTableWidgetItem()
        self.searchView.setVerticalHeaderItem(1, item)
        item = QtWidgets.QTableWidgetItem()
        self.searchView.setVerticalHeaderItem(2, item)
        item = QtWidgets.QTableWidgetItem()
        self.searchView.setHorizontalHeaderItem(0, item)
        item = QtWidgets.QTableWidgetItem()
        self.searchView.setHorizontalHeaderItem(1, item)
        item = QtWidgets.QTableWidgetItem()
        self.searchView.setHorizontalHeaderItem(2, item)
        item = QtWidgets.QTableWidgetItem()
        self.searchView.setHorizontalHeaderItem(3, item)
        self.systemView.addTab(self.searchview, "")
        self.changeview = QtWidgets.QWidget()
        self.changeview.setObjectName("changeview")
        self.pushButton_3 = QtWidgets.QPushButton(self.changeview)
        self.pushButton_3.setGeometry(QtCore.QRect(270, 240, 93, 28))
        self.pushButton_3.setObjectName("pushButton_3")
        self.formLayoutWidget_2 = QtWidgets.QWidget(self.changeview)
        self.formLayoutWidget_2.setGeometry(QtCore.QRect(350, 40, 311, 150))
        self.formLayoutWidget_2.setObjectName("formLayoutWidget_2")
        self.formLayout_2 = QtWidgets.QFormLayout(self.formLayoutWidget_2)
        self.formLayout_2.setContentsMargins(0, 0, 0, 0)
        self.formLayout_2.setObjectName("formLayout_2")
        self.no_label_2 = QtWidgets.QLabel(self.formLayoutWidget_2)
        font = QtGui.QFont()
        font.setFamily("微软雅黑")
        self.no_label_2.setFont(font)
        self.no_label_2.setObjectName("no_label_2")
        self.formLayout_2.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.no_label_2)
        self.lineEdit_no = QtWidgets.QLineEdit(self.formLayoutWidget_2)
        self.lineEdit_no.setObjectName("lineEdit_no")
        self.formLayout_2.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.lineEdit_no)
        self.tip_label = QtWidgets.QLabel(self.formLayoutWidget_2)
        self.tip_label.setObjectName("tip_label")
        self.formLayout_2.setWidget(3, QtWidgets.QFormLayout.SpanningRole, self.tip_label)
        self.label_name = QtWidgets.QLabel(self.formLayoutWidget_2)
        font = QtGui.QFont()
        font.setFamily("微软雅黑")
        self.label_name.setFont(font)
        self.label_name.setObjectName("label_name")
        self.formLayout_2.setWidget(4, QtWidgets.QFormLayout.LabelRole, self.label_name)
        self.lineEdit_name = QtWidgets.QLineEdit(self.formLayoutWidget_2)
        self.lineEdit_name.setObjectName("lineEdit_name")
        self.formLayout_2.setWidget(4, QtWidgets.QFormLayout.FieldRole, self.lineEdit_name)
        self.label_price = QtWidgets.QLabel(self.formLayoutWidget_2)
        font = QtGui.QFont()
        font.setFamily("微软雅黑")
        self.label_price.setFont(font)
        self.label_price.setObjectName("label_price")
        self.formLayout_2.setWidget(5, QtWidgets.QFormLayout.LabelRole, self.label_price)
        self.lineEdit_price = QtWidgets.QLineEdit(self.formLayoutWidget_2)
        self.lineEdit_price.setObjectName("lineEdit_price")
        self.formLayout_2.setWidget(5, QtWidgets.QFormLayout.FieldRole, self.lineEdit_price)
        self.changeView = QtWidgets.QTableWidget(self.changeview)
        self.changeView.setGeometry(QtCore.QRect(10, 40, 331, 151))
        font = QtGui.QFont()
        font.setFamily("微软雅黑")
        font.setPointSize(6)
        self.changeView.setFont(font)
        self.changeView.setObjectName("changeView")
        self.changeView.setColumnCount(0)
        self.changeView.setRowCount(0)
        self.systemView.addTab(self.changeview, "")
        self.tab = QtWidgets.QWidget()
        self.tab.setObjectName("tab")
        self.changed_TableView = QtWidgets.QTableWidget(self.tab)
        self.changed_TableView.setGeometry(QtCore.QRect(30, 40, 611, 192))
        font = QtGui.QFont()
        font.setFamily("微软雅黑")
        self.changed_TableView.setFont(font)
        self.changed_TableView.setObjectName("changed_TableView")
        self.changed_TableView.setColumnCount(0)
        self.changed_TableView.setRowCount(0)
        self.toolButton = QtWidgets.QToolButton(self.tab)
        self.toolButton.setGeometry(QtCore.QRect(230, 10, 191, 21))
        self.toolButton.setObjectName("toolButton")
        self.systemView.addTab(self.tab, "")
        self.loginClicked = QtWidgets.QPushButton(self.centralwidget)
        self.loginClicked.setGeometry(QtCore.QRect(582, 0, 111, 28))
        self.loginClicked.setObjectName("loginClicked")
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 700, 26))
        self.menubar.setObjectName("menubar")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        self.systemView.setCurrentIndex(3)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "仓库进销存系统-戢浩源201731064317"))
        self.input_Button.setText(_translate("MainWindow", "入库"))
        self.name_label.setText(_translate("MainWindow", "产品名称"))
        self.number_label.setText(_translate("MainWindow", "数目"))
        self.no_label.setText(_translate("MainWindow", "单价"))
        self.output_Button.setText(_translate("MainWindow", "出库"))
        self.systemView.setTabText(self.systemView.indexOf(self.inoutview), _translate("MainWindow", "出入库登记"))
        self.search_Button.setText(_translate("MainWindow", "查询"))
        self.search_label.setText(_translate("MainWindow", "输入产品名称:"))
        self.searchView.setSortingEnabled(False)
        item = self.searchView.verticalHeaderItem(0)
        item.setText(_translate("MainWindow", "1"))
        item = self.searchView.verticalHeaderItem(1)
        item.setText(_translate("MainWindow", "2"))
        item = self.searchView.verticalHeaderItem(2)
        item.setText(_translate("MainWindow", "3"))
        item = self.searchView.horizontalHeaderItem(0)
        item.setText(_translate("MainWindow", "产品名"))
        item = self.searchView.horizontalHeaderItem(1)
        item.setText(_translate("MainWindow", "编号"))
        item = self.searchView.horizontalHeaderItem(2)
        item.setText(_translate("MainWindow", "库存数目"))
        item = self.searchView.horizontalHeaderItem(3)
        item.setText(_translate("MainWindow", "单价"))
        self.systemView.setTabText(self.systemView.indexOf(self.searchview), _translate("MainWindow", "库存信息查询"))
        self.pushButton_3.setText(_translate("MainWindow", "保存修改"))
        self.no_label_2.setText(_translate("MainWindow", "编号"))
        self.tip_label.setText(_translate("MainWindow", "(输入需要修改的选项)"))
        self.label_name.setText(_translate("MainWindow", "产品名称"))
        self.label_price.setText(_translate("MainWindow", "单价"))
        self.systemView.setTabText(self.systemView.indexOf(self.changeview), _translate("MainWindow", "库存产品信息维护"))
        self.toolButton.setText(_translate("MainWindow", "显示最近十次操作记录"))
        self.systemView.setTabText(self.systemView.indexOf(self.tab), _translate("MainWindow", "操作记录"))
        self.loginClicked.setText(_translate("MainWindow", "请登录"))