Baby Language Lab Scripts
A collection of data processing tools.
 All Classes Namespaces Files Functions Variables Pages
app.py
Go to the documentation of this file.
1 ## @package app.app
2 
3 from gi.repository import Gtk as gtk
4 from utils.backend_utils import BackendUtils
5 from utils.ui_utils import UIUtils
6 from utils.enum import Enum
7 
8 ## This is the "abstract" superclass of all _app classes. There is one subclass for each
9 # bll application. The launcher module instantiates the appropriate subclass to start the application.
10 # This provides a single entry point (the launcher module) for all applications.
11 # Subclasses should override the start method to do whatever they need to do to start the app.
12 class App(object):
13  APP_TYPES = Enum('GUI CMD_LINE'.split())
14 
15  ## Constructor
16  # @param self
17  # @param app_name (string) module name (name of a file from the app/ directory) of the app being started
18  # @param app_type (int) a value from the static enum App.APP_TYPES, indicating whether or not to initialize GUI stuff.
19  # @param app_icon_filename (string=None) path to the icon to use for this application (pass None if this is not a GUI-based app). This icon will be shown in the upper left corner of the title bar of all windows. The path may be absolute, or may be relative to the directory from which launcher.py is being called (typically this is the same directory that is specified by the BLL_APP_ROOT_DIR constant in launcher.py).
20  def __init__(self, app_name, app_type, app_icon_filename=None):
21  self.app_type = app_type
22 
23  BackendUtils.setup_logging(
24  'logs/%s.log' % (app_name)
25  )
26 
27  if app_type == App.APP_TYPES.GUI:
28  #this sets some project-wide GTK settings and sets the app-specific window icon
29  UIUtils.setup_gtk(app_icon_filename)
30 
31  ## This method must be overridden by subclasses to launch their main startup code.
32  # @param self
33  def start(self):
34  pass
35 
36  ## This method starts the gtk+ event loop. This causes the app to start accepting input from input
37  # devices like the keyboard and mouse. launcher.py only calls this if the app instance is App.APP_TYPES.GUI
38  def event_loop(self):
39  gtk.main()