Editing PyMaemo/Portrait mode
Warning: You are not logged in.
Your IP address will be recorded in this page's edit history.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 12: | Line 12: | ||
Usage: Save the code as "portrait.py" or find some nice place in the module structure of you project, then use something like the following, and you're done: | Usage: Save the code as "portrait.py" or find some nice place in the module structure of you project, then use something like the following, and you're done: | ||
- | |||
- | |||
- | main_window = ... # your main hildon.StackableWindow | + | from portrait import FremantleAutoRotation |
- | app_name = 'NameOfYourApp' # the name of your app | + | |
- | app_version = '1.0' # the version number of your app | + | main_window = ... # your main hildon.StackableWindow |
- | initial_mode = FremantleRotation.AUTOMATIC | + | app_name = 'NameOfYourApp' # the name of your app |
+ | app_version = '1.0' # the version number of your app | ||
+ | initial_mode = FremantleRotation.AUTOMATIC | ||
+ | |||
+ | rotation_object = FremantleRotation(app_name, main_window, app_version, initial_mode) | ||
- | |||
- | |||
The rotation object then takes care of enabling and disabling the accelerometer as it is needed. You can provide a preferences UI for your app (see gPodder for an example) and then set the mode of the rotation object like this: | The rotation object then takes care of enabling and disabling the accelerometer as it is needed. You can provide a preferences UI for your app (see gPodder for an example) and then set the mode of the rotation object like this: | ||
- | + | ||
- | rotation_object.set_mode(FremantleRotation.AUTOMATIC) | + | rotation_object.set_mode(FremantleRotation.AUTOMATIC) |
- | rotation_object.set_mode(FremantleRotation.NEVER) | + | rotation_object.set_mode(FremantleRotation.NEVER) |
- | rotation_object.set_mode(FremantleRotation.ALWAYS) | + | rotation_object.set_mode(FremantleRotation.ALWAYS) |
- | + | ||
- | You can create a | + | You can create a hildon.PickerButton and a hildon.TouchSelector for your preferences dialog to set the mode. As an example, consult the source code of gPodder's preferences dialog: |
http://repo.or.cz/w/gpodder.git?a=blob;f=src/gpodder/gtkui/frmntl/preferences.py | http://repo.or.cz/w/gpodder.git?a=blob;f=src/gpodder/gtkui/frmntl/preferences.py | ||
[[Category:Python]] | [[Category:Python]] |
Learn more about Contributing to the wiki.