简体   繁体   中英

QT code, nothing happens when I run the program

I am learning qt at the moment and I have an issue of comprehending why my code does not work as I want it to. It simply does not output anything. No window showing up, the test print statements are not even shown, just nothingness

The awkward thing is, the code returns the exit code 0, there are no obvious problems in PyCharm to be seen and I am lost. I consulted a couple of friends, but neither one of them was able to help me out with this.

from PySide.QtGui import QWidget, QApplication, QCheckBox, QPushButton, QPixmap, QLabel, QRadioButton
import sys

class ersteklasse(QWidget):
    def __init__(self):
        super(ersteklasse, self).__init__()
        self.initGui()
        self.initButton()

        print "I am there"

    def initGui(self):
        self.setGeometry(0, 0, 800, 600)
        self.setWindowTitle('Henris kleines Programm')
        filepath = '/Users/henrinehlsen/Desktop/KaNe_Logo_TEST_PORTFOLIOBOX.png'
        pix1 = QPixmap(filepath)
        self.img1 = QLabel
        self.img1.setPixmap(pix1)

        print "me too!"

    def initButton(self):
        self.Button1 = QRadioButton("Nope", self)
        self.Button1.move(100, 100)

if __name__ == "main":
    app = QApplication
    ErstesProgramm = ersteklasse()
    ErstesProgramm.show()
    sys.exit(app.exec_())
if __name__ == "main":

应该读

if __name__ == "__main__":

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM