我的PyQt程序崩溃了,我也不知道为什么

时间:2019-06-27 18:26:18

标签: python pyqt pyqt5

我是pyqt和class的新手,我在脑子上做了个例子,即使似乎没有问题,它也崩溃了,没有任何错误,我也不知道该怎么做。

import sys
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *

class win(QWidget):
    def __init__(self,parent=None):
        super(win,self).__init__(parent)


        la=QFormLayout()
        self.b1=QPushButton("Giriş için tıklayın")
        self.b1.clicked.connect(self.getitem)

        self.le=QLineEdit()
        la.addRow(self.b1,self.le)
        self.setLayout(la)
    def getitem(self):
        items=("1","2")

        item, ok=QInputDialog.getItem(self,"Personel numarası seçin","Personel No",items,0,False)




        if ok and item=="1":
            self.le.setItem(item)
            win2().show()
        elif ok and item=="2":
            self.le.setItem(item)
            win3().show()
        else:
            print("?!")


class win2(QWidget):
    def __init__(self,parent=None):
        super(win2,self).__init__(parent)

        la1=QHBoxLayout
        self.l1=QLabel(p1.bilgi())
        self.b2=QPushButton("Tamam")
        la1.addRow(self.b2,self.l1)
        self.setLayout(la1)
        self.b3.clicked.connect(self.closed)
    def closed(self):
        app.exit()




class win3(QWidget):
    def __init__(Self,parent=None):
        super(win3,self).__init__(parent)

        la2=QHBoxLayout
        self.l2=QLabel(p2.bilgi())
        self.b3=QPushButton("Tamam")
        la2.addRow(self.b3,self.l2)
        self.setLayout(la2)
        self.b3.clicked.connect(self.closed)
    def closed(self):
        app.exit()

class Personel:
    def __init__(self,ad,soyad,maas):
        self.ad=ad
        self.soyad=soyad
        self.maas=maas
        self.eposta=ad + "_" + soyad + "@sirket.com"
    def bilgi(self):
        return "{}{}{}{}".format(self.ad,self.soyad,self.maas,self.eposta)
p1=Personel("Ahmet","Acar",50000)
P2=Personel("...","...",1)


def main():
    app=QApplication(sys.argv)
    ex=win()
    ex.show()
    sys.exit(app.exec_())
if __name__=='__main__':
    main()

0 个答案:

没有答案