Python 更改父框布局kivy的大小
我正在尝试使用python更改kivy中的四个父框布局大小 代码-Python 更改父框布局kivy的大小,python,kivy,kivy-language,Python,Kivy,Kivy Language,我正在尝试使用python更改kivy中的四个父框布局大小 代码- class Run_app(App): def b1(self): self.b1 = BoxLayout(orientation="horizontal", spacing=10, size=(1, 0.15)) #< ADDED Two to three box layouts to self.b1> return(s
class Run_app(App):
def b1(self):
self.b1 = BoxLayout(orientation="horizontal", spacing=10, size=(1, 0.15))
#< ADDED Two to three box layouts to self.b1>
return(self.b1)
def b2(self):
self.b2 = BoxLayout(orientation="horizontal", spacing=10, size=(1, 0.45))
#< ADDED Two to three box layouts to self.b2>
return(self.b2)
def b3(self):
self.b3 = BoxLayout(orientation="horizontal", spacing=10, size=(1, 0.20))
#< ADDED Two to three box layouts to self.b3>
return(self.b3)
def b4(self):
self.b4 = BoxLayout(orientation="horizontal", spacing=10, size=(1, 0.20))
#< ADDED Two to three box layouts to self.b4>
return(self.b4)
def build(self):
self.title = "GUI"
self.root = BoxLayout(orientation="vertical", padding=15, spacing=15, )
self.root.add_widget(self.b1())
self.root.add_widget(self.b2())
self.root.add_widget(self.b3())
self.root.add_widget(self.b4())
return(self.root)
class Run\u应用程序(应用程序):
def b1(自我):
self.b1=BoxLayout(方向=“水平”,间距=10,尺寸=(1,0.15))
#<在self.b1中添加了两到三个方框布局>
返回(self.b1)
def b2(自我):
self.b2=BoxLayout(方向=“水平”,间距=10,尺寸=(1,0.45))
#<在self.b2中添加了两到三个方框布局>
返回(self.b2)
def b3(自我):
self.b3=BoxLayout(方向=“水平”,间距=10,尺寸=(1,0.20))
#<在self.b3中添加了两到三个方框布局>
返回(self.b3)
def b4(自身):
self.b4=BoxLayout(方向=“水平”,间距=10,尺寸=(1,0.20))
#<在self.b4中添加了两到三个方框布局>
返回(self.b4)
def生成(自):
self.title=“GUI”
self.root=BoxLayout(方向=“垂直”,填充=15,间距=15,)
self.root.add_小部件(self.b1())
self.root.add_小部件(self.b2())
self.root.add_小部件(self.b3())
self.root.add_小部件(self.b4())
返回(self.root)
我试图改变盒子(b1、b2、b3、b4)的大小,但大小没有改变,你能解释一下如何改变kivy中父盒子布局的大小吗
谢谢你如果你正在设置
大小
,那么你必须将大小
设置为无
,否则你的大小
设置将被忽略。例如:
self.b1 = BoxLayout(orientation="horizontal", spacing=10, size=(1, 0.15), size_hint=(None, None))
请注意,大小为(1,0.15)的BoxLayout
不会非常有用。也许你的意思是:
self.b1 = BoxLayout(orientation="horizontal", spacing=10, size_hint=(1, 0.15))
(只需将size
替换为size\u hint
)