View Single Post
thp's Avatar
Posts: 1,391 | Thanked: 4,272 times | Joined on Sep 2007 @ Vienna, Austria
#1
Hello!

Now that python-hildon has got support for portrait mode, I've added portrait mode support and auto-rotation to gPodder for Maemo 5, and in order to make my life easier, I've come up with a nice object that you can throw into your own code and that will take care of auto-rotation:

http://repo.or.cz/w/gpodder.git?a=bl...tl/portrait.py

The only thing you (might) need to do is to connect your windows to the configure-event signal and check the ratio of the width and height to determine if you need to relayout your window. For some windows (i.e. a window with just a treeview) you don't need to do anything

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:

Code:
from portrait import FremantleAutoRotation
FremantleAutoRotation()
Just make sure your windows are real hildon.StackableWindow, and everything should work out of the box.
 

The Following 41 Users Say Thank You to thp For This Useful Post: