Skip to content Skip to sidebar Skip to footer

Forcing A Kivy Widget's Orientation To Be Landscape/portrait

I'm developing an app where I want one of ScreenManager's screen to be in landscape orientation. I don't want it to change to vertical by itself. As of now, what I learned is only

Solution 1:

You can place a content of the screen on a scatter layout, and then rotate it:

test.kv:

ScreenManager:

    Screen:
        name: 'normal'

        Grid

    Screen:
        name: 'flipped'

        ScatterLayout:
            do_rotation: False
            do_scale: False
            do_translation: False
            rotation: 90
            pos_hint: {'center_x': 0.5, 'center_y': 0.5}
            size_hint: None, None
            size: root.height, root.width

            Grid


<Grid@GridLayout>:
    cols: 1

    Button:
        text: 'normal'
        on_press: app.root.current = 'normal'
    Button:
        text: 'flipped'
        on_press: app.root.current = 'flipped'

main.py:

#!/usr/bin/env python2
# -*- coding: utf-8 -*-
from kivy.app import App


class Test(App):
    pass


Test().run()

@edit There is also plyer's Orientation.


Post a Comment for "Forcing A Kivy Widget's Orientation To Be Landscape/portrait"