class root.RootWidget(Widget)
For the GUI to function, there must be exactly one instance of
RootWidget. It implements the main event loop and serves as the
ultimate container for all other visible widgets.
The root widget can be found using the get_root() function of the root module.
Functions
The root module contains the following module-level functions.- get_root()
- Returns the root widget.
- schedule(delay, function)
- Arranges for the given function to be called after the specified delay in seconds. Scheduled functions are called synchronously from the event loop, and only when the frame timer is running.
Constructor
- RootWidget(surface)
- Initialises the root widget with the given surface, which will normally be the PyGame screen, but could be a subsurface of it.
Attributes
- redraw_every_frame
- If true, all widgets will be redrawn on every animation frame (i.e. after every call to begin_frame()). If false, redrawing only occurs after user input events, such as mouse clicks and keystrokes, or if a widget calls its invalidate() method. The default is false.
Methods
- set_timer(interval)
- Arranges for the begin_frame() method to be called every interval milliseconds.
- run()
- Runs the main event loop. Control is retained until a QUIT event is received, whereupon the quit() method is called.
run_modal(widget)- Runs a modal event loop. The widget is run as a modal dialog until its dismiss method is called.
- quit()
- This method is called when a QUIT event is received. The default implementation first calls confirm_quit(), and if it returns true, calls sys.exit(0).
Abstract Methods
- begin_frame()
- Called at the beginning of each frame time, as determined by a previous call to set_timer.
confirm_quit()- Called
to give an opportunity to ask the user to confirm quitting the main
event loop. The default implementation simply returns true.
---