Qt designer window not showing
-
HI. Have been playing around with PyQt5 tutorials. Discovered Qt Designer. Designed a basic layout, again following a tutorial. Cannot get it to show. Any pointers? What am I missing?
Thanks
Program:
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QDialog, QApplication, QWidgetclass Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(800, 600)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.combox = QtWidgets.QComboBox(self.centralwidget)
self.combox.setGeometry(QtCore.QRect(40, 120, 111, 31))
font = QtGui.QFont()
font.setPointSize(10)
self.combox.setFont(font)
self.combox.setObjectName("combox")
self.combox.addItem("")
self.combox.addItem("")
self.comboy = QtWidgets.QComboBox(self.centralwidget)
self.comboy.setGeometry(QtCore.QRect(230, 120, 111, 31))
font = QtGui.QFont()
font.setPointSize(10)
self.comboy.setFont(font)
self.comboy.setObjectName("comboy")
self.comboy.addItem("")
self.comboy.addItem("")
self.Submit = QtWidgets.QPushButton(self.centralwidget)
self.Submit.setGeometry(QtCore.QRect(140, 410, 111, 31))
font = QtGui.QFont()
font.setPointSize(10)
self.Submit.setFont(font)
self.Submit.setObjectName("Submit")
self.label = QtWidgets.QLabel(self.centralwidget)
self.label.setGeometry(QtCore.QRect(130, 250, 141, 61))
font = QtGui.QFont()
font.setPointSize(12)
self.label.setFont(font)
self.label.setObjectName("label")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 21))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) self.InitUI_MainWindow() def retranslateUi(self, MainWindow): _translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) self.combox.setItemText(0, _translate("MainWindow", "0")) self.combox.setItemText(1, _translate("MainWindow", "1")) self.comboy.setItemText(0, _translate("MainWindow", "0")) self.comboy.setItemText(1, _translate("MainWindow", "1")) self.Submit.setText(_translate("MainWindow", "Submit")) self.label.setText(_translate("MainWindow", "x xor y ="))
if name == "main":
import sys
app = QtWidgets.QApplication(sys.argv)
Ui_MainWindow = QtWidgets.QMainWindow
ui = Ui_MainWindow()
sys.exit(app.exec_()) -
Hi and welcome to devnet,
From a quick look you don't call the show method of your UI_MainWindow object anywhere, therefore nothing is shown.
-