Create an application
| Run an application | Index | Widgets |
On this page... (hide)
1. Basics
A typical PyMT application is looking like this :
from pymt import * # # CODE APPLICATION # if __name__ == '__main__': # # UI CREATION # runTouchApp(ui)
In the "CODE APPLICATION" placeholder, you can add all your classes / functions / widgets. In the "UI CREATION" placeholder, you create object, and assemble them to make the application.
The line if __name__ == '__main__': is not mandatory. It's the python way to do it, because your file can be directly executed, or can be imported. If your file is beeing imported, you must not create the ui :)
2. Import PyMT
from pymt import *
The import line will import the whole PyMT framework into your application. It's not currently possible to import only part of it.
At import, PyMT create the initial window, according to your Configuration file. With this, you are able to execute OpenGL code at initialization.
3. Running the mainloop
runTouchApp(ui)
The runTouchApp() function is running the mainloop. The mainloop is :
- clear the current window
- walk your widget tree for update and draw widgets in background
- flip window from background to foreground
You can pass in runTouchApp() your root widget to use in the window. Without root widget, you'll never see anything on the window :).
Example of a simple PyMT application :
from pymt import * if __name__ == '__main__': root = MTScatterWidget() runTouchApp(root)
