Python started to learn the basic structure of the program --PyQt5

In learning python GUI part, I began to read a bit ignorant, can not read the framework, the following is a personal income study (refer to someone else's video to explain), mistakes, hope you enlighten 


# 0. Package and module import needs
from PyQt5 .Qt import * #Qt comprising common package and module
import sys

# Create the application object, 
the role of # sys.argv: our code to execute when there are two methods, one right-click execution, 2 command line python code name.
# After executing this command-line program, through the implementation of this different parameters passed script to perform different logic (transfer medium corresponding to the sys.argv parameter)

# 1. Create an application object, when other files you want to call in the command line parameter app can be invoked by qApp, global variables as it should be in PyQt5 defined
app = QApplication (sys.argv)
# Print (app.arguments ())
#Print (qApp.arguments ())



# 2. controls operation
# create controls, but can set its properties (handle position, size, style, events, signals ...) #
2.1 create the control
window = QWidget ()

# 2.2 set control properties
window.setWindowTitle ( "window frame")
window.resize (400, 500)
window.move (400, 200)

label = QLabel (window)
label.setText ( "the I like Python")
label .move (200, 200)
# display control (Once you create a control, if the control has no parent control is not displayed, the need to manually call the show () by default)
window.show ()

# 3. execute the application object, and enter message loop
#exit program exits normal exit code of 0
the sys.exit (app.exec_ ())

result:



On the command line, using pycharm software, click on the toolbar below Terminal, enter "python + file name + parameters you want to convey" in the middle
* PyQt5.Qt Import from 
Import SYS
# passes this command line program, various parameters by executing the script passed to perform different logic
args = the sys.argv
Print (args)
IF args [. 1] == '. 1 ':
Print ( "XXX")
the else:
Print ( "yyy")




Guess you like

Origin www.cnblogs.com/fqkang/p/11209122.html