Connecting click events to function for pyqt - python

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_())

Related

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

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_())

Embedding PyQtGraph plots within an existing Qt Window

I'm trying to embed PyQtGraphs into an existing Qt Window (designed with Qt Designer and converted to .py file). I'm having trouble getting the PyQt GraphicLayoutView to size correctly to the Qt Group which is also inside a Tab.
I had previously managed to get the plots to work using MatPlotLib but they are just too slow at updating once the dataset gets larger, so i decided to make the switch to PyQtGraph as several posts suggested.
Im unsure if im embedding the plots correctly or if it is a case of resizing the GrahpicLayoutView to fill the group.
Any help is appreciated, code and images attached:
Image showing how the graphicsView doesnt size to fit the group
emgWindow_ui.py
# Form implementation generated from reading ui file 'emgWindow.ui'
#
# Created by: PyQt4 UI code generator 4.11.4
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
import pyqtgraph as pg
import numpy as np
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):
global win,curve
MainWindow.setObjectName(_fromUtf8("MainWindow"))
MainWindow.resize(1239, 796)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(MainWindow.sizePolicy().hasHeightForWidth())
MainWindow.setSizePolicy(sizePolicy)
self.centralWidget = QtGui.QWidget(MainWindow)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.centralWidget.sizePolicy().hasHeightForWidth())
self.centralWidget.setSizePolicy(sizePolicy)
self.centralWidget.setObjectName(_fromUtf8("centralWidget"))
self.gridLayout = QtGui.QGridLayout(self.centralWidget)
self.gridLayout.setMargin(11)
self.gridLayout.setSpacing(6)
self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
self.tabWidget = QtGui.QTabWidget(self.centralWidget)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.tabWidget.sizePolicy().hasHeightForWidth())
self.tabWidget.setSizePolicy(sizePolicy)
self.tabWidget.setObjectName(_fromUtf8("tabWidget"))
self.recordTab = QtGui.QWidget()
self.recordTab.setObjectName(_fromUtf8("recordTab"))
self.dirFrame = QtGui.QFrame(self.recordTab)
self.dirFrame.setGeometry(QtCore.QRect(10, 640, 711, 51))
self.dirFrame.setFrameShape(QtGui.QFrame.StyledPanel)
self.dirFrame.setFrameShadow(QtGui.QFrame.Raised)
self.dirFrame.setObjectName(_fromUtf8("dirFrame"))
self.dirTextBox = QtGui.QTextEdit(self.dirFrame)
self.dirTextBox.setGeometry(QtCore.QRect(10, 10, 511, 31))
self.dirTextBox.setObjectName(_fromUtf8("dirTextBox"))
self.recordBtn = QtGui.QPushButton(self.dirFrame)
self.recordBtn.setGeometry(QtCore.QRect(530, 10, 81, 31))
self.recordBtn.setObjectName(_fromUtf8("recordBtn"))
self.stopBtn = QtGui.QPushButton(self.dirFrame)
self.stopBtn.setGeometry(QtCore.QRect(620, 10, 81, 31))
self.stopBtn.setObjectName(_fromUtf8("stopBtn"))
self.trainingIMGBox = QtGui.QGroupBox(self.recordTab)
self.trainingIMGBox.setGeometry(QtCore.QRect(730, 400, 481, 291))
self.trainingIMGBox.setObjectName(_fromUtf8("trainingIMGBox"))
self.IMUBox = QtGui.QGroupBox(self.recordTab)
self.IMUBox.setGeometry(QtCore.QRect(730, 10, 481, 381))
self.IMUBox.setObjectName(_fromUtf8("IMUBox"))
self.EMGBox = QtGui.QGroupBox(self.recordTab)
self.EMGBox.setGeometry(QtCore.QRect(10, 10, 711, 621))
self.EMGBox.setObjectName(_fromUtf8("EMGBox"))
self.tabWidget.addTab(self.recordTab, _fromUtf8(""))
self.classifyTab = QtGui.QWidget()
self.classifyTab.setObjectName(_fromUtf8("classifyTab"))
self.frame_4 = QtGui.QFrame(self.classifyTab)
self.frame_4.setGeometry(QtCore.QRect(280, 10, 921, 681))
self.frame_4.setFrameShape(QtGui.QFrame.StyledPanel)
self.frame_4.setFrameShadow(QtGui.QFrame.Raised)
self.frame_4.setObjectName(_fromUtf8("frame_4"))
self.featuresBox = QtGui.QGroupBox(self.classifyTab)
self.featuresBox.setGeometry(QtCore.QRect(10, 10, 261, 191))
self.featuresBox.setObjectName(_fromUtf8("featuresBox"))
self.MAVCheck = QtGui.QCheckBox(self.featuresBox)
self.MAVCheck.setGeometry(QtCore.QRect(10, 20, 141, 17))
self.MAVCheck.setObjectName(_fromUtf8("MAVCheck"))
self.RMSCheck = QtGui.QCheckBox(self.featuresBox)
self.RMSCheck.setGeometry(QtCore.QRect(10, 40, 141, 17))
self.RMSCheck.setObjectName(_fromUtf8("RMSCheck"))
self.VARCheck = QtGui.QCheckBox(self.featuresBox)
self.VARCheck.setGeometry(QtCore.QRect(10, 60, 131, 17))
self.VARCheck.setObjectName(_fromUtf8("VARCheck"))
self.SSICheck = QtGui.QCheckBox(self.featuresBox)
self.SSICheck.setGeometry(QtCore.QRect(10, 80, 141, 17))
self.SSICheck.setObjectName(_fromUtf8("SSICheck"))
self.ZCCheck = QtGui.QCheckBox(self.featuresBox)
self.ZCCheck.setGeometry(QtCore.QRect(10, 100, 131, 17))
self.ZCCheck.setObjectName(_fromUtf8("ZCCheck"))
self.WLCheck = QtGui.QCheckBox(self.featuresBox)
self.WLCheck.setGeometry(QtCore.QRect(10, 120, 141, 17))
self.WLCheck.setObjectName(_fromUtf8("WLCheck"))
self.SSCCheck = QtGui.QCheckBox(self.featuresBox)
self.SSCCheck.setGeometry(QtCore.QRect(10, 140, 141, 17))
self.SSCCheck.setObjectName(_fromUtf8("SSCCheck"))
self.WACheck = QtGui.QCheckBox(self.featuresBox)
self.WACheck.setGeometry(QtCore.QRect(10, 160, 131, 17))
self.WACheck.setObjectName(_fromUtf8("WACheck"))
self.splitBox = QtGui.QGroupBox(self.classifyTab)
self.splitBox.setGeometry(QtCore.QRect(10, 210, 261, 91))
self.splitBox.setObjectName(_fromUtf8("splitBox"))
self.trainSpin = QtGui.QSpinBox(self.splitBox)
self.trainSpin.setGeometry(QtCore.QRect(110, 20, 42, 22))
self.trainSpin.setMinimum(1)
self.trainSpin.setMaximum(100)
self.trainSpin.setSingleStep(5)
self.trainSpin.setProperty("value", 70)
self.trainSpin.setObjectName(_fromUtf8("trainSpin"))
self.testSpin = QtGui.QSpinBox(self.splitBox)
self.testSpin.setGeometry(QtCore.QRect(110, 60, 42, 22))
self.testSpin.setMinimum(1)
self.testSpin.setMaximum(100)
self.testSpin.setSingleStep(5)
self.testSpin.setProperty("value", 30)
self.testSpin.setObjectName(_fromUtf8("testSpin"))
self.label = QtGui.QLabel(self.splitBox)
self.label.setGeometry(QtCore.QRect(10, 20, 91, 16))
self.label.setObjectName(_fromUtf8("label"))
self.label_2 = QtGui.QLabel(self.splitBox)
self.label_2.setGeometry(QtCore.QRect(10, 60, 91, 16))
self.label_2.setObjectName(_fromUtf8("label_2"))
self.splitBtn = QtGui.QPushButton(self.splitBox)
self.splitBtn.setGeometry(QtCore.QRect(170, 20, 75, 61))
self.splitBtn.setObjectName(_fromUtf8("splitBtn"))
self.trainBtn = QtGui.QPushButton(self.classifyTab)
self.trainBtn.setGeometry(QtCore.QRect(40, 310, 181, 41))
self.trainBtn.setAutoFillBackground(False)
self.trainBtn.setObjectName(_fromUtf8("trainBtn"))
self.resultsBox = QtGui.QGroupBox(self.classifyTab)
self.resultsBox.setGeometry(QtCore.QRect(10, 360, 261, 331))
self.resultsBox.setObjectName(_fromUtf8("resultsBox"))
self.resultsScroll = QtGui.QScrollArea(self.resultsBox)
self.resultsScroll.setGeometry(QtCore.QRect(10, 20, 241, 301))
self.resultsScroll.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
self.resultsScroll.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.resultsScroll.setWidgetResizable(True)
self.resultsScroll.setObjectName(_fromUtf8("resultsScroll"))
self.scrollAreaWidgetContents = QtGui.QWidget()
self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 222, 299))
self.scrollAreaWidgetContents.setObjectName(_fromUtf8("scrollAreaWidgetContents"))
self.resultsScroll.setWidget(self.scrollAreaWidgetContents)
self.tabWidget.addTab(self.classifyTab, _fromUtf8(""))
self.testTab = QtGui.QWidget()
self.testTab.setObjectName(_fromUtf8("testTab"))
self.detectBox = QtGui.QGroupBox(self.testTab)
self.detectBox.setGeometry(QtCore.QRect(600, 10, 191, 681))
self.detectBox.setObjectName(_fromUtf8("detectBox"))
self.gestureTable = QtGui.QTableWidget(self.detectBox)
self.gestureTable.setGeometry(QtCore.QRect(10, 20, 171, 651))
font = QtGui.QFont()
font.setPointSize(12)
self.gestureTable.setFont(font)
self.gestureTable.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.gestureTable.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.gestureTable.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers)
self.gestureTable.setTextElideMode(QtCore.Qt.ElideMiddle)
self.gestureTable.setRowCount(10)
self.gestureTable.setColumnCount(1)
self.gestureTable.setObjectName(_fromUtf8("gestureTable"))
self.gestureTable.horizontalHeader().setVisible(False)
self.gestureTable.horizontalHeader().setDefaultSectionSize(170)
self.gestureTable.verticalHeader().setVisible(False)
self.gestureTable.verticalHeader().setDefaultSectionSize(65)
self.imgBox = QtGui.QFrame(self.testTab)
self.imgBox.setGeometry(QtCore.QRect(10, 10, 581, 571))
self.imgBox.setFrameShape(QtGui.QFrame.StyledPanel)
self.imgBox.setFrameShadow(QtGui.QFrame.Raised)
self.imgBox.setObjectName(_fromUtf8("imgBox"))
self.gestureSignal = QtGui.QLabel(self.testTab)
self.gestureSignal.setGeometry(QtCore.QRect(10, 590, 581, 21))
font = QtGui.QFont()
font.setPointSize(15)
font.setBold(True)
font.setWeight(75)
self.gestureSignal.setFont(font)
self.gestureSignal.setAlignment(QtCore.Qt.AlignCenter)
self.gestureSignal.setObjectName(_fromUtf8("gestureSignal"))
self.startBtn = QtGui.QPushButton(self.testTab)
self.startBtn.setGeometry(QtCore.QRect(230, 630, 71, 51))
self.startBtn.setObjectName(_fromUtf8("startBtn"))
self.stopBtn_2 = QtGui.QPushButton(self.testTab)
self.stopBtn_2.setGeometry(QtCore.QRect(310, 630, 75, 51))
self.stopBtn_2.setObjectName(_fromUtf8("stopBtn_2"))
self.currentBox = QtGui.QGroupBox(self.testTab)
self.currentBox.setGeometry(QtCore.QRect(800, 10, 411, 681))
self.currentBox.setObjectName(_fromUtf8("currentBox"))
self.tabWidget.addTab(self.testTab, _fromUtf8(""))
self.gridLayout.addWidget(self.tabWidget, 0, 0, 1, 1)
MainWindow.setCentralWidget(self.centralWidget)
self.menuBar = QtGui.QMenuBar(MainWindow)
self.menuBar.setGeometry(QtCore.QRect(0, 0, 1239, 21))
self.menuBar.setObjectName(_fromUtf8("menuBar"))
MainWindow.setMenuBar(self.menuBar)
self.mainToolBar = QtGui.QToolBar(MainWindow)
self.mainToolBar.setObjectName(_fromUtf8("mainToolBar"))
MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.mainToolBar)
self.statusBar = QtGui.QStatusBar(MainWindow)
self.statusBar.setObjectName(_fromUtf8("statusBar"))
MainWindow.setStatusBar(self.statusBar)
self.win = pg.GraphicsLayoutWidget(self.EMGBox)
#self.win = pg.GraphicsWindow()
pg.setConfigOptions(antialias=True)
self.p6 = self.win.addPlot(title="My Plot")
self.curve = self.p6.plot(pen='r')
data1 = np.random.normal(size=300)
curve1 = self.p6.plot(data1)
ptr1 = 0
def update1():
global data1, ptr1
data1[:-1] = data1[1:] # shift data in the array one sample left
# (see also: np.roll)
data1[-1] = np.random.normal()
curve1.setData(data1)
ptr1 += 1
curve1.setData(data1)
self.retranslateUi(MainWindow)
self.tabWidget.setCurrentIndex(0)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(_translate("MainWindow", "EMG Gesute Classifier", None))
self.recordBtn.setText(_translate("MainWindow", "Record", None))
self.stopBtn.setText(_translate("MainWindow", "Stop", None))
self.trainingIMGBox.setTitle(_translate("MainWindow", "Gesture", None))
self.IMUBox.setTitle(_translate("MainWindow", "IMU Data", None))
self.EMGBox.setTitle(_translate("MainWindow", "EMG Data", None))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.recordTab), _translate("MainWindow", "Record", None))
self.featuresBox.setTitle(_translate("MainWindow", "Features", None))
self.MAVCheck.setText(_translate("MainWindow", "Mean Absolute Value", None))
self.RMSCheck.setText(_translate("MainWindow", "Root Mean Square", None))
self.VARCheck.setText(_translate("MainWindow", "Variance", None))
self.SSICheck.setText(_translate("MainWindow", "Simple Square Integral", None))
self.ZCCheck.setText(_translate("MainWindow", "Zero Crossings", None))
self.WLCheck.setText(_translate("MainWindow", "Wave Length", None))
self.SSCCheck.setText(_translate("MainWindow", "Slope Sign Changes", None))
self.WACheck.setText(_translate("MainWindow", "Willison Amplitude", None))
self.splitBox.setTitle(_translate("MainWindow", "Split Data", None))
self.label.setText(_translate("MainWindow", "Training Dataset:", None))
self.label_2.setText(_translate("MainWindow", "Test Dataset:", None))
self.splitBtn.setText(_translate("MainWindow", "Split", None))
self.trainBtn.setText(_translate("MainWindow", "Train", None))
self.resultsBox.setTitle(_translate("MainWindow", "Results", None))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.classifyTab), _translate("MainWindow", "Classify", None))
self.detectBox.setTitle(_translate("MainWindow", "Gesture Detected", None))
self.gestureSignal.setText(_translate("MainWindow", "SIGNAL", None))
self.startBtn.setText(_translate("MainWindow", "Start", None))
self.stopBtn_2.setText(_translate("MainWindow", "Stop", None))
self.currentBox.setTitle(_translate("MainWindow", "Current", None))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.testTab), _translate("MainWindow", "Test", None))
It is all executed from emgRun.py
import sys
import numpy as np
import pyqtgraph as pg
from PyQt4 import QtCore, QtGui
from emgesture import EMG_Classify as emg
from emgWindow_ui import Ui_MainWindow
data = emg.dataset
class MyForm(QtGui.QMainWindow):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
myapp = MyForm()
myapp.show()
sys.exit(app.exec_())

PyQt4 form ain't launching

I have made the following code to execute an form made in QtDesigner and converted to a '.py' file. My issue is that when i execute the code, it doesn't really show the form, but there is no message error and it appears an python icon on the toolbar like if it was running the form, i tried launching it from the cmd.exe, but the same stuff happens.PD: I use Sublime Text 3 and Python 3.4.4. Please help, thanks!
from PyQt4 import QtGui
import sys
import form3qt_edit
class Form3(QtGui.QMainWindow, form3qt_edit.Ui_MainWindow):
def __init__(self,parent =None):
super(Form3, self).__init__(parent)
self.setupUi(self)
def main():
app = QtGui.QApplication(sys.argv)
form = Form3()
form.show()
app.exec_()
if __name__ == '__main__':
main()
Code from formqt3_edit.py
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_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName(_fromUtf8("MainWindow"))
MainWindow.resize(710, 450)
MainWindow.setWindowOpacity(-1.0)
MainWindow.setStyleSheet(_fromUtf8("background-color:\'#effec7\';\n"
"border-radius:20px;\n"
"\n"
""))
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
self.tabWidget = QtGui.QTabWidget(self.centralwidget)
self.tabWidget.setGeometry(QtCore.QRect(150, 90, 391, 261))
self.tabWidget.setStyleSheet(_fromUtf8("background-color:\'#effec7\';\n"
"background-color: rgb(211, 207, 157);"))
self.tabWidget.setTabPosition(QtGui.QTabWidget.North)
self.tabWidget.setTabShape(QtGui.QTabWidget.Rounded)
self.tabWidget.setObjectName(_fromUtf8("tabWidget"))
self.tP = QtGui.QWidget()
self.tP.setObjectName(_fromUtf8("tP"))
self.checkBox = QtGui.QCheckBox(self.tP)
self.checkBox.setGeometry(QtCore.QRect(20, 10, 151, 17))
self.checkBox.setObjectName(_fromUtf8("checkBox"))
self.checkBox_2 = QtGui.QCheckBox(self.tP)
self.checkBox_2.setGeometry(QtCore.QRect(20, 40, 141, 17))
self.checkBox_2.setObjectName(_fromUtf8("checkBox_2"))
self.checkBox_3 = QtGui.QCheckBox(self.tP)
self.checkBox_3.setGeometry(QtCore.QRect(20, 70, 141, 17))
self.checkBox_3.setObjectName(_fromUtf8("checkBox_3"))
self.tabWidget.addTab(self.tP, _fromUtf8(""))
self.tC = QtGui.QWidget()
self.tC.setObjectName(_fromUtf8("tC"))
self.checkBox_4 = QtGui.QCheckBox(self.tC)
self.checkBox_4.setGeometry(QtCore.QRect(20, 10, 141, 17))
self.checkBox_4.setObjectName(_fromUtf8("checkBox_4"))
self.checkBox_5 = QtGui.QCheckBox(self.tC)
self.checkBox_5.setGeometry(QtCore.QRect(20, 30, 171, 17))
self.checkBox_5.setObjectName(_fromUtf8("checkBox_5"))
self.checkBox_6 = QtGui.QCheckBox(self.tC)
self.checkBox_6.setGeometry(QtCore.QRect(20, 50, 261, 17))
self.checkBox_6.setObjectName(_fromUtf8("checkBox_6"))
self.checkBox_7 = QtGui.QCheckBox(self.tC)
self.checkBox_7.setGeometry(QtCore.QRect(20, 70, 151, 17))
self.checkBox_7.setObjectName(_fromUtf8("checkBox_7"))
self.checkBox_8 = QtGui.QCheckBox(self.tC)
self.checkBox_8.setGeometry(QtCore.QRect(20, 90, 331, 17))
self.checkBox_8.setObjectName(_fromUtf8("checkBox_8"))
self.checkBox_9 = QtGui.QCheckBox(self.tC)
self.checkBox_9.setGeometry(QtCore.QRect(20, 110, 251, 17))
self.checkBox_9.setObjectName(_fromUtf8("checkBox_9"))
self.checkBox_10 = QtGui.QCheckBox(self.tC)
self.checkBox_10.setGeometry(QtCore.QRect(20, 130, 191, 17))
self.checkBox_10.setObjectName(_fromUtf8("checkBox_10"))
self.checkBox_11 = QtGui.QCheckBox(self.tC)
self.checkBox_11.setGeometry(QtCore.QRect(20, 150, 331, 17))
self.checkBox_11.setObjectName(_fromUtf8("checkBox_11"))
self.checkBox_12 = QtGui.QCheckBox(self.tC)
self.checkBox_12.setGeometry(QtCore.QRect(20, 170, 231, 17))
self.checkBox_12.setObjectName(_fromUtf8("checkBox_12"))
self.checkBox_13 = QtGui.QCheckBox(self.tC)
self.checkBox_13.setGeometry(QtCore.QRect(20, 190, 201, 17))
self.checkBox_13.setObjectName(_fromUtf8("checkBox_13"))
self.checkBox_14 = QtGui.QCheckBox(self.tC)
self.checkBox_14.setGeometry(QtCore.QRect(20, 210, 231, 17))
self.checkBox_14.setObjectName(_fromUtf8("checkBox_14"))
self.tabWidget.addTab(self.tC, _fromUtf8(""))
self.tO = QtGui.QWidget()
self.tO.setObjectName(_fromUtf8("tO"))
self.checkBox_15 = QtGui.QCheckBox(self.tO)
self.checkBox_15.setGeometry(QtCore.QRect(20, 10, 141, 17))
self.checkBox_15.setObjectName(_fromUtf8("checkBox_15"))
self.checkBox_16 = QtGui.QCheckBox(self.tO)
self.checkBox_16.setGeometry(QtCore.QRect(20, 30, 201, 17))
self.checkBox_16.setObjectName(_fromUtf8("checkBox_16"))
self.checkBox_17 = QtGui.QCheckBox(self.tO)
self.checkBox_17.setGeometry(QtCore.QRect(20, 50, 201, 17))
self.checkBox_17.setObjectName(_fromUtf8("checkBox_17"))
self.checkBox_18 = QtGui.QCheckBox(self.tO)
self.checkBox_18.setGeometry(QtCore.QRect(20, 70, 191, 17))
self.checkBox_18.setObjectName(_fromUtf8("checkBox_18"))
self.checkBox_19 = QtGui.QCheckBox(self.tO)
self.checkBox_19.setGeometry(QtCore.QRect(20, 90, 221, 17))
self.checkBox_19.setObjectName(_fromUtf8("checkBox_19"))
self.checkBox_20 = QtGui.QCheckBox(self.tO)
self.checkBox_20.setGeometry(QtCore.QRect(20, 110, 161, 17))
self.checkBox_20.setObjectName(_fromUtf8("checkBox_20"))
self.checkBox_21 = QtGui.QCheckBox(self.tO)
self.checkBox_21.setGeometry(QtCore.QRect(20, 130, 271, 17))
self.checkBox_21.setObjectName(_fromUtf8("checkBox_21"))
self.checkBox_22 = QtGui.QCheckBox(self.tO)
self.checkBox_22.setGeometry(QtCore.QRect(20, 150, 201, 17))
self.checkBox_22.setObjectName(_fromUtf8("checkBox_22"))
self.checkBox_23 = QtGui.QCheckBox(self.tO)
self.checkBox_23.setGeometry(QtCore.QRect(20, 170, 231, 17))
self.checkBox_23.setObjectName(_fromUtf8("checkBox_23"))
self.tabWidget.addTab(self.tO, _fromUtf8(""))
self.tA = QtGui.QWidget()
self.tA.setObjectName(_fromUtf8("tA"))
self.checkBox_24 = QtGui.QCheckBox(self.tA)
self.checkBox_24.setGeometry(QtCore.QRect(30, 10, 171, 17))
self.checkBox_24.setObjectName(_fromUtf8("checkBox_24"))
self.checkBox_25 = QtGui.QCheckBox(self.tA)
self.checkBox_25.setGeometry(QtCore.QRect(30, 50, 121, 17))
self.checkBox_25.setObjectName(_fromUtf8("checkBox_25"))
self.checkBox_26 = QtGui.QCheckBox(self.tA)
self.checkBox_26.setGeometry(QtCore.QRect(30, 70, 111, 17))
self.checkBox_26.setObjectName(_fromUtf8("checkBox_26"))
self.checkBox_27 = QtGui.QCheckBox(self.tA)
self.checkBox_27.setGeometry(QtCore.QRect(30, 30, 241, 17))
self.checkBox_27.setObjectName(_fromUtf8("checkBox_27"))
self.tabWidget.addTab(self.tA, _fromUtf8(""))
self.label = QtGui.QLabel(self.centralwidget)
self.label.setGeometry(QtCore.QRect(230, -10, 211, 41))
font = QtGui.QFont()
font.setFamily(_fromUtf8("Yu Gothic UI Semibold"))
font.setPointSize(14)
font.setBold(True)
font.setWeight(75)
self.label.setFont(font)
self.label.setObjectName(_fromUtf8("label"))
self.plainTextEdit = QtGui.QPlainTextEdit(self.centralwidget)
self.plainTextEdit.setGeometry(QtCore.QRect(140, 30, 411, 51))
font = QtGui.QFont()
font.setFamily(_fromUtf8("Yu Gothic UI Semibold"))
self.plainTextEdit.setFont(font)
self.plainTextEdit.setStyleSheet(_fromUtf8("background-color: \'#effec7\'"))
self.plainTextEdit.setReadOnly(True)
self.plainTextEdit.setBackgroundVisible(True)
self.plainTextEdit.setObjectName(_fromUtf8("plainTextEdit"))
self.pushButton = QtGui.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(270, 370, 141, 23))
self.pushButton.setStyleSheet(_fromUtf8("border-radius:\'20px\';\n"
"background-color:\'#bea575\';\n"
"border-color:\'#e2d2ae\';\n"
""))
self.pushButton.setObjectName(_fromUtf8("pushButton"))
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtGui.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 710, 21))
self.menubar.setObjectName(_fromUtf8("menubar"))
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtGui.QStatusBar(MainWindow)
self.statusbar.setObjectName(_fromUtf8("statusbar"))
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
self.tabWidget.setCurrentIndex(3)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(_translate("MainWindow", "Form3-QtDesigner", None))
self.checkBox.setText(_translate("MainWindow", "Gestión de trámites legales", None))
self.checkBox_2.setText(_translate("MainWindow", "Realización de línea base y estudios técnicos", None))
self.checkBox_3.setText(_translate("MainWindow", "Realización de diseños", None))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tP), _translate("MainWindow", "Planeación", None))
self.checkBox_4.setText(_translate("MainWindow", "Localización y replanteo", None))
self.checkBox_5.setText(_translate("MainWindow", "Adecuación de accesos o vías", None))
self.checkBox_6.setText(_translate("MainWindow", "Instalación de obras provisionales y/o definitivas", None))
self.checkBox_7.setText(_translate("MainWindow", "Explotación de préstamos", None))
self.checkBox_8.setText(_translate("MainWindow", "Ejecución de tratamientos silviculturales y manejo de coberturas", None))
self.checkBox_9.setText(_translate("MainWindow", "Construcción de obras de protección y drenaje", None))
self.checkBox_10.setText(_translate("MainWindow", "Realización de trabajos preliminares", None))
self.checkBox_11.setText(_translate("MainWindow", "Ejecución de cimentaciones, fundaciones, relleno y compactación", None))
self.checkBox_12.setText(_translate("MainWindow", "Levantamiento o instalación de estructuras.", None))
self.checkBox_13.setText(_translate("MainWindow", "Levantamiento o instalación de muros", None))
self.checkBox_14.setText(_translate("MainWindow", "Realización de acabados y obras exteriores", None))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tC), _translate("MainWindow", "Construcción", None))
self.checkBox_15.setText(_translate("MainWindow", "Realización de pruebas", None))
self.checkBox_16.setText(_translate("MainWindow", "Operación obra de infraestructura", None))
self.checkBox_17.setText(_translate("MainWindow", "Reposición de elementos o tramos", None))
self.checkBox_18.setText(_translate("MainWindow", "Reparación de elementos o tramos", None))
self.checkBox_19.setText(_translate("MainWindow", "Limpieza de las instalaciones y elementos", None))
self.checkBox_20.setText(_translate("MainWindow", "Mejoramiento o ampliaciones", None))
self.checkBox_21.setText(_translate("MainWindow", "Limpieza final de la obra e instalaciones temporales", None))
self.checkBox_22.setText(_translate("MainWindow", "Control de emisiones y vertimientos", None))
self.checkBox_23.setText(_translate("MainWindow", "Cobertura o reconformación final del sitio", None))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tO), _translate("MainWindow", "Operación", None))
self.checkBox_24.setText(_translate("MainWindow", "Desmantelamiento/demolición", None))
self.checkBox_25.setText(_translate("MainWindow", "Obras de urbanismo", None))
self.checkBox_26.setText(_translate("MainWindow", "Uso final del sitio", None))
self.checkBox_27.setText(_translate("MainWindow", "Reactivación de un servicio o sistema natural", None))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tA), _translate("MainWindow", "Abandono", None))
self.label.setText(_translate("MainWindow", "Selección de actividades", None))
self.plainTextEdit.setPlainText(_translate("MainWindow", "Por favor, seleccione las actividades de ingeniería que se llevarán a cabo en el proyecto, de acuerdo con la fase del ciclo de vida.\n"
"Luego de la selección, haga clik en el botón \"Seleccionar impactos\"", None))
self.pushButton.setText(_translate("MainWindow", "Seleccionar impactos", None))
Try changing
MainWindow.setWindowOpacity(-1.0)
to
MainWindow.setWindowOpacity(1.0)
From http://doc.qt.io/qt-4.8/qwidget.html#windowOpacity-prop
The valid range of opacity is from 1.0 (completely opaque) to 0.0 (completely transparent).
I tried your code on Ubuntu with Python 2.7.11+ and got the same result as you
it doesn't really show the form, but there is no message error and it
appears an python icon on the toolbar like if it was running the form
but changing this one line fixed the problem
UPDATED: Just tried it on Windows 10, Python 3.4.4, PyQt4, Sublime build 3103. It works with the updated line of code, even from Sublime (using Ctrl + B), with the two files provided with just the one change.

Spawning one window from another window on button click in qt4

I've created two windows using qt4 designer, and would like to link them together. I put them both in a folder and created a file outside the directory, which I'm importing them with.
I can open both windows at the same time, but that's not what I would like to do. I would like to make it so that when a button is pushed on one window, it opens the other window, then closes the first window, so the second window is the only one left open.
This is the code for the first window, with comments next to the button that I would like to have open the other window.
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_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName(_fromUtf8("MainWindow"))
MainWindow.resize(893, 591)
MainWindow.setMinimumSize(QtCore.QSize(893, 591))
MainWindow.setMaximumSize(QtCore.QSize(893, 591))
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(_fromUtf8("images/turbulence.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
MainWindow.setWindowIcon(icon)
MainWindow.setStyleSheet(_fromUtf8(""))
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
self.label_2 = QtGui.QLabel(self.centralwidget)
self.label_2.setGeometry(QtCore.QRect(-10, 50, 911, 581))
self.label_2.setStyleSheet(_fromUtf8("background-color: rgb(0, 0, 0);"))
self.label_2.setText(_fromUtf8(""))
self.label_2.setObjectName(_fromUtf8("label_2"))
self.label = QtGui.QLabel(self.centralwidget)
self.label.setGeometry(QtCore.QRect(-20, -10, 921, 71))
self.label.setStyleSheet(_fromUtf8("background-color: rgb(0, 37, 37);"))
self.label.setText(_fromUtf8(""))
self.label.setPixmap(QtGui.QPixmap(_fromUtf8("images/header.png")))
self.label.setObjectName(_fromUtf8("label"))
self.label_3 = QtGui.QLabel(self.centralwidget)
self.label_3.setGeometry(QtCore.QRect(60, 0, 351, 51))
self.label_3.setStyleSheet(_fromUtf8("font: 20pt \"Sans Serif\";\n"
"color: rgb(0, 221, 221);"))
self.label_3.setObjectName(_fromUtf8("label_3"))
self.label_4 = QtGui.QLabel(self.centralwidget)
self.label_4.setGeometry(QtCore.QRect(-4, 73, 901, 41))
self.label_4.setStyleSheet(_fromUtf8("background-color: rgba(13, 247, 255, 72);"))
self.label_4.setText(_fromUtf8(""))
self.label_4.setObjectName(_fromUtf8("label_4"))
self.label_6 = QtGui.QLabel(self.centralwidget)
self.label_6.setGeometry(QtCore.QRect(110, 80, 31, 31))
self.label_6.setPixmap(QtGui.QPixmap(_fromUtf8("images/arrow.png")))
self.label_6.setObjectName(_fromUtf8("label_6"))
self.pushButton = QtGui.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(10, 80, 101, 31))
self.pushButton.setStyleSheet(_fromUtf8("font: 13pt \"Sans Serif\";\n"
"color: rgb(0, 255, 255);"))
self.pushButton.setFlat(True)
self.pushButton.setObjectName(_fromUtf8("pushButton"))
self.pushButton_2 = QtGui.QPushButton(self.centralwidget)
self.pushButton_2.setGeometry(QtCore.QRect(140, 80, 81, 31))
self.pushButton_2.setStyleSheet(_fromUtf8("font: 12pt \"Sans Serif\";\n"
"color: rgb(0, 255, 255);"))
self.pushButton_2.setFlat(True)
self.pushButton_2.setObjectName(_fromUtf8("pushButton_2"))
self.label_5 = QtGui.QLabel(self.centralwidget)
self.label_5.setGeometry(QtCore.QRect(6, 3, 51, 51))
self.label_5.setText(_fromUtf8(""))
self.label_5.setPixmap(QtGui.QPixmap(_fromUtf8("images/turbulence.png")))
self.label_5.setObjectName(_fromUtf8("label_5"))
self.label_7 = QtGui.QLabel(self.centralwidget)
self.label_7.setGeometry(QtCore.QRect(20, 150, 491, 91))
self.label_7.setStyleSheet(_fromUtf8("font: 30pt \"Sans Serif\";\n"
"color: rgb(0, 191, 191);"))
self.label_7.setObjectName(_fromUtf8("label_7"))
self.label_8 = QtGui.QLabel(self.centralwidget)
self.label_8.setGeometry(QtCore.QRect(60, 240, 831, 271))
self.label_8.setStyleSheet(_fromUtf8("color: rgb(0, 191, 191);\n"
"font: 10pt \"Sans Serif\";"))
self.label_8.setObjectName(_fromUtf8("label_8"))
self.label_9 = QtGui.QLabel(self.centralwidget)
self.label_9.setGeometry(QtCore.QRect(60, 350, 21, 21))
self.label_9.setPixmap(QtGui.QPixmap(_fromUtf8("images/bullet.png")))
self.label_9.setObjectName(_fromUtf8("label_9"))
self.label_10 = QtGui.QLabel(self.centralwidget)
self.label_10.setGeometry(QtCore.QRect(60, 380, 21, 21))
self.label_10.setPixmap(QtGui.QPixmap(_fromUtf8("images/bullet.png")))
self.label_10.setObjectName(_fromUtf8("label_10"))
self.label_11 = QtGui.QLabel(self.centralwidget)
self.label_11.setGeometry(QtCore.QRect(60, 410, 21, 21))
self.label_11.setPixmap(QtGui.QPixmap(_fromUtf8("images/bullet.png")))
self.label_11.setObjectName(_fromUtf8("label_11"))
self.label_12 = QtGui.QLabel(self.centralwidget)
self.label_12.setGeometry(QtCore.QRect(60, 450, 21, 31))
self.label_12.setPixmap(QtGui.QPixmap(_fromUtf8("images/bullet.png")))
self.label_12.setObjectName(_fromUtf8("label_12"))
self.label_13 = QtGui.QLabel(self.centralwidget)
self.label_13.setGeometry(QtCore.QRect(-10, 550, 911, 51))
self.label_13.setStyleSheet(_fromUtf8("background-color: rgba(13, 247, 255, 72);"))
self.label_13.setText(_fromUtf8(""))
self.label_13.setObjectName(_fromUtf8("label_13"))
self.pushButton_3 = QtGui.QPushButton(self.centralwidget)
self.pushButton_3.setGeometry(QtCore.QRect(818, 560, 71, 21))
icon1 = QtGui.QIcon()
icon1.addPixmap(QtGui.QPixmap(_fromUtf8("images/arrow.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.pushButton_3.setIcon(icon1)
self.pushButton_3.setIconSize(QtCore.QSize(20, 20))
self.pushButton_3.setObjectName(_fromUtf8("pushButton_3"))
self.pushButton_4 = QtGui.QPushButton(self.centralwidget)
self.pushButton_4.setGeometry(QtCore.QRect(10, 560, 71, 23))
icon2 = QtGui.QIcon()
icon2.addPixmap(QtGui.QPixmap(_fromUtf8("images/cancel.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.pushButton_4.setIcon(icon2)
self.pushButton_4.setObjectName(_fromUtf8("pushButton_4"))
MainWindow.setCentralWidget(self.centralwidget)
self.retranslateUi(MainWindow)
QtCore.QObject.connect(self.pushButton_4, QtCore.SIGNAL(_fromUtf8("clicked()")), MainWindow.close)
QtCore.QObject.connect(self.pushButton_2, QtCore.SIGNAL(_fromUtf8("clicked()")), MainWindow.close) #This button
QtCore.QObject.connect(self.pushButton_3, QtCore.SIGNAL(_fromUtf8("clicke
import sysd()")), MainWindow.close) #And this button too.
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(_translate("MainWindow", "Turbulence", None))
self.label_3.setText(_translate("MainWindow", "label3", None))
self.pushButton.setText(_translate("MainWindow", "Welcome", None))
self.pushButton_2.setText(_translate("MainWindow", "Folders", None))
self.label_7.setText(_translate("MainWindow", "label7", None))
self.label_8.setText(_translate("MainWindow", "label8", None))
self.pushButton_3.setText(_translate("MainWindow", "Next", None))
self.pushButton_4.setText(_translate("MainWindow", "Cancel", None))
And this is the code for the second window
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_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName(_fromUtf8("MainWindow"))
MainWindow.resize(893, 591)
MainWindow.setMinimumSize(QtCore.QSize(893, 591))
MainWindow.setMaximumSize(QtCore.QSize(893, 591))
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(_fromUtf8("images/turbulence.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
MainWindow.setWindowIcon(icon)
MainWindow.setStyleSheet(_fromUtf8(""))
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
self.label_2 = QtGui.QLabel(self.centralwidget)
self.label_2.setGeometry(QtCore.QRect(-10, 50, 911, 581))
self.label_2.setStyleSheet(_fromUtf8("background-color: rgb(0, 0, 0);"))
self.label_2.setText(_fromUtf8(""))
self.label_2.setObjectName(_fromUtf8("label_2"))
self.label = QtGui.QLabel(self.centralwidget)
self.label.setGeometry(QtCore.QRect(-20, -10, 921, 71))
self.label.setStyleSheet(_fromUtf8("background-color: rgb(0, 37, 37);"))
self.label.setText(_fromUtf8(""))
self.label.setPixmap(QtGui.QPixmap(_fromUtf8("../images/header.png")))
self.label.setObjectName(_fromUtf8("label"))
self.label_3 = QtGui.QLabel(self.centralwidget)
self.label_3.setGeometry(QtCore.QRect(60, 0, 351, 51))
self.label_3.setStyleSheet(_fromUtf8("font: 20pt \"Sans Serif\";\n"
"color: rgb(0, 221, 221);"))
self.label_3.setObjectName(_fromUtf8("label_3"))
self.label_4 = QtGui.QLabel(self.centralwidget)
self.label_4.setGeometry(QtCore.QRect(-4, 73, 901, 41))
self.label_4.setStyleSheet(_fromUtf8("background-color: rgba(13, 247, 255, 72);"))
self.label_4.setText(_fromUtf8(""))
self.label_4.setObjectName(_fromUtf8("label_4"))
self.label_6 = QtGui.QLabel(self.centralwidget)
self.label_6.setGeometry(QtCore.QRect(100, 80, 31, 31))
self.label_6.setPixmap(QtGui.QPixmap(_fromUtf8("../images/arrow.png")))
self.label_6.setObjectName(_fromUtf8("label_6"))
self.pushButton = QtGui.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(10, 80, 91, 31))
self.pushButton.setStyleSheet(_fromUtf8("font: 13pt \"Sans Serif\";\n"
"color: rgb(0, 255, 255);"))
self.pushButton.setFlat(True)
self.pushButton.setObjectName(_fromUtf8("pushButton"))
self.pushButton_2 = QtGui.QPushButton(self.centralwidget)
self.pushButton_2.setGeometry(QtCore.QRect(130, 80, 91, 31))
self.pushButton_2.setStyleSheet(_fromUtf8("font: 12pt \"Sans Serif\";\n"
"color: rgb(0, 255, 255);"))
self.pushButton_2.setFlat(True)
self.pushButton_2.setObjectName(_fromUtf8("pushButton_2"))
self.label_5 = QtGui.QLabel(self.centralwidget)
self.label_5.setGeometry(QtCore.QRect(6, 3, 51, 51))
self.label_5.setText(_fromUtf8(""))
self.label_5.setPixmap(QtGui.QPixmap(_fromUtf8("../images/turbulence.png")))
self.label_5.setObjectName(_fromUtf8("label_5"))
self.label_13 = QtGui.QLabel(self.centralwidget)
self.label_13.setGeometry(QtCore.QRect(-10, 550, 911, 51))
self.label_13.setStyleSheet(_fromUtf8("background-color: rgba(13, 247, 255, 72);"))
self.label_13.setText(_fromUtf8(""))
self.label_13.setObjectName(_fromUtf8("label_13"))
self.pushButton_3 = QtGui.QPushButton(self.centralwidget)
self.pushButton_3.setGeometry(QtCore.QRect(818, 560, 71, 21))
icon1 = QtGui.QIcon()
icon1.addPixmap(QtGui.QPixmap(_fromUtf8("../images/arrow.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.pushButton_3.setIcon(icon1)
self.pushButton_3.setIconSize(QtCore.QSize(20, 20))
self.pushButton_3.setObjectName(_fromUtf8("pushButton_3"))
self.pushButton_4 = QtGui.QPushButton(self.centralwidget)
self.pushButton_4.setGeometry(QtCore.QRect(10, 560, 71, 23))
icon2 = QtGui.QIcon()
icon2.addPixmap(QtGui.QPixmap(_fromUtf8("../images/cancel.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.pushButton_4.setIcon(icon2)
self.pushButton_4.setObjectName(_fromUtf8("pushButton_4"))
self.pushButton_5 = QtGui.QPushButton(self.centralwidget)
self.pushButton_5.setGeometry(QtCore.QRect(720, 560, 91, 21))
icon3 = QtGui.QIcon()
icon3.addPixmap(QtGui.QPixmap(_fromUtf8("../images/arrowreverse.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.pushButton_5.setIcon(icon3)
self.pushButton_5.setIconSize(QtCore.QSize(20, 20))
self.pushButton_5.setObjectName(_fromUtf8("pushButton_5"))
MainWindow.setCentralWidget(self.centralwidget)
self.retranslateUi(MainWindow)
QtCore.QObject.connect(self.pushButton_4, QtCore.SIGNAL(_fromUtf8("clicked()")), MainWindow.close)
QtCore.QObject.connect(self.pushButton_2, QtCore.SIGNAL(_fromUtf8("clicked()")), MainWindow.close)
QtCore.QObject.connect(self.pushButton_3, QtCore.SIGNAL(_fromUtf8("clicked()")), MainWindow.close)
QtCore.QObject.connect(self.pushButton_5, QtCore.SIGNAL(_fromUtf8("clicked()")), MainWindow.close)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(_translate("MainWindow", "Turbulence", None))
self.label_3.setText(_translate("MainWindow", "Customize Your Desktop", None))
self.pushButton.setText(_translate("MainWindow", "Folders", None))
self.pushButton_2.setText(_translate("MainWindow", "Themes", None))
self.pushButton_3.setText(_translate("MainWindow", "Next", None))
self.pushButton_4.setText(_translate("MainWindow", "Cancel", None))
self.pushButton_5.setText(_translate("MainWindow", "Previous", None))
I think the way to do this might be to create a function which opens the second window, then closes the first, but I'm not sure if I should put this in the file I'm using to import these two windows, or the first window.
I can hook up the buttons to a function that would normally open up the other window, but when I click on the button nothing happens.
Thanks for any help.
You really need to reconsider the design of your application.
Opening and closing multiple main windows in the manner you describe is ugly and completely unnecessary. Instead, you should have one main window and use a QStackedWidget to hold a sequence of pages that can navigated through using buttons.
To experiment with this idea, create a new main window in Qt Designer and add a QStackedWidget to it (it's in the "Containers" section). Then open the two UIs you've already designed, and copy the widgets of each UI into separate pages of the stacked-widget.
Once you've done that, make sure you give all the widgets descriptive names, because you will need to refer to them later when you start writing the logic for your program. The main script of your application should look something like this:
from PyQt4 import QtCore, QtGui
from mainwindow_ui import Ui_MainWindow
class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
def __init__(self):
super(MainWindow, self).__init__()
self.setupUi(self)
...
self.buttonNext.clicked.connect(self.handleButtonNext)
self.buttonPrev.clicked.connect(self.handleButtonPrev)
def handleButtonNext(self):
index = self.stackedWidget.currentIndex() + 1
if index < self.stackedWidget.count():
self.stackedWidget.setCurrentWidget(index)
def handleButtonPrev(self):
index = self.stackedWidget.currentIndex() - 1
if index >= 0:
self.stackedWidget.setCurrentWidget(index)
if __name__ == '__main__':
import sys
app = QtGui.QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec_())
Obviously, the real logic for your program will be more sophisticated than this, but it should give you a general idea of how to go about things.
PS:
I have never used it myself, but you might also want to see if the QWizard class might be more suitable for your needs.
Your question don't show much context but it seems you are new at PyQt and PyUIC tools.
That you post aren't (or not should be) the real windows of your app. Those class are generated for pyuic or pyuic4.
You must have something like:
class RealWindow(QMainWindow):
def __init__(parent=None):
super(RealWindow, self).__init__(parent) # Call QMainWindow constructor.
self.__ui = UI_MainWindow() # Here is when you should use that class.
self.__ui.setupUI(self) # And apply the properties to yout actual window
def on_some_button_clicked(*args, **args) # And here is where you do whatever you want to do when you press a button.
On the other hand, I'm not sure is a good idea having two main windows in the same app. I don't know even if Qt allow that at all.
I recommend you build one of your windows as a QDialog. Or build a single window with a set of controls you can hide or show at will.
I also recommend you: a pyqt tutorial

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