QT代码,运行程序时没有任何反应

2024-04-20 06:39:53 发布

您现在位置:Python中文网/ 问答频道 /正文

我现在正在学习qt,我有一个问题,就是为什么我的代码不能像我希望的那样工作。 它只是不输出任何东西。没有窗口显示,测试打印语句甚至没有显示,只是虚无

尴尬的是,代码返回退出代码0,PyCharm中没有明显的问题,我迷路了。我咨询了几个朋友,但他们都没能帮我解决这个问题。你知道吗

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

Tags: 代码importselfinitdefsysprintqapplication