我試圖將此按鈕移到右上方,但不管我做什麼我只是無法移動它。這是總是在左下角,從來沒有離開這個位置。kivy gridlayout中的按鈕位置
這是我的.py:
#!/usr/bin/python
# coding=UTF-8
import kivy
from kivy.uix.gridlayout import GridLayout
from kivy.app import App
from kivy.uix.button import Button
from kivy.lang import Builder
Builder.load_file('listadex.kv')
class TestS(GridLayout):
def bt1(self):
print 'Olar galera' #layout.add_widget(bt1.Button(text='TestS'))
class SegundaTela(App):
def build(self):
#layout = GridLayout(cols=2, row_force_default=False, row_default_height=10)
#layout.add_widget(bt1.Button(text='TestS'))
#layout.add_widget(bt2.Button(text='TestA'))
#layout.add_widget(bt3.Button(text='TestD'))
#layout.add_widget(bt4.Button(text='TestMC'))
#return layout
CF = TestS()
return CF
SegundaTela().run()
這是我.kv
<TestS>:
GridLayout:
rows: 1
cols: 1
padding: 3
spacing: 3
Button:
text: 'botao1'
on_press: root.bt1()
pos_hint: {'center_x':.15}
你想把按鈕放在哪裏? – Juggernaut
它將成爲screem的頂部 – Kirat