0

Why can I move the button only horizontally using the vertical orientation of BoxLayout, and only vertically using the horizontal orientation? For example:

from kivy.lang import Builder
from kivymd.app import MDApp
    KV = '''
    Screen:
        BoxLayout:
            orientation: 'vertical'
            MDRaisedButton:
                pos_hint: {'center_x': .3,'center_y': .5}
    '''
    class Test(MDApp):
        def build(self):
            return Builder.load_string(KV)
    Test().run()

Horizontal orientation, also the default orientation:

from kivy.lang import Builder
from kivymd.app import MDApp
KV = '''
Screen:
    BoxLayout:
        orientation: 'horizontal'
        MDRaisedButton:
            pos_hint: {'center_x': .3,'center_y': .5}
'''
class FindWord(MDApp):
    def build(self):
        return Builder.load_string(KV)
FindWord().run()

How to move widgets freely on both axes? Help please

Mirai
  • 115
  • 2
  • 16

1 Answers1

0
from kivy.lang import Builder

from kivymd.app import MDApp

KV = '''
MDScreen:

    MDBoxLayout:
        adaptive_size: True
        pos_hint: {'center_x': .3, 'center_y': .5}

        MDRaisedButton:
            text: "MDRaisedButton"
'''


class FindWord(MDApp):
    def build(self):
        return Builder.load_string(KV)


FindWord().run()

https://kivy.org/doc/stable/api-kivy.uix.floatlayout.html

https://kivy.org/doc/stable/api-kivy.uix.boxlayout.html

Xyanight
  • 1,315
  • 1
  • 7
  • 10