'The window i made with qt designer doesn't show up
I made this window using qt designer i did not add the code that downloads the songs yet but when I run it the window doest show up
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MuziekDownloader(object):
def setupUi(self, MuziekDownloader):
MuziekDownloader.setObjectName("MuziekDownloader")
MuziekDownloader.resize(640, 480)
self.centralwidget = QtWidgets.QWidget(MuziekDownloader)
self.centralwidget.setObjectName("centralwidget")
self.PageSwitcher = QtWidgets.QTabWidget(self.centralwidget)
self.PageSwitcher.setGeometry(QtCore.QRect(0, 0, 651, 501))
self.PageSwitcher.setObjectName("PageSwitcher")
self.Spotify = QtWidgets.QWidget()
self.Spotify.setObjectName("Spotify")
self.ConfirmSpotify = QtWidgets.QPushButton(self.Spotify)
self.ConfirmSpotify.setGeometry(QtCore.QRect(190, 210, 261, 41))
font = QtGui.QFont()
font.setPointSize(14)
font.setBold(True)
font.setWeight(75)
self.ConfirmSpotify.setFont(font)
self.ConfirmSpotify.setObjectName("ConfirmSpotify")
self.Bynametextlabel_2 = QtWidgets.QLabel(self.Spotify)
self.Bynametextlabel_2.setGeometry(QtCore.QRect(260, 30, 91, 41))
font = QtGui.QFont()
font.setPointSize(15)
font.setBold(True)
font.setWeight(75)
self.Bynametextlabel_2.setFont(font)
self.Bynametextlabel_2.setToolTipDuration(0)
self.Bynametextlabel_2.setObjectName("Bynametextlabel_2")
self.InputSpotify = QtWidgets.QTextEdit(self.Spotify)
self.InputSpotify.setGeometry(QtCore.QRect(60, 90, 501, 41))
self.InputSpotify.setObjectName("InputSpotify")
self.PageSwitcher.addTab(self.Spotify, "")
self.Youtube = QtWidgets.QWidget()
self.Youtube.setObjectName("Youtube")
self.ConfirmYoutube = QtWidgets.QPushButton(self.Youtube)
self.ConfirmYoutube.setGeometry(QtCore.QRect(190, 210, 261, 41))
font = QtGui.QFont()
font.setPointSize(14)
font.setBold(True)
font.setWeight(75)
self.ConfirmYoutube.setFont(font)
self.ConfirmYoutube.setObjectName("ConfirmYoutube")
self.InputYoutube = QtWidgets.QTextEdit(self.Youtube)
self.InputYoutube.setGeometry(QtCore.QRect(60, 90, 501, 41))
self.InputYoutube.setObjectName("InputYoutube")
self.Bynametextlabel_3 = QtWidgets.QLabel(self.Youtube)
self.Bynametextlabel_3.setGeometry(QtCore.QRect(260, 30, 91, 41))
font = QtGui.QFont()
font.setPointSize(15)
font.setBold(True)
font.setWeight(75)
self.Bynametextlabel_3.setFont(font)
self.Bynametextlabel_3.setToolTipDuration(0)
self.Bynametextlabel_3.setObjectName("Bynametextlabel_3")
self.PageSwitcher.addTab(self.Youtube, "")
self.Soundcloud = QtWidgets.QWidget()
self.Soundcloud.setObjectName("Soundcloud")
self.ConfirmSoundcloud = QtWidgets.QPushButton(self.Soundcloud)
self.ConfirmSoundcloud.setGeometry(QtCore.QRect(190, 210, 261, 41))
font = QtGui.QFont()
font.setPointSize(14)
font.setBold(True)
font.setWeight(75)
self.ConfirmSoundcloud.setFont(font)
self.ConfirmSoundcloud.setObjectName("ConfirmSoundcloud")
self.InputSoundcloud = QtWidgets.QTextEdit(self.Soundcloud)
self.InputSoundcloud.setGeometry(QtCore.QRect(60, 90, 501, 41))
self.InputSoundcloud.setObjectName("InputSoundcloud")
self.Bynametextlabel_4 = QtWidgets.QLabel(self.Soundcloud)
self.Bynametextlabel_4.setGeometry(QtCore.QRect(260, 30, 91, 41))
font = QtGui.QFont()
font.setPointSize(15)
font.setBold(True)
font.setWeight(75)
self.Bynametextlabel_4.setFont(font)
self.Bynametextlabel_4.setToolTipDuration(0)
self.Bynametextlabel_4.setObjectName("Bynametextlabel_4")
self.PageSwitcher.addTab(self.Soundcloud, "")
MuziekDownloader.setCentralWidget(self.centralwidget)
self.retranslateUi(MuziekDownloader)
self.PageSwitcher.setCurrentIndex(0)
QtCore.QMetaObject.connectSlotsByName(MuziekDownloader)
def retranslateUi(self, MuziekDownloader):
_translate = QtCore.QCoreApplication.translate
MuziekDownloader.setWindowTitle(_translate("MuziekDownloader", "MainWindow"))
self.ConfirmSpotify.setText(_translate("MuziekDownloader", "Confirm"))
self.Bynametextlabel_2.setText(_translate("MuziekDownloader", "By URL"))
self.PageSwitcher.setTabText(self.PageSwitcher.indexOf(self.Spotify), _translate("MuziekDownloader", "Spotify"))
self.ConfirmYoutube.setText(_translate("MuziekDownloader", "Confirm"))
self.Bynametextlabel_3.setText(_translate("MuziekDownloader", "By URL"))
self.PageSwitcher.setTabText(self.PageSwitcher.indexOf(self.Youtube), _translate("MuziekDownloader", "Youtube"))
self.ConfirmSoundcloud.setText(_translate("MuziekDownloader", "Confirm"))
self.Bynametextlabel_4.setText(_translate("MuziekDownloader", "By URL"))
self.PageSwitcher.setTabText(self.PageSwitcher.indexOf(self.Soundcloud), _translate("MuziekDownloader", "Soundcloud"))
Coudl someone please help me with this problem cause I already looked at other post and I just couldn't find any solution, or send me links of videos/post where I can find how to fix this. Thanks I advance for any helpers.
Solution 1:[1]
The file you generated has to be read and executed through another script, with a class that inherits the generated file
try to create a new script and import this file generated by QT and run the script created with this code
from PyQt5.QtWidgets import(QApplication, QMainWindow)
from 'file generated by QT' import Ui_MuziekDownloader
import sys
class MainWindow(QMainWindow, Ui_MuziekDownloader):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent=parent)
self.setupUi(self)
self.show()
if __name__ == "__main__":
app = QApplication(sys.argv)
w = MainWindow()
#here the functions of your program will be executed
w.show()
sys.exit(app.exec_())
or you can add to the last line of your generated script
from PyQt5.QtWidgets import(QApplication, QMainWindow)
import sys
class MainWindow(QMainWindow, Ui_MuziekDownloader):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent=parent)
self.setupUi(self)
self.show()
if __name__ == "__main__":
app = QApplication(sys.argv)
w = MainWindow()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |