PyQt5 - Updating a label from a edit Window using Line Edit - python

I have trouble time creating a program wherein I have two window where the Main Window wherein you can see all the data and the other is the edit Window where editing or updating the label from the Main Window using the Line Edit from the edit Window
I want to pass the changes from Line Edit that is in the edit Window to the Label in Main Window
Here is the code Main Window, derived from Qt Designer:
from PyQt5 import QtCore, QtGui, QtWidgets
from FinalEditForm import Ui_editWindow
class Ui_MainWindow(object):
def openWindow(self):
self.window = QtWidgets.QMainWindow()
self.ui = Ui_editWindow()
self.ui.setupUi(self.window)
self.window.show()
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(634, 578)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.gridLayout_3 = QtWidgets.QGridLayout(self.centralwidget)
self.gridLayout_3.setContentsMargins(10, 10, 10, 10)
self.gridLayout_3.setObjectName("gridLayout_3")
self.tabWidget = QtWidgets.QTabWidget(self.centralwidget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.tabWidget.sizePolicy().hasHeightForWidth())
self.tabWidget.setSizePolicy(sizePolicy)
self.tabWidget.setObjectName("tabWidget")
self.widget = QtWidgets.QWidget()
self.widget.setObjectName("widget")
self.gridLayout = QtWidgets.QGridLayout(self.widget)
self.gridLayout.setContentsMargins(0, 0, 0, 0)
self.gridLayout.setObjectName("gridLayout")
self.scrollArea = QtWidgets.QScrollArea(self.widget)
self.scrollArea.setWidgetResizable(True)
self.scrollArea.setObjectName("scrollArea")
self.scrollAreaWidgetContents = QtWidgets.QWidget()
self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 588, 492))
self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents")
self.label = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label.setGeometry(QtCore.QRect(38, 20, 81, 21))
font = QtGui.QFont()
font.setPointSize(10)
font.setBold(True)
font.setWeight(75)
self.label.setFont(font)
self.label.setObjectName("label")
self.label_2 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_2.setGeometry(QtCore.QRect(160, 20, 121, 21))
font = QtGui.QFont()
font.setPointSize(10)
font.setBold(True)
font.setWeight(75)
self.label_2.setFont(font)
self.label_2.setObjectName("label_2")
self.label_3 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_3.setGeometry(QtCore.QRect(317, 20, 61, 21))
font = QtGui.QFont()
font.setPointSize(10)
font.setBold(True)
font.setWeight(75)
self.label_3.setFont(font)
self.label_3.setObjectName("label_3")
self.label_4 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_4.setGeometry(QtCore.QRect(400, 20, 141, 21))
font = QtGui.QFont()
font.setPointSize(10)
font.setBold(True)
font.setWeight(75)
self.label_4.setFont(font)
self.label_4.setObjectName("label_4")
self.label_5 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_5.setGeometry(QtCore.QRect(40, 50, 47, 13))
self.label_5.setObjectName("label_5")
self.label_6 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_6.setGeometry(QtCore.QRect(180, 50, 61, 13))
self.label_6.setObjectName("label_6")
self.label_7 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_7.setGeometry(QtCore.QRect(320, 49, 61, 16))
self.label_7.setObjectName("label_7")
self.label_8 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_8.setGeometry(QtCore.QRect(440, 49, 61, 16))
self.label_8.setObjectName("label_8")
self.label_9 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_9.setGeometry(QtCore.QRect(40, 70, 47, 13))
self.label_9.setObjectName("label_9")
self.label_10 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_10.setGeometry(QtCore.QRect(180, 70, 58, 13))
self.label_10.setObjectName("label_10")
self.label_11 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_11.setGeometry(QtCore.QRect(319, 68, 71, 16))
self.label_11.setObjectName("label_11")
self.label_12 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_12.setGeometry(QtCore.QRect(440, 69, 61, 16))
self.label_12.setObjectName("label_12")
self.label_13 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_13.setGeometry(QtCore.QRect(40, 90, 61, 16))
self.label_13.setObjectName("label_13")
self.label_14 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_14.setGeometry(QtCore.QRect(180, 90, 59, 13))
self.label_14.setObjectName("label_14")
self.label_15 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_15.setGeometry(QtCore.QRect(319, 88, 61, 16))
self.label_15.setObjectName("label_15")
self.label_16 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_16.setGeometry(QtCore.QRect(440, 89, 61, 16))
self.label_16.setObjectName("label_16")
self.label_17 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_17.setGeometry(QtCore.QRect(40, 110, 61, 16))
self.label_17.setObjectName("label_17")
self.label_18 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_18.setGeometry(QtCore.QRect(180, 110, 59, 13))
self.label_18.setObjectName("label_18")
self.label_19 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_19.setGeometry(QtCore.QRect(318, 109, 61, 16))
self.label_19.setObjectName("label_19")
self.label_20 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_20.setGeometry(QtCore.QRect(440, 109, 61, 16))
self.label_20.setObjectName("label_20")
self.pushButton = QtWidgets.QPushButton(self.scrollAreaWidgetContents)
self.pushButton.setGeometry(QtCore.QRect(490, 440, 75, 23))
self.pushButton.setObjectName("pushButton")
self.pushButton.clicked.connect(self.openWindow)
self.label_21 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_21.setGeometry(QtCore.QRect(40, 130, 101, 16))
self.label_21.setObjectName("label_21")
self.label_22 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_22.setGeometry(QtCore.QRect(179, 130, 47, 13))
self.label_22.setObjectName("label_22")
self.label_23 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_23.setGeometry(QtCore.QRect(320, 129, 51, 16))
self.label_23.setObjectName("label_23")
self.label_24 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_24.setGeometry(QtCore.QRect(441, 130, 47, 13))
self.label_24.setObjectName("label_24")
self.label_25 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_25.setGeometry(QtCore.QRect(40, 150, 71, 16))
self.label_25.setObjectName("label_25")
self.label_26 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_26.setGeometry(QtCore.QRect(180, 150, 47, 13))
self.label_26.setObjectName("label_26")
self.label_27 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_27.setGeometry(QtCore.QRect(320, 150, 47, 13))
self.label_27.setObjectName("label_27")
self.label_28 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_28.setGeometry(QtCore.QRect(440, 150, 47, 13))
self.label_28.setObjectName("label_28")
self.label.raise_()
self.label_2.raise_()
self.label_3.raise_()
self.label_4.raise_()
self.label_5.raise_()
self.label_6.raise_()
self.label_7.raise_()
self.label_8.raise_()
self.label_9.raise_()
self.label_10.raise_()
self.label_11.raise_()
self.label_12.raise_()
self.label_13.raise_()
self.label_14.raise_()
self.label_15.raise_()
self.label_16.raise_()
self.label_17.raise_()
self.label_18.raise_()
self.label_19.raise_()
self.label_20.raise_()
self.label_21.raise_()
self.label_22.raise_()
self.label_23.raise_()
self.label_24.raise_()
self.label_25.raise_()
self.label_26.raise_()
self.label_27.raise_()
self.label_28.raise_()
self.pushButton.raise_()
self.scrollArea.setWidget(self.scrollAreaWidgetContents)
self.gridLayout.addWidget(self.scrollArea, 0, 1, 1, 1)
self.tabWidget.addTab(self.widget, "")
self.tab_2 = QtWidgets.QWidget()
self.tab_2.setObjectName("tab_2")
self.checkBox = QtWidgets.QCheckBox(self.tab_2)
self.checkBox.setGeometry(QtCore.QRect(20, 40, 70, 17))
self.checkBox.setObjectName("checkBox")
self.label_29 = QtWidgets.QLabel(self.tab_2)
self.label_29.setGeometry(QtCore.QRect(30, 10, 81, 16))
font = QtGui.QFont()
font.setPointSize(10)
font.setBold(True)
font.setWeight(75)
self.label_29.setFont(font)
self.label_29.setObjectName("label_29")
self.checkBox_2 = QtWidgets.QCheckBox(self.tab_2)
self.checkBox_2.setGeometry(QtCore.QRect(20, 60, 70, 17))
self.checkBox_2.setObjectName("checkBox_2")
self.checkBox_3 = QtWidgets.QCheckBox(self.tab_2)
self.checkBox_3.setGeometry(QtCore.QRect(20, 80, 76, 17))
self.checkBox_3.setObjectName("checkBox_3")
self.checkBox_4 = QtWidgets.QCheckBox(self.tab_2)
self.checkBox_4.setGeometry(QtCore.QRect(20, 100, 78, 17))
self.checkBox_4.setObjectName("checkBox_4")
self.checkBox_5 = QtWidgets.QCheckBox(self.tab_2)
self.checkBox_5.setGeometry(QtCore.QRect(20, 120, 117, 17))
self.checkBox_5.setObjectName("checkBox_5")
self.checkBox_6 = QtWidgets.QCheckBox(self.tab_2)
self.checkBox_6.setGeometry(QtCore.QRect(20, 140, 85, 17))
self.checkBox_6.setObjectName("checkBox_6")
self.label_30 = QtWidgets.QLabel(self.tab_2)
self.label_30.setGeometry(QtCore.QRect(180, 10, 45, 13))
font = QtGui.QFont()
font.setPointSize(10)
font.setBold(True)
font.setWeight(75)
self.label_30.setFont(font)
self.label_30.setObjectName("label_30")
self.label_31 = QtWidgets.QLabel(self.tab_2)
self.label_31.setGeometry(QtCore.QRect(270, 6, 62, 19))
font = QtGui.QFont()
font.setPointSize(10)
font.setBold(True)
font.setWeight(75)
self.label_31.setFont(font)
self.label_31.setObjectName("label_31")
self.label_32 = QtWidgets.QLabel(self.tab_2)
self.label_32.setGeometry(QtCore.QRect(180, 40, 65, 13))
self.label_32.setObjectName("label_32")
self.label_33 = QtWidgets.QLabel(self.tab_2)
self.label_33.setGeometry(QtCore.QRect(180, 60, 63, 13))
self.label_33.setObjectName("label_33")
self.label_34 = QtWidgets.QLabel(self.tab_2)
self.label_34.setGeometry(QtCore.QRect(180, 80, 61, 13))
self.label_34.setObjectName("label_34")
self.label_35 = QtWidgets.QLabel(self.tab_2)
self.label_35.setGeometry(QtCore.QRect(180, 100, 63, 13))
self.label_35.setObjectName("label_35")
self.label_36 = QtWidgets.QLabel(self.tab_2)
self.label_36.setGeometry(QtCore.QRect(180, 120, 47, 13))
self.label_36.setObjectName("label_36")
self.label_37 = QtWidgets.QLabel(self.tab_2)
self.label_37.setGeometry(QtCore.QRect(180, 140, 47, 13))
self.label_37.setObjectName("label_37")
self.lineEdit = QtWidgets.QLineEdit(self.tab_2)
self.lineEdit.setGeometry(QtCore.QRect(260, 35, 91, 20))
self.lineEdit.setObjectName("lineEdit")
self.lineEdit_2 = QtWidgets.QLineEdit(self.tab_2)
self.lineEdit_2.setGeometry(QtCore.QRect(260, 57, 91, 20))
self.lineEdit_2.setObjectName("lineEdit_2")
self.lineEdit_3 = QtWidgets.QLineEdit(self.tab_2)
self.lineEdit_3.setGeometry(QtCore.QRect(260, 78, 91, 20))
self.lineEdit_3.setObjectName("lineEdit_3")
self.lineEdit_4 = QtWidgets.QLineEdit(self.tab_2)
self.lineEdit_4.setGeometry(QtCore.QRect(260, 99, 91, 20))
self.lineEdit_4.setObjectName("lineEdit_4")
self.lineEdit_5 = QtWidgets.QLineEdit(self.tab_2)
self.lineEdit_5.setGeometry(QtCore.QRect(260, 120, 91, 20))
self.lineEdit_5.setObjectName("lineEdit_5")
self.lineEdit_6 = QtWidgets.QLineEdit(self.tab_2)
self.lineEdit_6.setGeometry(QtCore.QRect(260, 141, 91, 20))
self.lineEdit_6.setObjectName("lineEdit_6")
self.pushButton_2 = QtWidgets.QPushButton(self.tab_2)
self.pushButton_2.setGeometry(QtCore.QRect(350, 470, 70, 23))
self.pushButton_2.setObjectName("pushButton_2")
self.pushButton_3 = QtWidgets.QPushButton(self.tab_2)
self.pushButton_3.setGeometry(QtCore.QRect(425, 470, 70, 23))
self.pushButton_3.setObjectName("pushButton_3")
self.label_38 = QtWidgets.QLabel(self.tab_2)
self.label_38.setGeometry(QtCore.QRect(520, 471, 16, 16))
self.label_38.setObjectName("label_38")
self.label_39 = QtWidgets.QLabel(self.tab_2)
self.label_39.setGeometry(QtCore.QRect(420, 10, 117, 19))
font = QtGui.QFont()
font.setPointSize(10)
font.setBold(True)
font.setWeight(75)
self.label_39.setFont(font)
self.label_39.setObjectName("label_39")
self.label_40 = QtWidgets.QLabel(self.tab_2)
self.label_40.setGeometry(QtCore.QRect(450, 38, 66, 13))
self.label_40.setObjectName("label_40")
self.label_41 = QtWidgets.QLabel(self.tab_2)
self.label_41.setGeometry(QtCore.QRect(450, 60, 66, 13))
self.label_41.setObjectName("label_41")
self.label_42 = QtWidgets.QLabel(self.tab_2)
self.label_42.setGeometry(QtCore.QRect(450, 81, 57, 13))
self.label_42.setObjectName("label_42")
self.label_43 = QtWidgets.QLabel(self.tab_2)
self.label_43.setGeometry(QtCore.QRect(450, 102, 55, 13))
self.label_43.setObjectName("label_43")
self.label_44 = QtWidgets.QLabel(self.tab_2)
self.label_44.setGeometry(QtCore.QRect(450, 124, 47, 15))
self.label_44.setObjectName("label_44")
self.label_45 = QtWidgets.QLabel(self.tab_2)
self.label_45.setGeometry(QtCore.QRect(450, 145, 47, 13))
self.label_45.setObjectName("label_45")
self.tabWidget.addTab(self.tab_2, "")
self.gridLayout_3.addWidget(self.tabWidget, 0, 0, 1, 1)
MainWindow.setCentralWidget(self.centralwidget)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
self.tabWidget.setCurrentIndex(0)
self.pushButton_2.clicked.connect(self.lineEdit.clear)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "Automated System Inventory"))
self.label.setText(_translate("MainWindow", "Item Name"))
self.label_2.setText(_translate("MainWindow", "Number of Stocks"))
self.label_3.setText(_translate("MainWindow", "mSRP"))
self.label_4.setText(_translate("MainWindow", "Sari-Sari Store Price"))
self.label_5.setText(_translate("MainWindow", "RC Small"))
self.label_6.setText(_translate("MainWindow", "120 (bottles)"))
self.label_7.setText(_translate("MainWindow", "8.00/bottle"))
self.label_8.setText(_translate("MainWindow", "10.00/bottle"))
self.label_9.setText(_translate("MainWindow", "RC Big"))
self.label_10.setText(_translate("MainWindow", "48 (bottles)"))
self.label_11.setText(_translate("MainWindow", "21.00/bottle"))
self.label_12.setText(_translate("MainWindow", "24.00/bottle"))
self.label_13.setText(_translate("MainWindow", "Coke (Litro)"))
self.label_14.setText(_translate("MainWindow", "48 (bottles)"))
self.label_15.setText(_translate("MainWindow", "22.00/bottle"))
self.label_16.setText(_translate("MainWindow", "26.00/bottle"))
self.label_17.setText(_translate("MainWindow", "C2 (230 mL)"))
self.label_18.setText(_translate("MainWindow", "48 (bottles)"))
self.label_19.setText(_translate("MainWindow", "10.00/bottle"))
self.label_20.setText(_translate("MainWindow", "12.00/bottle"))
self.pushButton.setText(_translate("MainWindow", "Edit"))
self.label_21.setText(_translate("MainWindow", "555 Tuna(Afritada)"))
self.label_22.setText(_translate("MainWindow", "10 (cans)"))
self.label_23.setText(_translate("MainWindow", "18.00/pc"))
self.label_24.setText(_translate("MainWindow", "22.00/pc"))
self.label_25.setText(_translate("MainWindow", "Cup Noodles"))
self.label_26.setText(_translate("MainWindow", "10 (pcs)"))
self.label_27.setText(_translate("MainWindow", "18.00/pc"))
self.label_28.setText(_translate("MainWindow", "24.00/pc"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.widget), _translate("MainWindow", "Stocks and Price"))
self.checkBox.setText(_translate("MainWindow", "RC Small"))
self.label_29.setText(_translate("MainWindow", "Item Name"))
self.checkBox_2.setText(_translate("MainWindow", "RC Big"))
self.checkBox_3.setText(_translate("MainWindow", "Coke (Litro)"))
self.checkBox_4.setText(_translate("MainWindow", "C2 (230 mL)"))
self.checkBox_5.setText(_translate("MainWindow", "555 Tuna (Afritada)"))
self.checkBox_6.setText(_translate("MainWindow", "Cup Noodles"))
self.label_30.setText(_translate("MainWindow", "Price"))
self.label_31.setText(_translate("MainWindow", "Quantity"))
self.label_32.setText(_translate("MainWindow", "10.00"))
self.label_33.setText(_translate("MainWindow", "24.00"))
self.label_34.setText(_translate("MainWindow", "26.00"))
self.label_35.setText(_translate("MainWindow", "12.00"))
self.label_36.setText(_translate("MainWindow", "22.00"))
self.label_37.setText(_translate("MainWindow", "24.00"))
self.pushButton_2.setText(_translate("MainWindow", "Reset"))
self.pushButton_3.setText(_translate("MainWindow", "Total"))
self.label_38.setText(_translate("MainWindow", "0"))
self.label_39.setText(_translate("MainWindow", "Remaining Stocks"))
self.label_40.setText(_translate("MainWindow", "120 (bottles)"))
self.label_41.setText(_translate("MainWindow", "48(bottles)"))
self.label_42.setText(_translate("MainWindow", "48(bottles)"))
self.label_43.setText(_translate("MainWindow", "48(bottles)"))
self.label_44.setText(_translate("MainWindow", "10 (pc)"))
self.label_45.setText(_translate("MainWindow", "10 (pc)"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2), _translate("MainWindow", "Sales"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
Here is the code for the edit Window, derived from Qt Designer:
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_editWindow(object):
def setupUi(self, editWindow):
editWindow.setObjectName("editWindow")
editWindow.setEnabled(True)
editWindow.resize(627, 319)
editWindow.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu)
self.centralwidget = QtWidgets.QWidget(editWindow)
self.centralwidget.setObjectName("centralwidget")
self.label = QtWidgets.QLabel(self.centralwidget)
self.label.setGeometry(QtCore.QRect(300, 20, 71, 31))
font = QtGui.QFont()
font.setPointSize(10)
font.setBold(True)
font.setWeight(75)
self.label.setFont(font)
self.label.setObjectName("label")
self.label_2 = QtWidgets.QLabel(self.centralwidget)
self.label_2.setGeometry(QtCore.QRect(10, 63, 47, 13))
self.label_2.setText("")
self.label_2.setObjectName("label_2")
self.splitter_2 = QtWidgets.QSplitter(self.centralwidget)
self.splitter_2.setGeometry(QtCore.QRect(70, 60, 532, 20))
self.splitter_2.setOrientation(QtCore.Qt.Horizontal)
self.splitter_2.setObjectName("splitter_2")
self.lineEdit = QtWidgets.QLineEdit(self.splitter_2)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.lineEdit.sizePolicy().hasHeightForWidth())
self.lineEdit.setSizePolicy(sizePolicy)
self.lineEdit.setObjectName("lineEdit")
self.lineEdit_2 = QtWidgets.QLineEdit(self.splitter_2)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.lineEdit_2.sizePolicy().hasHeightForWidth())
self.lineEdit_2.setSizePolicy(sizePolicy)
self.lineEdit_2.setObjectName("lineEdit_2")
self.lineEdit_3 = QtWidgets.QLineEdit(self.splitter_2)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.lineEdit_3.sizePolicy().hasHeightForWidth())
self.lineEdit_3.setSizePolicy(sizePolicy)
self.lineEdit_3.setObjectName("lineEdit_3")
self.lineEdit_4 = QtWidgets.QLineEdit(self.splitter_2)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.lineEdit_4.sizePolicy().hasHeightForWidth())
self.lineEdit_4.setSizePolicy(sizePolicy)
self.lineEdit_4.setStyleSheet("")
self.lineEdit_4.setObjectName("lineEdit_4")
self.splitter = QtWidgets.QSplitter(self.centralwidget)
self.splitter.setGeometry(QtCore.QRect(360, 270, 225, 23))
self.splitter.setOrientation(QtCore.Qt.Horizontal)
self.splitter.setObjectName("splitter")
self.pushButton_3 = QtWidgets.QPushButton(self.splitter)
self.pushButton_3.setObjectName("pushButton_3")
self.pushButton_2 = QtWidgets.QPushButton(self.splitter)
self.pushButton_2.setObjectName("pushButton_2")
self.pushButton = QtWidgets.QPushButton(self.splitter)
self.pushButton.setObjectName("pushButton")
editWindow.setCentralWidget(self.centralwidget)
self.statusbar = QtWidgets.QStatusBar(editWindow)
self.statusbar.setObjectName("statusbar")
editWindow.setStatusBar(self.statusbar)
self.retranslateUi(editWindow)
self.pushButton.clicked.connect(self.label_2.clear)
self.pushButton.clicked.connect(self.lineEdit.clear)
self.pushButton.clicked.connect(self.lineEdit_2.clear)
self.pushButton.clicked.connect(self.lineEdit_3.clear)
self.pushButton.clicked.connect(self.lineEdit_4.clear)
QtCore.QMetaObject.connectSlotsByName(editWindow)
def retranslateUi(self, editWindow):
_translate = QtCore.QCoreApplication.translate
editWindow.setWindowTitle(_translate("editWindow", "MainWindow"))
self.label.setText(_translate("editWindow", "EDIT FORM"))
self.lineEdit.setPlaceholderText(_translate("editWindow", "Item Name"))
self.lineEdit_2.setPlaceholderText(_translate("editWindow", "Number of Stocks"))
self.lineEdit_3.setPlaceholderText(_translate("editWindow", "mSRP"))
self.lineEdit_4.setPlaceholderText(_translate("editWindow", "Sari-Sari Store Price"))
self.pushButton_3.setText(_translate("editWindow", "Add Item"))
self.pushButton_2.setText(_translate("editWindow", "Update"))
self.pushButton.setText(_translate("editWindow", "Clear"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
editWindow = QtWidgets.QMainWindow()
ui = Ui_editWindow()
ui.setupUi(editWindow)
editWindow.show()
sys.exit(app.exec_())

Try it:
from PyQt5 import QtCore, QtGui, QtWidgets
from FinalEditForm import Ui_editWindow
class Ui_MainWindow(object):
# def openWindow(self):
# self.window = QtWidgets.QMainWindow()
# self.ui = Ui_editWindow()
# self.ui.setupUi(self.window)
# self.window.show()
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(634, 578)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.gridLayout_3 = QtWidgets.QGridLayout(self.centralwidget)
self.gridLayout_3.setContentsMargins(10, 10, 10, 10)
self.gridLayout_3.setObjectName("gridLayout_3")
self.tabWidget = QtWidgets.QTabWidget(self.centralwidget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.tabWidget.sizePolicy().hasHeightForWidth())
self.tabWidget.setSizePolicy(sizePolicy)
self.tabWidget.setObjectName("tabWidget")
self.widget = QtWidgets.QWidget()
self.widget.setObjectName("widget")
self.gridLayout = QtWidgets.QGridLayout(self.widget)
self.gridLayout.setContentsMargins(0, 0, 0, 0)
self.gridLayout.setObjectName("gridLayout")
self.scrollArea = QtWidgets.QScrollArea(self.widget)
self.scrollArea.setWidgetResizable(True)
self.scrollArea.setObjectName("scrollArea")
self.scrollAreaWidgetContents = QtWidgets.QWidget()
self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 588, 492))
self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents")
self.label = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label.setGeometry(QtCore.QRect(38, 20, 81, 21))
font = QtGui.QFont()
font.setPointSize(10)
font.setBold(True)
font.setWeight(75)
self.label.setFont(font)
self.label.setObjectName("label")
self.label_2 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_2.setGeometry(QtCore.QRect(160, 20, 121, 21))
font = QtGui.QFont()
font.setPointSize(10)
font.setBold(True)
font.setWeight(75)
self.label_2.setFont(font)
self.label_2.setObjectName("label_2")
self.label_3 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_3.setGeometry(QtCore.QRect(317, 20, 61, 21))
font = QtGui.QFont()
font.setPointSize(10)
font.setBold(True)
font.setWeight(75)
self.label_3.setFont(font)
self.label_3.setObjectName("label_3")
self.label_4 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_4.setGeometry(QtCore.QRect(400, 20, 141, 21))
font = QtGui.QFont()
font.setPointSize(10)
font.setBold(True)
font.setWeight(75)
self.label_4.setFont(font)
self.label_4.setObjectName("label_4")
self.label_5 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_5.setGeometry(QtCore.QRect(40, 50, 47, 13))
self.label_5.setObjectName("label_5")
self.label_6 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_6.setGeometry(QtCore.QRect(180, 50, 61, 13))
self.label_6.setObjectName("label_6")
self.label_7 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_7.setGeometry(QtCore.QRect(320, 49, 61, 16))
self.label_7.setObjectName("label_7")
self.label_8 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_8.setGeometry(QtCore.QRect(440, 49, 61, 16))
self.label_8.setObjectName("label_8")
self.label_9 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_9.setGeometry(QtCore.QRect(40, 70, 47, 13))
self.label_9.setObjectName("label_9")
self.label_10 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_10.setGeometry(QtCore.QRect(180, 70, 58, 13))
self.label_10.setObjectName("label_10")
self.label_11 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_11.setGeometry(QtCore.QRect(319, 68, 71, 16))
self.label_11.setObjectName("label_11")
self.label_12 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_12.setGeometry(QtCore.QRect(440, 69, 61, 16))
self.label_12.setObjectName("label_12")
self.label_13 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_13.setGeometry(QtCore.QRect(40, 90, 61, 16))
self.label_13.setObjectName("label_13")
self.label_14 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_14.setGeometry(QtCore.QRect(180, 90, 59, 13))
self.label_14.setObjectName("label_14")
self.label_15 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_15.setGeometry(QtCore.QRect(319, 88, 61, 16))
self.label_15.setObjectName("label_15")
self.label_16 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_16.setGeometry(QtCore.QRect(440, 89, 61, 16))
self.label_16.setObjectName("label_16")
self.label_17 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_17.setGeometry(QtCore.QRect(40, 110, 61, 16))
self.label_17.setObjectName("label_17")
self.label_18 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_18.setGeometry(QtCore.QRect(180, 110, 59, 13))
self.label_18.setObjectName("label_18")
self.label_19 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_19.setGeometry(QtCore.QRect(318, 109, 61, 16))
self.label_19.setObjectName("label_19")
self.label_20 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_20.setGeometry(QtCore.QRect(440, 109, 61, 16))
self.label_20.setObjectName("label_20")
self.pushButton = QtWidgets.QPushButton(self.scrollAreaWidgetContents)
self.pushButton.setGeometry(QtCore.QRect(490, 440, 75, 23))
self.pushButton.setObjectName("pushButton")
# self.pushButton.clicked.connect(self.openWindow)
self.label_21 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_21.setGeometry(QtCore.QRect(40, 130, 101, 16))
self.label_21.setObjectName("label_21")
self.label_22 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_22.setGeometry(QtCore.QRect(179, 130, 47, 13))
self.label_22.setObjectName("label_22")
self.label_23 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_23.setGeometry(QtCore.QRect(320, 129, 51, 16))
self.label_23.setObjectName("label_23")
self.label_24 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_24.setGeometry(QtCore.QRect(441, 130, 47, 13))
self.label_24.setObjectName("label_24")
self.label_25 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_25.setGeometry(QtCore.QRect(40, 150, 71, 16))
self.label_25.setObjectName("label_25")
self.label_26 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_26.setGeometry(QtCore.QRect(180, 150, 47, 13))
self.label_26.setObjectName("label_26")
self.label_27 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_27.setGeometry(QtCore.QRect(320, 150, 47, 13))
self.label_27.setObjectName("label_27")
self.label_28 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
self.label_28.setGeometry(QtCore.QRect(440, 150, 47, 13))
self.label_28.setObjectName("label_28")
self.label.raise_()
self.label_2.raise_()
self.label_3.raise_()
self.label_4.raise_()
self.label_5.raise_()
self.label_6.raise_()
self.label_7.raise_()
self.label_8.raise_()
self.label_9.raise_()
self.label_10.raise_()
self.label_11.raise_()
self.label_12.raise_()
self.label_13.raise_()
self.label_14.raise_()
self.label_15.raise_()
self.label_16.raise_()
self.label_17.raise_()
self.label_18.raise_()
self.label_19.raise_()
self.label_20.raise_()
self.label_21.raise_()
self.label_22.raise_()
self.label_23.raise_()
self.label_24.raise_()
self.label_25.raise_()
self.label_26.raise_()
self.label_27.raise_()
self.label_28.raise_()
self.pushButton.raise_()
self.scrollArea.setWidget(self.scrollAreaWidgetContents)
self.gridLayout.addWidget(self.scrollArea, 0, 1, 1, 1)
self.tabWidget.addTab(self.widget, "")
self.tab_2 = QtWidgets.QWidget()
self.tab_2.setObjectName("tab_2")
self.checkBox = QtWidgets.QCheckBox(self.tab_2)
self.checkBox.setGeometry(QtCore.QRect(20, 40, 70, 17))
self.checkBox.setObjectName("checkBox")
self.label_29 = QtWidgets.QLabel(self.tab_2)
self.label_29.setGeometry(QtCore.QRect(30, 10, 81, 16))
font = QtGui.QFont()
font.setPointSize(10)
font.setBold(True)
font.setWeight(75)
self.label_29.setFont(font)
self.label_29.setObjectName("label_29")
self.checkBox_2 = QtWidgets.QCheckBox(self.tab_2)
self.checkBox_2.setGeometry(QtCore.QRect(20, 60, 70, 17))
self.checkBox_2.setObjectName("checkBox_2")
self.checkBox_3 = QtWidgets.QCheckBox(self.tab_2)
self.checkBox_3.setGeometry(QtCore.QRect(20, 80, 76, 17))
self.checkBox_3.setObjectName("checkBox_3")
self.checkBox_4 = QtWidgets.QCheckBox(self.tab_2)
self.checkBox_4.setGeometry(QtCore.QRect(20, 100, 78, 17))
self.checkBox_4.setObjectName("checkBox_4")
self.checkBox_5 = QtWidgets.QCheckBox(self.tab_2)
self.checkBox_5.setGeometry(QtCore.QRect(20, 120, 117, 17))
self.checkBox_5.setObjectName("checkBox_5")
self.checkBox_6 = QtWidgets.QCheckBox(self.tab_2)
self.checkBox_6.setGeometry(QtCore.QRect(20, 140, 85, 17))
self.checkBox_6.setObjectName("checkBox_6")
self.label_30 = QtWidgets.QLabel(self.tab_2)
self.label_30.setGeometry(QtCore.QRect(180, 10, 45, 13))
font = QtGui.QFont()
font.setPointSize(10)
font.setBold(True)
font.setWeight(75)
self.label_30.setFont(font)
self.label_30.setObjectName("label_30")
self.label_31 = QtWidgets.QLabel(self.tab_2)
self.label_31.setGeometry(QtCore.QRect(270, 6, 62, 19))
font = QtGui.QFont()
font.setPointSize(10)
font.setBold(True)
font.setWeight(75)
self.label_31.setFont(font)
self.label_31.setObjectName("label_31")
self.label_32 = QtWidgets.QLabel(self.tab_2)
self.label_32.setGeometry(QtCore.QRect(180, 40, 65, 13))
self.label_32.setObjectName("label_32")
self.label_33 = QtWidgets.QLabel(self.tab_2)
self.label_33.setGeometry(QtCore.QRect(180, 60, 63, 13))
self.label_33.setObjectName("label_33")
self.label_34 = QtWidgets.QLabel(self.tab_2)
self.label_34.setGeometry(QtCore.QRect(180, 80, 61, 13))
self.label_34.setObjectName("label_34")
self.label_35 = QtWidgets.QLabel(self.tab_2)
self.label_35.setGeometry(QtCore.QRect(180, 100, 63, 13))
self.label_35.setObjectName("label_35")
self.label_36 = QtWidgets.QLabel(self.tab_2)
self.label_36.setGeometry(QtCore.QRect(180, 120, 47, 13))
self.label_36.setObjectName("label_36")
self.label_37 = QtWidgets.QLabel(self.tab_2)
self.label_37.setGeometry(QtCore.QRect(180, 140, 47, 13))
self.label_37.setObjectName("label_37")
self.lineEdit = QtWidgets.QLineEdit(self.tab_2)
self.lineEdit.setGeometry(QtCore.QRect(260, 35, 91, 20))
self.lineEdit.setObjectName("lineEdit")
self.lineEdit_2 = QtWidgets.QLineEdit(self.tab_2)
self.lineEdit_2.setGeometry(QtCore.QRect(260, 57, 91, 20))
self.lineEdit_2.setObjectName("lineEdit_2")
self.lineEdit_3 = QtWidgets.QLineEdit(self.tab_2)
self.lineEdit_3.setGeometry(QtCore.QRect(260, 78, 91, 20))
self.lineEdit_3.setObjectName("lineEdit_3")
self.lineEdit_4 = QtWidgets.QLineEdit(self.tab_2)
self.lineEdit_4.setGeometry(QtCore.QRect(260, 99, 91, 20))
self.lineEdit_4.setObjectName("lineEdit_4")
self.lineEdit_5 = QtWidgets.QLineEdit(self.tab_2)
self.lineEdit_5.setGeometry(QtCore.QRect(260, 120, 91, 20))
self.lineEdit_5.setObjectName("lineEdit_5")
self.lineEdit_6 = QtWidgets.QLineEdit(self.tab_2)
self.lineEdit_6.setGeometry(QtCore.QRect(260, 141, 91, 20))
self.lineEdit_6.setObjectName("lineEdit_6")
self.pushButton_2 = QtWidgets.QPushButton(self.tab_2)
self.pushButton_2.setGeometry(QtCore.QRect(350, 470, 70, 23))
self.pushButton_2.setObjectName("pushButton_2")
self.pushButton_3 = QtWidgets.QPushButton(self.tab_2)
self.pushButton_3.setGeometry(QtCore.QRect(425, 470, 70, 23))
self.pushButton_3.setObjectName("pushButton_3")
self.label_38 = QtWidgets.QLabel(self.tab_2)
self.label_38.setGeometry(QtCore.QRect(520, 471, 16, 16))
self.label_38.setObjectName("label_38")
self.label_39 = QtWidgets.QLabel(self.tab_2)
self.label_39.setGeometry(QtCore.QRect(420, 10, 117, 19))
font = QtGui.QFont()
font.setPointSize(10)
font.setBold(True)
font.setWeight(75)
self.label_39.setFont(font)
self.label_39.setObjectName("label_39")
self.label_40 = QtWidgets.QLabel(self.tab_2)
self.label_40.setGeometry(QtCore.QRect(450, 38, 66, 13))
self.label_40.setObjectName("label_40")
self.label_41 = QtWidgets.QLabel(self.tab_2)
self.label_41.setGeometry(QtCore.QRect(450, 60, 66, 13))
self.label_41.setObjectName("label_41")
self.label_42 = QtWidgets.QLabel(self.tab_2)
self.label_42.setGeometry(QtCore.QRect(450, 81, 57, 13))
self.label_42.setObjectName("label_42")
self.label_43 = QtWidgets.QLabel(self.tab_2)
self.label_43.setGeometry(QtCore.QRect(450, 102, 55, 13))
self.label_43.setObjectName("label_43")
self.label_44 = QtWidgets.QLabel(self.tab_2)
self.label_44.setGeometry(QtCore.QRect(450, 124, 47, 15))
self.label_44.setObjectName("label_44")
self.label_45 = QtWidgets.QLabel(self.tab_2)
self.label_45.setGeometry(QtCore.QRect(450, 145, 47, 13))
self.label_45.setObjectName("label_45")
self.tabWidget.addTab(self.tab_2, "")
self.gridLayout_3.addWidget(self.tabWidget, 0, 0, 1, 1)
MainWindow.setCentralWidget(self.centralwidget)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
self.tabWidget.setCurrentIndex(0)
self.pushButton_2.clicked.connect(self.lineEdit.clear)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "Automated System Inventory"))
self.label.setText(_translate("MainWindow", "Item Name"))
self.label_2.setText(_translate("MainWindow", "Number of Stocks"))
self.label_3.setText(_translate("MainWindow", "mSRP"))
self.label_4.setText(_translate("MainWindow", "Sari-Sari Store Price"))
self.label_5.setText(_translate("MainWindow", "RC Small"))
self.label_6.setText(_translate("MainWindow", "120 (bottles)"))
self.label_7.setText(_translate("MainWindow", "8.00/bottle"))
self.label_8.setText(_translate("MainWindow", "10.00/bottle"))
self.label_9.setText(_translate("MainWindow", "RC Big"))
self.label_10.setText(_translate("MainWindow", "48 (bottles)"))
self.label_11.setText(_translate("MainWindow", "21.00/bottle"))
self.label_12.setText(_translate("MainWindow", "24.00/bottle"))
self.label_13.setText(_translate("MainWindow", "Coke (Litro)"))
self.label_14.setText(_translate("MainWindow", "48 (bottles)"))
self.label_15.setText(_translate("MainWindow", "22.00/bottle"))
self.label_16.setText(_translate("MainWindow", "26.00/bottle"))
self.label_17.setText(_translate("MainWindow", "C2 (230 mL)"))
self.label_18.setText(_translate("MainWindow", "48 (bottles)"))
self.label_19.setText(_translate("MainWindow", "10.00/bottle"))
self.label_20.setText(_translate("MainWindow", "12.00/bottle"))
self.pushButton.setText(_translate("MainWindow", "Edit"))
self.label_21.setText(_translate("MainWindow", "555 Tuna(Afritada)"))
self.label_22.setText(_translate("MainWindow", "10 (cans)"))
self.label_23.setText(_translate("MainWindow", "18.00/pc"))
self.label_24.setText(_translate("MainWindow", "22.00/pc"))
self.label_25.setText(_translate("MainWindow", "Cup Noodles"))
self.label_26.setText(_translate("MainWindow", "10 (pcs)"))
self.label_27.setText(_translate("MainWindow", "18.00/pc"))
self.label_28.setText(_translate("MainWindow", "24.00/pc"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.widget), _translate("MainWindow", "Stocks and Price"))
self.checkBox.setText(_translate("MainWindow", "RC Small"))
self.label_29.setText(_translate("MainWindow", "Item Name"))
self.checkBox_2.setText(_translate("MainWindow", "RC Big"))
self.checkBox_3.setText(_translate("MainWindow", "Coke (Litro)"))
self.checkBox_4.setText(_translate("MainWindow", "C2 (230 mL)"))
self.checkBox_5.setText(_translate("MainWindow", "555 Tuna (Afritada)"))
self.checkBox_6.setText(_translate("MainWindow", "Cup Noodles"))
self.label_30.setText(_translate("MainWindow", "Price"))
self.label_31.setText(_translate("MainWindow", "Quantity"))
self.label_32.setText(_translate("MainWindow", "10.00"))
self.label_33.setText(_translate("MainWindow", "24.00"))
self.label_34.setText(_translate("MainWindow", "26.00"))
self.label_35.setText(_translate("MainWindow", "12.00"))
self.label_36.setText(_translate("MainWindow", "22.00"))
self.label_37.setText(_translate("MainWindow", "24.00"))
self.pushButton_2.setText(_translate("MainWindow", "Reset"))
self.pushButton_3.setText(_translate("MainWindow", "Total"))
self.label_38.setText(_translate("MainWindow", "0"))
self.label_39.setText(_translate("MainWindow", "Remaining Stocks"))
self.label_40.setText(_translate("MainWindow", "120 (bottles)"))
self.label_41.setText(_translate("MainWindow", "48(bottles)"))
self.label_42.setText(_translate("MainWindow", "48(bottles)"))
self.label_43.setText(_translate("MainWindow", "48(bottles)"))
self.label_44.setText(_translate("MainWindow", "10 (pc)"))
self.label_45.setText(_translate("MainWindow", "10 (pc)"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2), _translate("MainWindow", "Sales"))
class MyWindow(QtWidgets.QMainWindow, Ui_MainWindow): # ++++
def __init__(self):
super().__init__()
self.setupUi(self)
self.pushButton.clicked.connect(self.openWindow)
def openWindow(self):
self.window = QtWidgets.QMainWindow()
self.ui = Ui_editWindow()
self.ui.setupUi(self.window)
self.window.show()
# +++ vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
self.ui.lineEdit.textEdited['QString'].connect(self.label_5.setText)
self.ui.lineEdit_2.textEdited['QString'].connect(self.label_6.setText)
self.ui.lineEdit_3.textEdited['QString'].connect(self.label_7.setText)
self.ui.lineEdit_4.textEdited['QString'].connect(self.label_8.setText)
self.ui.lineEdit.setText(self.label_5.text())
self.ui.lineEdit_2.setText(self.label_6.text())
self.ui.lineEdit_3.setText(self.label_7.text())
self.ui.lineEdit_4.setText(self.label_8.text())
# +++ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
self.ui.pushButton_2.clicked.connect(self.updateWindow)
def updateWindow(self):
self.label_5.setText(self.ui.lineEdit.text())
# ...
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = MyWindow()
MainWindow.show()
sys.exit(app.exec_())

Related

issue with QScrollArea

I am trying to add some check boxes in scroll area.but for me it is not working properly.i am new in python could anyone help?
import PyQt5
from PyQt5 import QtCore, QtGui, QtWidgets
from configparser import ConfigParser
import paramiko
import threading
import os
if hasattr(QtCore.Qt, 'AA_EnableHighDpiScaling'):
PyQt5.QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True)
if hasattr(QtCore.Qt, 'AA_UseHighDpiPixmaps'):
PyQt5.QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps, True)
class Ui_MainWindow(object):
def __init__(self, parent=None):
self.configur = ConfigParser()
self.configur.read('ServerConfigurationDetails.ini')
self.serverName=self.configur.sections()
print(self.serverName)
self.getComponents = self.configur.options("Component")
self.sLen = len(self.serverName)
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.setEnabled(True)
MainWindow.resize(951, 634)
font = QtGui.QFont()
font.setPointSize(10)
MainWindow.setFont(font)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.label_2 = QtWidgets.QLabel(self.centralwidget)
self.label_2.setGeometry(QtCore.QRect(150, 220, 91, 31))
font = QtGui.QFont()
font.setPointSize(14)
self.label_2.setFont(font)
self.label_2.setObjectName("label_2")
self.comboBox_2 = QtWidgets.QComboBox(self.centralwidget)
self.comboBox_2.setGeometry(QtCore.QRect(250, 220, 231, 31))
self.comboBox_2.setObjectName("comboBox_2")
self.comboBox_2.addItem("")
self.comboBox_2.addItem("")
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(700, 40, 101, 31))
self.pushButton.setObjectName("pushButton")
self.groupBox = QtWidgets.QGroupBox(self.centralwidget)
self.groupBox.setGeometry(QtCore.QRect(140, 260, 681, 81))
self.groupBox.setObjectName("groupBox")
self.radioButton = QtWidgets.QRadioButton(self.groupBox)
self.radioButton.setGeometry(QtCore.QRect(10, 30, 201, 20))
self.radioButton.setObjectName("radioButton")
self.radioButton_2 = QtWidgets.QRadioButton(self.groupBox)
self.radioButton_2.setGeometry(QtCore.QRect(220, 30, 201, 20))
self.radioButton_2.setObjectName("radioButton_2")
self.checkBox = QtWidgets.QCheckBox(self.groupBox)
self.checkBox.setEnabled(False)
self.checkBox.setGeometry(QtCore.QRect(10, 50, 231, 31))
self.checkBox.setChecked(True)
self.checkBox.setObjectName("checkBox")
self.radioButton_3 = QtWidgets.QRadioButton(self.groupBox)
self.radioButton_3.setGeometry(QtCore.QRect(420, 30, 171, 20))
self.radioButton_3.setObjectName("radioButton_3")
self.lineEdit = QtWidgets.QLineEdit(self.centralwidget)
self.lineEdit.setGeometry(QtCore.QRect(280, 40, 411, 31))
self.lineEdit.setObjectName("lineEdit")
self.label_3 = QtWidgets.QLabel(self.centralwidget)
self.label_3.setGeometry(QtCore.QRect(130, 40, 131, 31))
self.label_3.setObjectName("label_3")
self.label_5 = QtWidgets.QLabel(self.centralwidget)
self.label_5.setGeometry(QtCore.QRect(140, 125, 661, 21))
self.label_5.setText("")
self.label_5.setObjectName("label_5")
self.scrollArea = QtWidgets.QScrollArea(self.centralwidget)
self.scrollArea.setGeometry(QtCore.QRect(130, 110, 681, 101))
self.scrollArea.setAccessibleDescription("")
self.scrollArea.setWidgetResizable(False)
self.scrollArea.setObjectName("scrollArea")
self.scrollAreaWidgetContents = QtWidgets.QWidget()
self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 679, 99))
self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents")
c=10
n=0
x = 10
y = 10
print(self.sLen)
for i in range(self.sLen):
if(n==4):
n=0
x=10
y=y+20
self.checkbox1 = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
self.checkbox1.setGeometry(QtCore.QRect(x+1, y+1, 161, 20))
self.checkbox1.setText(self.serverName[i])
self.checkbox1.setObjectName(self.serverName[i])
print(x)
print(n)
n=n+1
if(n==4):
x=10
y = y+20
else:
x= x+180
## self.checkBox_2 = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
## self.checkBox_2.setGeometry(QtCore.QRect(10, 10, 161, 20))
## self.checkBox_2.setObjectName("checkBox_2")
## self.checkBox_3 = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
## self.checkBox_3.setGeometry(QtCore.QRect(180, 10, 131, 20))
## self.checkBox_3.setObjectName("checkBox_3")
## self.checkBox_4 = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
## self.checkBox_4.setGeometry(QtCore.QRect(350, 10, 151, 20))
## self.checkBox_4.setObjectName("checkBox_4")
## self.checkBox_5 = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
## self.checkBox_5.setGeometry(QtCore.QRect(530, 10, 141, 20))
## self.checkBox_5.setObjectName("checkBox_5")
## self.checkBox_6 = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
## self.checkBox_6.setGeometry(QtCore.QRect(10, 30, 161, 20))
## self.checkBox_6.setObjectName("checkBox_6")
self.scrollArea.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
self.scrollArea.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.scrollArea.setWidget(self.scrollAreaWidgetContents)
self.scrollArea_2 = QtWidgets.QScrollArea(self.centralwidget)
self.scrollArea_2.setGeometry(QtCore.QRect(140, 380, 681, 191))
self.scrollArea_2.setWidgetResizable(True)
self.scrollArea_2.setObjectName("scrollArea_2")
self.scrollAreaWidgetContents_2 = QtWidgets.QWidget()
self.scrollAreaWidgetContents_2.setGeometry(QtCore.QRect(0, 0, 679, 189))
self.scrollAreaWidgetContents_2.setObjectName("scrollAreaWidgetContents_2")
self.scrollArea_2.setWidget(self.scrollAreaWidgetContents_2)
self.line = QtWidgets.QFrame(self.centralwidget)
self.line.setGeometry(QtCore.QRect(70, 340, 811, 20))
self.line.setFrameShape(QtWidgets.QFrame.HLine)
self.line.setFrameShadow(QtWidgets.QFrame.Sunken)
self.line.setObjectName("line")
MainWindow.setCentralWidget(self.centralwidget)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 951, 26))
self.menubar.setObjectName("menubar")
self.menuhelp = QtWidgets.QMenu(self.menubar)
self.menuhelp.setObjectName("menuhelp")
MainWindow.setMenuBar(self.menubar)
self.actionAbout = QtWidgets.QAction(MainWindow)
self.actionAbout.setObjectName("actionAbout")
self.menuhelp.addAction(self.actionAbout)
self.menubar.addAction(self.menuhelp.menuAction())
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.label_2.setText(_translate("MainWindow", "<html><head/><body><p><span style=\" font-size:10pt;\">Component</span></p></body></html>"))
self.comboBox_2.setItemText(0, _translate("MainWindow", "eComm"))
self.comboBox_2.setItemText(1, _translate("MainWindow", "workproc"))
self.pushButton.setText(_translate("MainWindow", "Search"))
self.groupBox.setTitle(_translate("MainWindow", "Other Details"))
self.radioButton.setText(_translate("MainWindow", "Only Search in Archive"))
self.radioButton_2.setText(_translate("MainWindow", "Also Search in Archive"))
self.checkBox.setText(_translate("MainWindow", "Auto Download"))
self.radioButton_3.setText(_translate("MainWindow", "Only Search in Log"))
self.label_3.setText(_translate("MainWindow", "<html><head/><body><p>Search String<span style=\" color:#ff0000;\">*</span></p></body></html>"))
## self.checkBox_2.setText(_translate("MainWindow", "CheckBox"))
## self.checkBox_3.setText(_translate("MainWindow", "CheckBox"))
## self.checkBox_4.setText(_translate("MainWindow", "CheckBox"))
## self.checkBox_5.setText(_translate("MainWindow", "CheckBox"))
## self.checkBox_6.setText(_translate("MainWindow", "CheckBox"))
self.menuhelp.setTitle(_translate("MainWindow", "Help"))
self.actionAbout.setText(_translate("MainWindow", "About"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
as you can see the scroll area is not showing properly.i have some 20 servers to show.this server list is coming from ini file and i need to show the check boxes in that scroll area.
you need to use QLayout to arrange you widgets. check out
Qt Designer -> "Widget Box" docker -> "Layouts" section
For the scrollarea part:
create scrollarea scroll_area = QScrollArea()
create view widget you want to put inside scrollarea base_widget = QWidget()
install view layout for view widget base_layout = QVBoxLayout(base_widget)
install view widget into scrollarea scroll_area.setWidget(base_widget)
fill in objects with view layout base_layout.addWidget(QLabel('foo')) base_layout.addWidget(QPushButton('bar')) base_layout.addLayout(my_sub_layout) etc.

Implementing Timer to blink Q Push Buttons

Im trying to get some push buttons to blink from a QtDesigner file, but im having trouble using the timer function to change the background of the button.
I was already helped by someone here and their code works great, but I cant seem to integrate the code to what I already have.
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(QtWidgets.QMainWindow):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(1309, 813)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.label = QtWidgets.QLabel(self.centralwidget)
self.label.setGeometry(QtCore.QRect(50, 30, 251, 41))
font = QtGui.QFont()
font.setPointSize(36)
self.label.setFont(font)
self.label.setObjectName("label")
self.voltage_percent = QtWidgets.QLCDNumber(self.centralwidget)
self.voltage_percent.setGeometry(QtCore.QRect(80, 170, 141, 91))
self.voltage_percent.setSmallDecimalPoint(True)
self.voltage_percent.setDigitCount(1)
self.voltage_percent.setProperty("intValue", 5)
self.voltage_percent.setObjectName("voltage_percent")
self.label_2 = QtWidgets.QLabel(self.centralwidget)
self.label_2.setGeometry(QtCore.QRect(1070, 30, 111, 51))
font = QtGui.QFont()
font.setPointSize(36)
self.label_2.setFont(font)
self.label_2.setObjectName("label_2")
self.modeTable = QtWidgets.QTableView(self.centralwidget)
self.modeTable.setGeometry(QtCore.QRect(970, 90, 321, 411))
self.modeTable.setObjectName("modeTable")
self.label_12 = QtWidgets.QLabel(self.centralwidget)
self.label_12.setGeometry(QtCore.QRect(170, 190, 51, 61))
font = QtGui.QFont()
font.setPointSize(48)
self.label_12.setFont(font)
self.label_12.setObjectName("label_12")
self.label_13 = QtWidgets.QLabel(self.centralwidget)
self.label_13.setGeometry(QtCore.QRect(580, 30, 91, 41))
font = QtGui.QFont()
font.setPointSize(36)
self.label_13.setFont(font)
self.label_13.setObjectName("label_13")
self.flags_table = QtWidgets.QGraphicsView(self.centralwidget)
self.flags_table.setGeometry(QtCore.QRect(370, 90, 541, 401))
self.flags_table.setObjectName("flags_table")
self.powerup_button = QtWidgets.QPushButton(self.centralwidget)
self.powerup_button.setGeometry(QtCore.QRect(380, 110, 111, 81))
self.powerup_button.setText("")
self.powerup_button.setObjectName("powerup_button")
self.flag = True
timer = QtCore.QTimer(self, interval=1000)
timer.timeout.connect(self.update)
timer.start(1000)
def update_color (self):
if self.flag==True:
self.powerup_button.setStyleSheet("background-color:none;")
else:
self.powerup_button.setStyleSheet("background-color: green;")
self.flag = False
I only included the part where I created my push button for simplicity, there are many more but I figured the same solution applies to all of them since they're the same. Am I just applying the timer wrong? the gui pops up, but the button I want to blink wont blink when I run the program (the powerup button)
Try it:
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(QtWidgets.QMainWindow):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(1309, 813)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.label = QtWidgets.QLabel(self.centralwidget)
self.label.setGeometry(QtCore.QRect(50, 30, 251, 41))
font = QtGui.QFont()
font.setPointSize(36)
self.label.setFont(font)
self.label.setObjectName("label")
self.voltage_percent = QtWidgets.QLCDNumber(self.centralwidget)
self.voltage_percent.setGeometry(QtCore.QRect(80, 170, 141, 91))
self.voltage_percent.setSmallDecimalPoint(True)
self.voltage_percent.setDigitCount(1)
self.voltage_percent.setProperty("intValue", 5)
self.voltage_percent.setObjectName("voltage_percent")
self.label_2 = QtWidgets.QLabel(self.centralwidget)
self.label_2.setGeometry(QtCore.QRect(1070, 30, 111, 51))
font = QtGui.QFont()
font.setPointSize(36)
self.label_2.setFont(font)
self.label_2.setObjectName("label_2")
self.modeTable = QtWidgets.QTableView(self.centralwidget)
self.modeTable.setGeometry(QtCore.QRect(970, 90, 321, 411))
self.modeTable.setObjectName("modeTable")
self.label_12 = QtWidgets.QLabel(self.centralwidget)
self.label_12.setGeometry(QtCore.QRect(170, 190, 51, 61))
font = QtGui.QFont()
font.setPointSize(48)
self.label_12.setFont(font)
self.label_12.setObjectName("label_12")
self.label_13 = QtWidgets.QLabel(self.centralwidget)
self.label_13.setGeometry(QtCore.QRect(580, 30, 91, 41))
font = QtGui.QFont()
font.setPointSize(36)
self.label_13.setFont(font)
self.label_13.setObjectName("label_13")
self.flags_table = QtWidgets.QGraphicsView(self.centralwidget)
self.flags_table.setGeometry(QtCore.QRect(370, 90, 541, 401))
self.flags_table.setObjectName("flags_table")
self.powerup_button = QtWidgets.QPushButton(self.centralwidget)
self.powerup_button.setGeometry(QtCore.QRect(380, 110, 111, 81))
self.powerup_button.setText(" ")
self.powerup_button.setObjectName("powerup_button")
self.flag = True
timer = QtCore.QTimer(MainWindow) # +++
timer.timeout.connect(self.update_color)
timer.start(1000)
MainWindow.setCentralWidget(self.centralwidget)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def update_color (self):
if self.flag: #==True:
self.powerup_button.setStyleSheet("#powerup_button {background-color:none;}")
else:
self.powerup_button.setStyleSheet("#powerup_button {background-color: green;}")
# self.flag = False
self.flag = not self.flag # +
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
app.setStyle('Windows')
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())

PyQt5 identical push buttons, one works one doesn't

I tried writing some codes using pyqt5 and have two main windows and push buttons, for both cases I have done same but one works on clicked.connect and one doesn't. Pasting code for the button which doesn't work. I call this window after closing first one
I tried creating module outside of class and that worked but then struggled with referencing to lineEdit objects
from PyQt5 import QtCore, QtGui, QtWidgets
import sys
app = QtWidgets.QApplication(sys.argv)
PREMIX = QtWidgets.QMainWindow()
logo = QtGui.QIcon()
def init_login():
ui = Ui_PREMIXlogin()
ui.setupUi(PREMIX)
PREMIX.show()
sys.exit(app.exec_())
def close_login():
PREMIX.hide()
def init_main():
ui = Ui_PREMIX()
ui.setupUi(PREMIX)
PREMIX.show()
class Ui_PREMIXlogin(object):
def setupUi(self, PREMIXlogin):
PREMIXlogin.setObjectName("PREMIXlogin")
PREMIXlogin.setEnabled(True)
PREMIXlogin.resize(280, 319)
sizePolicy = QtWidgets.QSizePolicy(
QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed
)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(
PREMIXlogin.sizePolicy().hasHeightForWidth()
)
PREMIXlogin.setSizePolicy(sizePolicy)
PREMIXlogin.setMinimumSize(QtCore.QSize(280, 319))
PREMIXlogin.setMaximumSize(QtCore.QSize(280, 319))
PREMIXlogin.setMouseTracking(False)
PREMIXlogin.setWindowIcon(logo)
PREMIXlogin.setAutoFillBackground(False)
PREMIXlogin.setStyleSheet("background-color: rgb(255, 255, 255);")
self.centralwidget = QtWidgets.QWidget(PREMIXlogin)
self.centralwidget.setObjectName("centralwidget")
self.label = QtWidgets.QLabel(self.centralwidget)
self.label.setGeometry(QtCore.QRect(36, 190, 61, 20))
font = QtGui.QFont()
font.setPointSize(10)
self.label.setFont(font)
self.label.setObjectName("label")
self.label_2 = QtWidgets.QLabel(self.centralwidget)
self.label_2.setGeometry(QtCore.QRect(36, 220, 61, 20))
font = QtGui.QFont()
font.setPointSize(10)
self.label_2.setFont(font)
self.label_2.setObjectName("label_2")
self.lineEdit = QtWidgets.QLineEdit(self.centralwidget)
self.lineEdit.setGeometry(QtCore.QRect(110, 190, 113, 20))
self.lineEdit.setObjectName("lineEdit")
self.lineEdit_2 = QtWidgets.QLineEdit(self.centralwidget)
self.lineEdit_2.setGeometry(QtCore.QRect(110, 220, 113, 20))
font = QtGui.QFont()
font.setBold(True)
font.setWeight(75)
self.lineEdit_2.setFont(font)
self.lineEdit_2.setInputMethodHints(
QtCore.Qt.ImhHiddenText
| QtCore.Qt.ImhNoAutoUppercase
| QtCore.Qt.ImhNoPredictiveText
| QtCore.Qt.ImhSensitiveData
)
self.lineEdit_2.setFrame(True)
self.lineEdit_2.setEchoMode(QtWidgets.QLineEdit.Password)
self.lineEdit_2.setObjectName("lineEdit_2")
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(100, 260, 81, 31))
font = QtGui.QFont()
font.setPointSize(11)
font.setBold(False)
font.setWeight(50)
self.pushButton.setFont(font)
self.pushButton.setAutoFillBackground(False)
self.pushButton.setStyleSheet("background-color: rgb(222, 31, 38);")
self.pushButton.setObjectName("pushButton")
self.frame = QtWidgets.QFrame(self.centralwidget)
self.frame.setGeometry(QtCore.QRect(30, 20, 231, 151))
self.frame.setStyleSheet(
"image: url(:/images/59301307_2353273704903079_3349139235981492224_n.png);"
)
self.frame.setFrameShape(QtWidgets.QFrame.StyledPanel)
self.frame.setFrameShadow(QtWidgets.QFrame.Raised)
self.frame.setObjectName("frame")
PREMIXlogin.setCentralWidget(self.centralwidget)
self.statusbar = QtWidgets.QStatusBar(PREMIXlogin)
self.statusbar.setObjectName("statusbar")
PREMIXlogin.setStatusBar(self.statusbar)
self.retranslateUi(PREMIXlogin)
QtCore.QMetaObject.connectSlotsByName(PREMIXlogin)
def retranslateUi(self, PREMIXlogin):
_translate = QtCore.QCoreApplication.translate
PREMIXlogin.setWindowTitle(_translate("PREMIXlogin", "PREMIX Login"))
self.label.setText(_translate("PREMIXlogin", "Username"))
self.label_2.setText(_translate("PREMIXlogin", "Password"))
self.pushButton.setText(_translate("PREMIXlogin", "Log in"))
self.pushButton.clicked.connect(self.on_click)
def on_click(self):
if True:
close_login()
init_main()
class Ui_PREMIX(object):
def setupUi(self, PREMIX):
PREMIX.setObjectName("PREMIX")
PREMIX.resize(473, 179)
sizePolicy = QtWidgets.QSizePolicy(
QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed
)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(PREMIX.sizePolicy().hasHeightForWidth())
PREMIX.setSizePolicy(sizePolicy)
PREMIX.setMinimumSize(QtCore.QSize(473, 179))
PREMIX.setMaximumSize(QtCore.QSize(473, 179))
PREMIX.setStyleSheet("background-color: rgb(255, 255, 255);")
PREMIX.setWindowIcon(logo)
self.centralwidget = QtWidgets.QWidget(PREMIX)
self.centralwidget.setObjectName("centralwidget")
self.Product = QtWidgets.QLabel(self.centralwidget)
self.Product.setGeometry(QtCore.QRect(30, 20, 61, 20))
font = QtGui.QFont()
font.setPointSize(13)
self.Product.setFont(font)
self.Product.setObjectName("Product")
self.Productname = QtWidgets.QLineEdit(self.centralwidget)
self.Productname.setGeometry(QtCore.QRect(100, 20, 251, 20))
self.Productname.setObjectName("Productname")
self.Checkbutton = QtWidgets.QPushButton(self.centralwidget)
self.Checkbutton.setGeometry(QtCore.QRect(370, 20, 81, 21))
font = QtGui.QFont()
font.setPointSize(11)
font.setBold(False)
font.setWeight(50)
self.Checkbutton.setFont(font)
self.Checkbutton.setAutoFillBackground(False)
self.Checkbutton.setStyleSheet("background-color: rgb(222, 31, 38);")
self.Checkbutton.setObjectName("Checkbutton")
self.logo = QtWidgets.QFrame(self.centralwidget)
self.logo.setGeometry(QtCore.QRect(359, 60, 101, 80))
self.logo.setStyleSheet(
"image: url(:/images/59301307_2353273704903079_3349139235981492224_n.png);"
)
self.logo.setFrameShape(QtWidgets.QFrame.StyledPanel)
self.logo.setFrameShadow(QtWidgets.QFrame.Raised)
self.logo.setObjectName("logo")
self.lineEdit = QtWidgets.QLineEdit(self.centralwidget)
self.lineEdit.setGeometry(QtCore.QRect(180, 80, 91, 31))
self.lineEdit.setMinimumSize(QtCore.QSize(89, 31))
self.lineEdit.setMaximumSize(QtCore.QSize(91, 31))
self.lineEdit.setObjectName("lineEdit")
self.lineEdit.setReadOnly(True)
PREMIX.setCentralWidget(self.centralwidget)
self.statusbar = QtWidgets.QStatusBar(PREMIX)
self.statusbar.setObjectName("statusbar")
PREMIX.setStatusBar(self.statusbar)
self.retranslateUi(PREMIX)
QtCore.QMetaObject.connectSlotsByName(PREMIX)
def retranslateUi(self, PREMIX):
_translate = QtCore.QCoreApplication.translate
PREMIX.setWindowTitle(_translate("PREMIX", "PREMIX"))
self.Product.setText(_translate("PREMIX", "Product"))
self.Checkbutton.setText(_translate("PREMIX", "Check"))
self.Checkbutton.clicked.connect(self.on_click)
def on_click(self):
print("aaaaaa")
product = self.Productname.text()
print(product)
def main():
init_login()
if __name__ == "__main__":
main()
I want Checkbutton on click event to work, please help
For Ui_Premix, used self.Checkbutton.clicked.connect(Ui_PREMIX.on_click) instead of
self.on_click even though on_click event was inside class, it works now

Connecting click events to function for pyqt

This is undoubtedly a simple question, but I cannot seem to get it. All i want to do is run a function on a button click. I have created a .ui and converted it to a .py file and imported it as Ui_Dialog. The gui itself opens up fine and my pushButton is called btn_browseDEM and lineEdit is called lineEdit_DEM. Help??
class MyDialog(QDialog):
def __init__(self):
QDialog.__init__(self)
# Set up the user interface from Designer.
self.ui = Ui_Dialog()
self.ui.setupUi(self)
self.ui.btn_browseDEM.clicked.connect(self.btn_browseDEM_clicked)
def btn_browseDEM_clicked(self):
self.ui.lineEdit_DEM.setText('hello')
app = QApplication(sys.argv)
window = QDialog()
gui = MyDialog()
gui.ui.setupUi(window)
window.show()
sys.exit(app.exec_())
converted ui file
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'C:\Python27\Scripts\PyQT\Example1.ui'
#
# Created: Thu Jul 31 20:40:38 2014
# by: PyQt4 UI code generator 4.10.3
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName(_fromUtf8("Dialog"))
Dialog.resize(592, 640)
self.buttonBox = QtGui.QDialogButtonBox(Dialog)
self.buttonBox.setGeometry(QtCore.QRect(230, 600, 341, 32))
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
self.buttonBox.setObjectName(_fromUtf8("buttonBox"))
self.tabWidget = QtGui.QTabWidget(Dialog)
self.tabWidget.setGeometry(QtCore.QRect(20, 20, 551, 571))
self.tabWidget.setObjectName(_fromUtf8("tabWidget"))
self.tab = QtGui.QWidget()
self.tab.setObjectName(_fromUtf8("tab"))
self.lineEdit_DEM = QtGui.QLineEdit(self.tab)
self.lineEdit_DEM.setGeometry(QtCore.QRect(50, 83, 301, 20))
self.lineEdit_DEM.setObjectName(_fromUtf8("lineEdit_DEM"))
self.checkBox_2 = QtGui.QCheckBox(self.tab)
self.checkBox_2.setGeometry(QtCore.QRect(50, 250, 141, 17))
self.checkBox_2.setObjectName(_fromUtf8("checkBox_2"))
self.label = QtGui.QLabel(self.tab)
self.label.setGeometry(QtCore.QRect(20, 200, 61, 16))
font = QtGui.QFont()
font.setPointSize(9)
font.setBold(False)
font.setWeight(50)
self.label.setFont(font)
self.label.setLineWidth(2)
self.label.setObjectName(_fromUtf8("label"))
self.checkBox = QtGui.QCheckBox(self.tab)
self.checkBox.setGeometry(QtCore.QRect(50, 220, 151, 17))
self.checkBox.setObjectName(_fromUtf8("checkBox"))
self.checkBox_3 = QtGui.QCheckBox(self.tab)
self.checkBox_3.setGeometry(QtCore.QRect(50, 280, 141, 17))
self.checkBox_3.setObjectName(_fromUtf8("checkBox_3"))
self.label_4 = QtGui.QLabel(self.tab)
self.label_4.setGeometry(QtCore.QRect(50, 102, 371, 16))
self.label_4.setFrameShadow(QtGui.QFrame.Plain)
self.label_4.setObjectName(_fromUtf8("label_4"))
self.pushButton_2 = QtGui.QPushButton(self.tab)
self.pushButton_2.setGeometry(QtCore.QRect(360, 130, 75, 23))
self.pushButton_2.setObjectName(_fromUtf8("pushButton_2"))
self.label_3 = QtGui.QLabel(self.tab)
self.label_3.setGeometry(QtCore.QRect(50, 60, 371, 16))
self.label_3.setFrameShadow(QtGui.QFrame.Plain)
self.label_3.setObjectName(_fromUtf8("label_3"))
self.btn_browseDEM = QtGui.QPushButton(self.tab)
self.btn_browseDEM.setGeometry(QtCore.QRect(360, 80, 75, 23))
self.btn_browseDEM.setObjectName(_fromUtf8("btn_browseDEM"))
self.lineEdit_2 = QtGui.QLineEdit(self.tab)
self.lineEdit_2.setGeometry(QtCore.QRect(50, 131, 301, 20))
self.lineEdit_2.setObjectName(_fromUtf8("lineEdit_2"))
self.line_7 = QtGui.QFrame(self.tab)
self.line_7.setGeometry(QtCore.QRect(10, 210, 521, 16))
self.line_7.setLineWidth(2)
self.line_7.setFrameShape(QtGui.QFrame.HLine)
self.line_7.setFrameShadow(QtGui.QFrame.Sunken)
self.line_7.setObjectName(_fromUtf8("line_7"))
self.line_8 = QtGui.QFrame(self.tab)
self.line_8.setGeometry(QtCore.QRect(10, 300, 521, 16))
self.line_8.setFrameShape(QtGui.QFrame.HLine)
self.line_8.setFrameShadow(QtGui.QFrame.Sunken)
self.line_8.setObjectName(_fromUtf8("line_8"))
self.line_9 = QtGui.QFrame(self.tab)
self.line_9.setGeometry(QtCore.QRect(10, 52, 521, 16))
self.line_9.setLineWidth(2)
self.line_9.setFrameShape(QtGui.QFrame.HLine)
self.line_9.setFrameShadow(QtGui.QFrame.Sunken)
self.line_9.setObjectName(_fromUtf8("line_9"))
self.line_10 = QtGui.QFrame(self.tab)
self.line_10.setGeometry(QtCore.QRect(10, 152, 521, 16))
self.line_10.setFrameShape(QtGui.QFrame.HLine)
self.line_10.setFrameShadow(QtGui.QFrame.Sunken)
self.line_10.setObjectName(_fromUtf8("line_10"))
self.label_20 = QtGui.QLabel(self.tab)
self.label_20.setGeometry(QtCore.QRect(20, 40, 61, 16))
font = QtGui.QFont()
font.setPointSize(9)
font.setBold(False)
font.setWeight(50)
self.label_20.setFont(font)
self.label_20.setObjectName(_fromUtf8("label_20"))
self.tabWidget.addTab(self.tab, _fromUtf8(""))
self.tab_3 = QtGui.QWidget()
self.tab_3.setObjectName(_fromUtf8("tab_3"))
self.label_10 = QtGui.QLabel(self.tab_3)
self.label_10.setGeometry(QtCore.QRect(80, 40, 351, 16))
self.label_10.setObjectName(_fromUtf8("label_10"))
self.lineEdit_7 = QtGui.QLineEdit(self.tab_3)
self.lineEdit_7.setGeometry(QtCore.QRect(40, 39, 31, 20))
self.lineEdit_7.setInputMethodHints(QtCore.Qt.ImhDigitsOnly)
self.lineEdit_7.setObjectName(_fromUtf8("lineEdit_7"))
self.label_11 = QtGui.QLabel(self.tab_3)
self.label_11.setGeometry(QtCore.QRect(40, 70, 481, 31))
self.label_11.setWordWrap(True)
self.label_11.setObjectName(_fromUtf8("label_11"))
self.label_12 = QtGui.QLabel(self.tab_3)
self.label_12.setGeometry(QtCore.QRect(30, 10, 491, 16))
self.label_12.setObjectName(_fromUtf8("label_12"))
self.checkBox_8 = QtGui.QCheckBox(self.tab_3)
self.checkBox_8.setGeometry(QtCore.QRect(20, 140, 341, 17))
self.checkBox_8.setObjectName(_fromUtf8("checkBox_8"))
self.lineEdit_8 = QtGui.QLineEdit(self.tab_3)
self.lineEdit_8.setGeometry(QtCore.QRect(40, 100, 81, 20))
self.lineEdit_8.setInputMethodHints(QtCore.Qt.ImhDigitsOnly)
self.lineEdit_8.setObjectName(_fromUtf8("lineEdit_8"))
self.label_17 = QtGui.QLabel(self.tab_3)
self.label_17.setGeometry(QtCore.QRect(50, 190, 351, 16))
self.label_17.setObjectName(_fromUtf8("label_17"))
self.label_15 = QtGui.QLabel(self.tab_3)
self.label_15.setGeometry(QtCore.QRect(100, 271, 351, 16))
self.label_15.setObjectName(_fromUtf8("label_15"))
self.lineEdit_9 = QtGui.QLineEdit(self.tab_3)
self.lineEdit_9.setGeometry(QtCore.QRect(60, 241, 301, 21))
self.lineEdit_9.setObjectName(_fromUtf8("lineEdit_9"))
self.comboBox = QtGui.QComboBox(self.tab_3)
self.comboBox.setGeometry(QtCore.QRect(80, 360, 261, 22))
self.comboBox.setObjectName(_fromUtf8("comboBox"))
self.comboBox.addItem(_fromUtf8(""))
self.comboBox.addItem(_fromUtf8(""))
self.comboBox.addItem(_fromUtf8(""))
self.label_14 = QtGui.QLabel(self.tab_3)
self.label_14.setGeometry(QtCore.QRect(60, 221, 461, 16))
self.label_14.setObjectName(_fromUtf8("label_14"))
self.pushButton_4 = QtGui.QPushButton(self.tab_3)
self.pushButton_4.setGeometry(QtCore.QRect(370, 240, 75, 23))
self.pushButton_4.setObjectName(_fromUtf8("pushButton_4"))
self.lineEdit_10 = QtGui.QLineEdit(self.tab_3)
self.lineEdit_10.setGeometry(QtCore.QRect(60, 270, 31, 20))
self.lineEdit_10.setInputMethodHints(QtCore.Qt.ImhDigitsOnly)
self.lineEdit_10.setObjectName(_fromUtf8("lineEdit_10"))
self.label_13 = QtGui.QLabel(self.tab_3)
self.label_13.setGeometry(QtCore.QRect(20, 171, 351, 16))
self.label_13.setObjectName(_fromUtf8("label_13"))
self.lineEdit_12 = QtGui.QLineEdit(self.tab_3)
self.lineEdit_12.setGeometry(QtCore.QRect(60, 460, 301, 21))
self.lineEdit_12.setObjectName(_fromUtf8("lineEdit_12"))
self.label_19 = QtGui.QLabel(self.tab_3)
self.label_19.setGeometry(QtCore.QRect(60, 340, 261, 16))
self.label_19.setObjectName(_fromUtf8("label_19"))
self.label_16 = QtGui.QLabel(self.tab_3)
self.label_16.setGeometry(QtCore.QRect(60, 390, 461, 31))
self.label_16.setFrameShape(QtGui.QFrame.NoFrame)
self.label_16.setWordWrap(True)
self.label_16.setObjectName(_fromUtf8("label_16"))
self.lineEdit_11 = QtGui.QLineEdit(self.tab_3)
self.lineEdit_11.setGeometry(QtCore.QRect(60, 430, 301, 21))
self.lineEdit_11.setObjectName(_fromUtf8("lineEdit_11"))
self.label_18 = QtGui.QLabel(self.tab_3)
self.label_18.setGeometry(QtCore.QRect(50, 320, 351, 16))
self.label_18.setObjectName(_fromUtf8("label_18"))
self.line = QtGui.QFrame(self.tab_3)
self.line.setGeometry(QtCore.QRect(10, 330, 531, 20))
self.line.setLineWidth(2)
self.line.setFrameShape(QtGui.QFrame.HLine)
self.line.setFrameShadow(QtGui.QFrame.Sunken)
self.line.setObjectName(_fromUtf8("line"))
self.line_2 = QtGui.QFrame(self.tab_3)
self.line_2.setGeometry(QtCore.QRect(10, 180, 531, 20))
self.line_2.setLineWidth(2)
self.line_2.setFrameShape(QtGui.QFrame.HLine)
self.line_2.setFrameShadow(QtGui.QFrame.Sunken)
self.line_2.setObjectName(_fromUtf8("line_2"))
self.line_3 = QtGui.QFrame(self.tab_3)
self.line_3.setGeometry(QtCore.QRect(10, 20, 531, 20))
self.line_3.setLineWidth(2)
self.line_3.setFrameShape(QtGui.QFrame.HLine)
self.line_3.setFrameShadow(QtGui.QFrame.Sunken)
self.line_3.setObjectName(_fromUtf8("line_3"))
self.line_4 = QtGui.QFrame(self.tab_3)
self.line_4.setGeometry(QtCore.QRect(10, 150, 531, 20))
self.line_4.setLineWidth(1)
self.line_4.setFrameShape(QtGui.QFrame.HLine)
self.line_4.setFrameShadow(QtGui.QFrame.Sunken)
self.line_4.setObjectName(_fromUtf8("line_4"))
self.line_5 = QtGui.QFrame(self.tab_3)
self.line_5.setGeometry(QtCore.QRect(10, 480, 531, 20))
self.line_5.setLineWidth(1)
self.line_5.setFrameShape(QtGui.QFrame.HLine)
self.line_5.setFrameShadow(QtGui.QFrame.Sunken)
self.line_5.setObjectName(_fromUtf8("line_5"))
self.line_6 = QtGui.QFrame(self.tab_3)
self.line_6.setGeometry(QtCore.QRect(10, 290, 531, 20))
self.line_6.setLineWidth(1)
self.line_6.setFrameShape(QtGui.QFrame.HLine)
self.line_6.setFrameShadow(QtGui.QFrame.Sunken)
self.line_6.setObjectName(_fromUtf8("line_6"))
self.tabWidget.addTab(self.tab_3, _fromUtf8(""))
self.tab_2 = QtGui.QWidget()
self.tab_2.setObjectName(_fromUtf8("tab_2"))
self.lineEdit_3 = QtGui.QLineEdit(self.tab_2)
self.lineEdit_3.setGeometry(QtCore.QRect(24, 68, 31, 20))
self.lineEdit_3.setInputMethodHints(QtCore.Qt.ImhDigitsOnly)
self.lineEdit_3.setObjectName(_fromUtf8("lineEdit_3"))
self.label_5 = QtGui.QLabel(self.tab_2)
self.label_5.setGeometry(QtCore.QRect(30, 40, 491, 16))
self.label_5.setObjectName(_fromUtf8("label_5"))
self.label_6 = QtGui.QLabel(self.tab_2)
self.label_6.setGeometry(QtCore.QRect(60, 70, 341, 16))
self.label_6.setObjectName(_fromUtf8("label_6"))
self.label_8 = QtGui.QLabel(self.tab_2)
self.label_8.setGeometry(QtCore.QRect(60, 130, 341, 16))
self.label_8.setObjectName(_fromUtf8("label_8"))
self.lineEdit_5 = QtGui.QLineEdit(self.tab_2)
self.lineEdit_5.setGeometry(QtCore.QRect(24, 128, 31, 20))
self.lineEdit_5.setInputMethodHints(QtCore.Qt.ImhDigitsOnly)
self.lineEdit_5.setObjectName(_fromUtf8("lineEdit_5"))
self.lineEdit_4 = QtGui.QLineEdit(self.tab_2)
self.lineEdit_4.setGeometry(QtCore.QRect(24, 99, 31, 20))
self.lineEdit_4.setInputMethodHints(QtCore.Qt.ImhDigitsOnly)
self.lineEdit_4.setObjectName(_fromUtf8("lineEdit_4"))
self.label_7 = QtGui.QLabel(self.tab_2)
self.label_7.setGeometry(QtCore.QRect(60, 101, 341, 16))
self.label_7.setInputMethodHints(QtCore.Qt.ImhDigitsOnly)
self.label_7.setObjectName(_fromUtf8("label_7"))
self.tabWidget.addTab(self.tab_2, _fromUtf8(""))
self.tab_4 = QtGui.QWidget()
self.tab_4.setObjectName(_fromUtf8("tab_4"))
self.checkBox_7 = QtGui.QCheckBox(self.tab_4)
self.checkBox_7.setGeometry(QtCore.QRect(30, 40, 241, 17))
self.checkBox_7.setObjectName(_fromUtf8("checkBox_7"))
self.label_9 = QtGui.QLabel(self.tab_4)
self.label_9.setGeometry(QtCore.QRect(30, 70, 471, 61))
self.label_9.setWordWrap(True)
self.label_9.setObjectName(_fromUtf8("label_9"))
self.lineEdit_6 = QtGui.QLineEdit(self.tab_4)
self.lineEdit_6.setGeometry(QtCore.QRect(30, 141, 301, 21))
self.lineEdit_6.setObjectName(_fromUtf8("lineEdit_6"))
self.pushButton_3 = QtGui.QPushButton(self.tab_4)
self.pushButton_3.setGeometry(QtCore.QRect(340, 140, 75, 23))
self.pushButton_3.setObjectName(_fromUtf8("pushButton_3"))
self.tabWidget.addTab(self.tab_4, _fromUtf8(""))
self.retranslateUi(Dialog)
self.tabWidget.setCurrentIndex(0)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), Dialog.accept)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), Dialog.reject)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
Dialog.setWindowTitle(_translate("Dialog", "Dialog", None))
self.checkBox_2.setText(_translate("Dialog", "Run depression areas?", None))
self.label.setText(_translate("Dialog", "TOOLS", None))
self.checkBox.setText(_translate("Dialog", "Run overland flow paths?", None))
self.checkBox_3.setText(_translate("Dialog", "Delineate catchments?", None))
self.label_4.setText(_translate("Dialog", "Set directory path where the results should be stored", None))
self.pushButton_2.setText(_translate("Dialog", "Browse", None))
self.label_3.setText(_translate("Dialog", "Set the path to your digital elevation model (must be in the Saga grid format)", None))
self.btn_browseDEM.setText(_translate("Dialog", "Browse", None))
self.label_20.setText(_translate("Dialog", "FOLDERS", None))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), _translate("Dialog", "Inputs", None))
self.label_10.setText(_translate("Dialog", "Set the minimum overland flow path length to be mapped (m)", None))
self.lineEdit_7.setText(_translate("Dialog", "50", None))
self.label_11.setText(_translate("Dialog", "The minimum area (m┬▓) required to initate an overland flow path. To run for multiple areas specify as comma delimited e.g \'1000, 2000, 3000\'", None))
self.label_12.setText(_translate("Dialog", "Overland flow path parameters", None))
self.checkBox_8.setText(_translate("Dialog", "Estimate flows for overland flow paths using the rational method?", None))
self.lineEdit_8.setText(_translate("Dialog", "10000", None))
self.label_17.setText(_translate("Dialog", "Runoff coefficient parameters", None))
self.label_15.setText(_translate("Dialog", "Default runoff coefficient (if grid is not specified)", None))
self.comboBox.setItemText(0, _translate("Dialog", "Ramser Kirpch, Waikato Regional Council", None))
self.comboBox.setItemText(1, _translate("Dialog", "Bransby Williams, Waikato Regional Council", None))
self.comboBox.setItemText(2, _translate("Dialog", "Bransby Williams, Christchurch City Council", None))
self.label_14.setText(_translate("Dialog", "Location of the runoff coefficient grid (must be in the saga grid format)", None))
self.pushButton_4.setText(_translate("Dialog", "Browse", None))
self.lineEdit_10.setText(_translate("Dialog", "0.35", None))
self.label_13.setText(_translate("Dialog", "Please fill in the boxes below if you want flows...", None))
self.lineEdit_12.setText(_translate("Dialog", "10,20,30,60,120,360,720,1440,2880,4320", None))
self.label_19.setText(_translate("Dialog", "Select method for calculating time of concentration", None))
self.label_16.setText(_translate("Dialog", "Rainfall intensities (mm/hr) and durations to be used in the flow calculation (these will be interpolated using the time of concentration to get a corrseponding rainfall intensity)", None))
self.lineEdit_11.setText(_translate("Dialog", "129,92.7,76.6,55.3,33.6,15.3,9.4,5.7,3.5,2.6", None))
self.label_18.setText(_translate("Dialog", "Time of concentration parameters", None))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_3), _translate("Dialog", "Overland Flow Paths", None))
self.lineEdit_3.setText(_translate("Dialog", "50", None))
self.label_5.setText(_translate("Dialog", "This module creates a lot of polygons, here you can specify filter parameters for the depression areas", None))
self.label_6.setText(_translate("Dialog", "Only depression areas with a volume exceeding xx m2 will be mapped", None))
self.label_8.setText(_translate("Dialog", "Only depression areas with a depth exceeding xx mm will be mapped", None))
self.lineEdit_5.setText(_translate("Dialog", "300", None))
self.lineEdit_4.setText(_translate("Dialog", "500", None))
self.label_7.setText(_translate("Dialog", "Only depression areas with an area exceeding xx m3 will be mapped", None))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2), _translate("Dialog", "Depression Areas", None))
self.checkBox_7.setText(_translate("Dialog", "Use overland flow paths generated by script?", None))
self.label_9.setText(_translate("Dialog", "<html><head/><body><p>If you do not want to use overland flow paths created by the script for delineating catchments, then you will need to browse to a shape file. The attribute table of the shape file must have a field named \'X_2\' containing the X co-ordinate of the catchment outlet and a field named \'Y_2\' containing the Y co-ordinate of the cathment outlet</p></body></html>", None))
self.pushButton_3.setText(_translate("Dialog", "Browse", None))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_4), _translate("Dialog", "Catchments", None))
You might want to show the created gui directly.
app = QApplication(sys.argv)
gui = MyDialog()
gui.show()
sys.exit(app.exec_())

Viewing pyqt4 export before adding code

I am new to python 3.3 and am having some trouble with random simple tasks. I made a gui in qt designer and exported the py code. I added
def show(self):
self.QtGui.show()
sys.exit(self.exec_())
and
MainWindow = Ui_MainWindow(sys.argv)
MainWindow.show()
to the end to try and view the GUI before I add in all the code. Im sure this is possible, I just can not figure it out. My entire code is:
from PyQt4 import QtCore, QtGui
import sys
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName(_fromUtf8("MainWindow"))
MainWindow.resize(390, 355)
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
self.tabWidget = QtGui.QTabWidget(self.centralwidget)
self.tabWidget.setGeometry(QtCore.QRect(10, 10, 371, 301))
self.tabWidget.setObjectName(_fromUtf8("tabWidget"))
self.TS2 = QtGui.QWidget()
self.TS2.setObjectName(_fromUtf8("TS2"))
self.lineEdit = QtGui.QLineEdit(self.TS2)
self.lineEdit.setGeometry(QtCore.QRect(120, 30, 91, 20))
self.lineEdit.setText(_fromUtf8(""))
self.lineEdit.setObjectName(_fromUtf8("lineEdit"))
self.spinBox = QtGui.QSpinBox(self.TS2)
self.spinBox.setGeometry(QtCore.QRect(120, 70, 42, 22))
self.spinBox.setObjectName(_fromUtf8("spinBox"))
self.pushButton = QtGui.QPushButton(self.TS2)
self.pushButton.setGeometry(QtCore.QRect(140, 230, 91, 23))
self.pushButton.setObjectName(_fromUtf8("pushButton"))
self.label = QtGui.QLabel(self.TS2)
self.label.setGeometry(QtCore.QRect(20, 30, 91, 16))
self.label.setObjectName(_fromUtf8("label"))
self.label_2 = QtGui.QLabel(self.TS2)
self.label_2.setGeometry(QtCore.QRect(20, 70, 91, 20))
self.label_2.setObjectName(_fromUtf8("label_2"))
self.label_11 = QtGui.QLabel(self.TS2)
self.label_11.setGeometry(QtCore.QRect(20, 170, 91, 21))
self.label_11.setObjectName(_fromUtf8("label_11"))
self.lineEdit_6 = QtGui.QLineEdit(self.TS2)
self.lineEdit_6.setGeometry(QtCore.QRect(120, 170, 131, 20))
self.lineEdit_6.setObjectName(_fromUtf8("lineEdit_6"))
self.pushButton_6 = QtGui.QPushButton(self.TS2)
self.pushButton_6.setGeometry(QtCore.QRect(260, 170, 75, 23))
self.pushButton_6.setObjectName(_fromUtf8("pushButton_6"))
self.line_2 = QtGui.QFrame(self.TS2)
self.line_2.setGeometry(QtCore.QRect(0, 200, 371, 20))
self.line_2.setFrameShape(QtGui.QFrame.HLine)
self.line_2.setFrameShadow(QtGui.QFrame.Sunken)
self.line_2.setObjectName(_fromUtf8("line_2"))
self.tabWidget.addTab(self.TS2, _fromUtf8(""))
self.AGS = QtGui.QWidget()
self.AGS.setObjectName(_fromUtf8("AGS"))
self.lineEdit_2 = QtGui.QLineEdit(self.AGS)
self.lineEdit_2.setGeometry(QtCore.QRect(120, 30, 91, 20))
self.lineEdit_2.setText(_fromUtf8(""))
self.lineEdit_2.setObjectName(_fromUtf8("lineEdit_2"))
self.label_3 = QtGui.QLabel(self.AGS)
self.label_3.setGeometry(QtCore.QRect(20, 30, 91, 16))
self.label_3.setObjectName(_fromUtf8("label_3"))
self.spinBox_2 = QtGui.QSpinBox(self.AGS)
self.spinBox_2.setGeometry(QtCore.QRect(120, 70, 42, 22))
self.spinBox_2.setObjectName(_fromUtf8("spinBox_2"))
self.label_4 = QtGui.QLabel(self.AGS)
self.label_4.setGeometry(QtCore.QRect(20, 70, 91, 20))
self.label_4.setObjectName(_fromUtf8("label_4"))
self.pushButton_2 = QtGui.QPushButton(self.AGS)
self.pushButton_2.setGeometry(QtCore.QRect(140, 230, 91, 23))
self.pushButton_2.setObjectName(_fromUtf8("pushButton_2"))
self.label_8 = QtGui.QLabel(self.AGS)
self.label_8.setGeometry(QtCore.QRect(20, 110, 91, 21))
self.label_8.setObjectName(_fromUtf8("label_8"))
self.label_10 = QtGui.QLabel(self.AGS)
self.label_10.setGeometry(QtCore.QRect(20, 170, 91, 21))
self.label_10.setObjectName(_fromUtf8("label_10"))
self.lineEdit_5 = QtGui.QLineEdit(self.AGS)
self.lineEdit_5.setGeometry(QtCore.QRect(120, 170, 131, 20))
self.lineEdit_5.setObjectName(_fromUtf8("lineEdit_5"))
self.pushButton_5 = QtGui.QPushButton(self.AGS)
self.pushButton_5.setGeometry(QtCore.QRect(260, 170, 75, 23))
self.pushButton_5.setObjectName(_fromUtf8("pushButton_5"))
self.lineEdit_7 = QtGui.QLineEdit(self.AGS)
self.lineEdit_7.setGeometry(QtCore.QRect(120, 110, 31, 20))
self.lineEdit_7.setObjectName(_fromUtf8("lineEdit_7"))
self.label_12 = QtGui.QLabel(self.AGS)
self.label_12.setGeometry(QtCore.QRect(160, 110, 61, 21))
self.label_12.setObjectName(_fromUtf8("label_12"))
self.line = QtGui.QFrame(self.AGS)
self.line.setGeometry(QtCore.QRect(0, 200, 371, 20))
self.line.setFrameShape(QtGui.QFrame.HLine)
self.line.setFrameShadow(QtGui.QFrame.Sunken)
self.line.setObjectName(_fromUtf8("line"))
self.tabWidget.addTab(self.AGS, _fromUtf8(""))
self.AQT = QtGui.QWidget()
self.AQT.setObjectName(_fromUtf8("AQT"))
self.label_5 = QtGui.QLabel(self.AQT)
self.label_5.setGeometry(QtCore.QRect(20, 30, 91, 16))
self.label_5.setObjectName(_fromUtf8("label_5"))
self.lineEdit_3 = QtGui.QLineEdit(self.AQT)
self.lineEdit_3.setGeometry(QtCore.QRect(120, 30, 91, 20))
self.lineEdit_3.setText(_fromUtf8(""))
self.lineEdit_3.setObjectName(_fromUtf8("lineEdit_3"))
self.spinBox_3 = QtGui.QSpinBox(self.AQT)
self.spinBox_3.setGeometry(QtCore.QRect(120, 70, 42, 22))
self.spinBox_3.setObjectName(_fromUtf8("spinBox_3"))
self.label_6 = QtGui.QLabel(self.AQT)
self.label_6.setGeometry(QtCore.QRect(20, 70, 91, 20))
self.label_6.setObjectName(_fromUtf8("label_6"))
self.pushButton_3 = QtGui.QPushButton(self.AQT)
self.pushButton_3.setGeometry(QtCore.QRect(140, 230, 91, 23))
self.pushButton_3.setObjectName(_fromUtf8("pushButton_3"))
self.dateEdit = QtGui.QDateEdit(self.AQT)
self.dateEdit.setGeometry(QtCore.QRect(120, 110, 110, 22))
self.dateEdit.setObjectName(_fromUtf8("dateEdit"))
self.label_7 = QtGui.QLabel(self.AQT)
self.label_7.setGeometry(QtCore.QRect(20, 110, 91, 21))
self.label_7.setObjectName(_fromUtf8("label_7"))
self.pushButton_4 = QtGui.QPushButton(self.AQT)
self.pushButton_4.setGeometry(QtCore.QRect(260, 170, 75, 23))
self.pushButton_4.setFlat(False)
self.pushButton_4.setObjectName(_fromUtf8("pushButton_4"))
self.lineEdit_4 = QtGui.QLineEdit(self.AQT)
self.lineEdit_4.setGeometry(QtCore.QRect(120, 170, 131, 20))
self.lineEdit_4.setObjectName(_fromUtf8("lineEdit_4"))
self.label_9 = QtGui.QLabel(self.AQT)
self.label_9.setGeometry(QtCore.QRect(20, 170, 91, 21))
self.label_9.setObjectName(_fromUtf8("label_9"))
self.line_3 = QtGui.QFrame(self.AQT)
self.line_3.setGeometry(QtCore.QRect(0, 200, 371, 20))
self.line_3.setFrameShape(QtGui.QFrame.HLine)
self.line_3.setFrameShadow(QtGui.QFrame.Sunken)
self.line_3.setObjectName(_fromUtf8("line_3"))
self.tabWidget.addTab(self.AQT, _fromUtf8(""))
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtGui.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 390, 21))
self.menubar.setObjectName(_fromUtf8("menubar"))
self.menuFile = QtGui.QMenu(self.menubar)
self.menuFile.setObjectName(_fromUtf8("menuFile"))
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtGui.QStatusBar(MainWindow)
self.statusbar.setObjectName(_fromUtf8("statusbar"))
MainWindow.setStatusBar(self.statusbar)
self.actionExit = QtGui.QAction(MainWindow)
self.actionExit.setObjectName(_fromUtf8("actionExit"))
self.menuFile.addAction(self.actionExit)
self.menubar.addAction(self.menuFile.menuAction())
self.retranslateUi(MainWindow)
self.tabWidget.setCurrentIndex(2)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None))
self.pushButton.setText(_translate("MainWindow", "Execute", None))
self.label.setText(_translate("MainWindow", "XXXXXXXXX:", None))
self.label_2.setText(_translate("MainWindow", "xXXXXXXXXXXX:", None))
self.label_11.setText(_translate("MainWindow", "XXXXXXXXXX:", None))
self.pushButton_6.setText(_translate("MainWindow", "Browse", None))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.TS2), _translate("MainWindow", "XXXXXX", None))
self.label_3.setText(_translate("MainWindow", "XXXXXXXX:", None))
self.label_4.setText(_translate("MainWindow", "XXXXXXXXXXX:", None))
self.pushButton_2.setText(_translate("MainWindow", "Execute", None))
self.label_8.setText(_translate("MainWindow", "xXXXXXXXX:", None))
self.label_10.setText(_translate("MainWindow", "XXXXXXXX:", None))
self.pushButton_5.setText(_translate("MainWindow", "Browse", None))
self.label_12.setText(_translate("MainWindow", "XXXXXX", None))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.AGS), _translate("MainWindow", "XXXXXX", None))
self.label_5.setText(_translate("MainWindow", "XXXX:", None))
self.label_6.setText(_translate("MainWindow", "XXXXX:", None))
self.pushButton_3.setText(_translate("MainWindow", "Execute", None))
self.dateEdit.setDisplayFormat(_translate("MainWindow", "yyyy-MM-dd", None))
self.label_7.setText(_translate("MainWindow", "XXXXX:", None))
self.pushButton_4.setText(_translate("MainWindow", "Browse", None))
self.label_9.setText(_translate("MainWindow", "xXXXXXX:", None))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.AQT), _translate("MainWindow", "XXXXX", None))
self.menuFile.setTitle(_translate("MainWindow", "File", None))
self.actionExit.setText(_translate("MainWindow", "Exit", None))
def show(self):
self.QtGui.show()
sys.exit(self.exec_())
MainWindow = Ui_MainWindow(sys.argv)
MainWindow.show()
And the error that I get is:
TypeError: object.__new__() takes no parameters
Now Im not even sure this error is related to my problem, but I am at the end of my rope trying to simply see this UI. No functionality needed yet.
Thank you in advance!
You don't need to do this by hand. pyuic4 has an option to add this: -x. Then you can just run the pyuic4 generated code and you'll see the widget. For example:
pyuic4 -x -o output.py input.ui

Categories

Resources