In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the relevant knowledge of "what is the method of python optical simulation PyQt5 basic framework". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
This article starts with the basic framework when PyQt5 was created. The code is as follows:
#-*-coding:utf-8-*-import sysfrom PyQt5.QtWidgets import QMainWindow, QApplicationclass MainWindow (QMainWindow): def _ _ init__ (self, parent=None): super (MainWindow, self). _ init__ (parent) self.resize (600,300) self.status = self.statusBar () self.status.showMessage ("this is a status prompt" 10000) self.setWindowTitle ("MainWindow interface") if _ _ name__ = ='_ main__': app = QApplication (sys.argv) window = MainWindow () window.show () sys.exit (app.exec_ ())
The above is the basic framework of our PyQt5 main interface, first create a class, use this class to inherit the QMainWindow class.
Interpretation of other statements:
Self.resize (600300): resize the MainWindow, 600 pixels horizontally and 300 pixels longitudinally.
Self.status = self.statusBar (): create a status bar object
Self.status.showMessage ("this is the status prompt", 10000): displays the status bar information for 10000 milliseconds, that is, 10 seconds, in which the first string parameter "this is the status prompt" is the information finally displayed in the status bar, which we are free to replace.
Note: this status message is displayed only when our mouse hovers in the MainWindow window, and if we want the status bar to display a message all the time, we can change the 10000 of the second parameter to-1.
Self.setWindowTitle ("MainWindow interface"): sets the name of the MainWindow main interface.
App = QApplication (sys.argv): initialize the various parts of the PyQt5, after which we can invoke the various elements in the module. Similar to the Initialization part of the Pygame module.
Sys.argv: this statement exists only so that we can write parameters to read on the command line in the future. If we don't consider making a direct call on the command line, we can change the initialization program to app = QApplication ([]).
Window = MainWindow (): instantiate the window class object that we defined.
Window.show (): this sentence must exist, otherwise the Gui interface we wrote at run time will not be displayed.
Used to display the Gui interface we wrote.
Sys.exit (app.exec_ ()): sys.exit () means to exit the program. App.exec_ () is similar to Mainloop () when the Gui interface is defined in the tkinter module, that is, the main loop body begins to execute. With the sys.exit () exit command, the memory can be emptied when we exit the program to achieve clean mode.
The final running results are as follows:
This is the end of the content of "what is the method of PyQt5 basic framework for python optical simulation". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.