Rana/Developers guide
Access it using self.get(key, default) and self.set(key, value)
Modules
All possible functionality is put into modules, which are loaded on startup (it scans through the module directory loading anything with a mod_something.py filename)
For a list and description of each, see: Rana/Modules
To use another module, access it with self.m.get('moduleName', None) and check the return value! (modules are not guaranteed to be loaded)
Messages
These are used to send data, event notifications, etc. between modules. Each message is a string (typically :-separated). Messages can set data, be routed to specific modules, and they can be bound to mouseclicks in a particular region of screen.
For a list and description of each, see: Rana/Messages
Beginning of message:
- set:optionName:optionValue - set the specified option
- toggle:optionName - toggle the specified option
- moduleName:someMessage - route message to the named module
- *:someMessage - route message to all modules
Multiple messages can be sent in the same string, use the | character to separate messages.
Actions are messages that are stored to send in response to some event (e.g. a mouse click).
Data
All configuration options and data are stored in a global dictionary (hash). Most data is text, but it's not required (yet)
For a list and description of each, see: Rana/Data
Use self.set("data_name", "value") and self.get("data_name", "default_value") rather than accessing the dictionary directly (because the messaging module may get smarter later, and support things like notification when certain values change)
Adding a module
- Copy an existing module or the example module
- Change the author and copyright date in the header
- Describe the module in 2 places - the header, and the doc text at the beginning of your class
- Change the name of the main class
- Change getModule() to return your main class
- Write your code. You can override any of the functions in base_module.py and your functions will be called at the appropriate time
Drawing on the map
See drawoverlay function in mod_route for sample code
Drawing an overlay
See mod_buttons for sample code
May be easier to modify mod_menu instead?
Responding to messages
Handle the handleMessage() function