<> One preface

After the previous one QT Introductory articles , Readers should be QT There's a simple concept , This article is about separating windows from business logic , Reduce coupling ;

Knowledge seeker (Inheriting the spirit of open source, Spreading technology knowledge;)

<> Two Separate code

First of all, use the idea of object-oriented , inherit QWidget, If multiple components , Multiple inheritance can be used ;
def __init__(self, parent=None): super().__init__(parent)
Next, define number initialization gui Content of , take gui Method into the constructor to initialize ;

At last _main_ Call in , It realizes the separation of interface and business logic
# -*- coding: utf-8 -*- import sys from PyQt5.QtWidgets import QApplication,
QWidgetfrom PyQt5.QtGui import QIcon """ With window icon """ class Windos(QWidget): def
__init__(self): # Inherit parent method super().__init__() # initialization gui self.init_gui() def
init_gui(self): # Set the location and size of the pop-up window , amount to move + resize self.setGeometry(500, 500, 250,
300) # Set title self.setWindowTitle(' Knowledge seeker ') # Set window icon self.setWindowIcon(QIcon(
'zszxz.png')) # display self.show() if __name__ == '__main__': # Basic module app =
QApplication(sys.argv) # Call object ex = Windos() # Loop exit sys.exit(app.exec_())
The display is as follows , The mainstream is single inheritance

©2019-2020 Toolsou All rights reserved,
Python Basic knowledge and notes Programmer Tanabata Valentine's Day confession code NOI2019 travels China's longest high speed rail officially opened ! The fastest way to finish the race 30.5 hour C Language programming to find a student's grade Software testing BUG describe ESP8266/ESP32 System : Optimize system startup time Unity Scene loading asynchronously ( Implementation of loading interface ) Baidu , Ali , Tencent's internal position level and salary structure , With job suggestions !PYTHON Summary of final review