User Manual

61
2. Programing the Functions
Now the interface design is finished. However, the interface files are just some static images
and cannot be put into use. So the next step, write the client.py to implement all the
interfaces with the corresponding functions as well as redirections. The PyQt is like this:
In Line 5, enter the name of the ui file you designed in the quotation marks.
In Lin 7e, "uic" is the contents in the previously imported PyQt; the built-in function loads the
ui files.
In Line 9-13, the class defined is just your GUI window. Define (def) the corresponding
functions in the class and write the functions in them. The first def __init __ (self) is the
initialization function which is a constructor in C++. It means when the instance is created,
the program will run the code and initialize the instance.
Line 15-19 is the entry of the __main__ function, where it starts to execute the whole program.
So here's how the program goes:
1. Run the __main__ function and create an instance app of QApplication, which is the GUI
application.
2. Create an instance window of the MyApp class type. After the creation is done, run the
__init__ initialization function of the class.
3. The window instance is displayed.
4. Wait for a while. If the instance app of the GUI application sends an exit signal app.exec_(),
then enter sys.exit() to exit Python.