-
Notifications
You must be signed in to change notification settings - Fork 39
QuEStApplicationStructure
The QuESt application is built using Kivy. The entry point for launching the application is through main.py
:
>> python main.py
The structure of main.py
is described as follows.
from kivy.config import Config, ConfigParser
This is necessary for the proceeding lines for specifying application settings such as window size.
from es_gui ... import ...
Various modules specific to QuESt are imported including:
- Controller layer modules, such as the DataManager
- Widgets and literals from the "common" module
- Screen widgets for the primary QuESt screen manager
LabelBase.register(...
)
These register the new fonts packaged with and used by QuESt:
- Exo 2
- Open Sans
- Modern Pictograms
The main.py
file contains class definitions for "global" level widgets and other Kivy classes.
- IndexScreen: The landing screen upon launching the application. This is where users select which QuESt app to use. It also includes a way to launch the introduction tutorial.
- AboutScreen: This is the modal view launched from the persistent "about" button from the top navigation bar. It includes version information and copyright/license notices.
- SettingsScreen: This is the modal view launched from the persistent "settings" button from the top navigation bar. It includes settings configurations which are defined separately in a JSON file.
- QuEStScreenManager: This is the global screen manager for QuESt. In the constructor, global Screen widgets need to be added as children of it using
self.add_widget()
. Screens that are part of non-global screen managers such as in individual application wizards are not managed here. Note that a unique screen name needs to be assigned to these screens through the name property of the screen instance. - NavigationBar: Derived from the Kivy ActionBar. This is where logic for dynamically changing the bar throughout QuESt is managed. A class variable
parent_screen
is used for defining the behavior of the NavigationBar's back button (top left, next to QuESt logo). In this dictionary, the key is the name of a screen and the value is the name of the screen where the back button will take you.
This is the Application object that is run when main.py
is executed. The build()
class method constructs the foundation of the QuESt application.
- Sets the title (e.g., for the window name)
- Creates the global screen manager and assigns it as a member of this Application object
- Instantiates the DataManager and assigns it as a member of this Application object
- Creates a BoxLayout to format the application appearance
- Creates the navigation bar and adds it to the top of the BoxLayout
- Adds the global screen manager below the navigation bar
- Builds the settings screen
The return value of the build()
method, the BoxLayout, is the widget that is displayed when the run()
method is called for the Application object.
The widget tree for QuESt can be summarized as follows:
QuEStApp: # (root, App)
BoxLayout:
NavigationBar:
QuEStScreenManager:
IndexScreen:
AboutScreen:
SettingsScreen:
DataManagerHome:
[...]
Per Kivy convention, the .kv
file associated with the QuESt Application is in QuESt.kv
. Of note in this file are the "include" statements:
#:include es_gui/settings.kv
[...]
These are equivalent to importing the contents of the named .kv
files. As new .kv
files are added to accomodate new widget definitions, the corresponding include statements will need to be added here as well.