Success Stories:
Design window
#-*-coding:utf-8-*-#Form Implementation generated from reading UI file ' Day2.ui '##Created by:pyqt5 UI code generator 5.4.1##warning! All changes made in this file would be lost! fromPyQt5ImportQtcore, Qtgui, QtwidgetsclassUi_form (object):defsetupui (Self, Form): Form.setobjectname ("Form") Form.resize (400, 300) Self.lineedit=Qtwidgets.qlineedit (Form) self.lineEdit.setGeometry (Qtcore.qrect (140, 100, 113, 20)) Self.lineEdit.setObjectName ("LineEdit") Self.retranslateui (form) QtCore.QMetaObject.connectSlotsByName (form)defRetranslateui (Self, Form): _translate=QtCore.QCoreApplication.translate Form.setwindowtitle (_translate ("Form","Form"))if __name__=="__main__": Importsys app=qtwidgets.qapplication (sys.argv) widget=qtwidgets.qwidget () UI=ui_form () ui.setupui ((widget)) widget.show () Sys.exit (App.exec_ ())
Business code:
ImportSYS fromPyqt5.qtwidgetsImportQapplication,qwidget fromDay2ImportUi_formclassMyForm (qwidget,ui_form):def __init__(self): Super ().__init__() self.setupui (self)#Self.lineEdit.textChanged.connect (Self.label.setText) if __name__=='__main__': App=qapplication (SYS.ARGV) W=MyForm () w.show () app.exec_ ( )
Python_ Design and business separation