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:
-
<source lang="python">
 
-
from portrait import FremantleAutoRotation
 
-
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)
-
rotation_object = FremantleRotation(app_name, main_window, app_version, initial_mode)
 
-
</source>
 
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:
-
<source lang="python">
+
 
-
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)
-
</source>
+
 
-
You can create a <code>hildon.PickerButton</code> and a <code>hildon.TouchSelector</code> for your preferences dialog to set the mode. As an example, consult the source code of gPodder's preferences dialog:
+
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.


Please note that all contributions to maemo.org wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see maemo.org wiki:Copyrights for details). Do not submit copyrighted work without permission!


Cancel | Editing help (opens in new window)