Forum Archive

How to lock the orientation in `ui.View.present()`

marcus67

I tried two different ways to lock the orientation of my app: provide an empty list as parameter to the orientations parameter of method ui.View.present() or provide the list ('landscape'). Neither approaches worked for me. The app was still allowed to change orientation into portrait mode. What am I doing wrong? Thanks a lot!

shaun-h

Does this work for you?

view.present(orientations=['landscape'])

view is the view you want to present

Phuket2

@shaun-h , lol I made the same mistake. Didn't pass a list.
Great catch

shaun-h

I am glad that worked

dgelessus

If you want to make a one-element tuple, you need to write ("landscape",) with the extra comma. Otherwise the parentheses are interpreted as a normal operator grouping thing, not a tuple.

marcus67

@dgelessus This works. This is too embarrassing. I'm inclined to delete this thread... :-)