简体   繁体   中英

How to return 2 variables at the same time in Python kivy

class Head(App): def __init__(self, **kwargs): super().__init__(**kwargs) def build(self): SL = StackLayout(orientation ='rl-bt') TL = StackLayout(orientation = 'lr-tb') button1 = Button(text ="1", font_size = 18, size_hint =(.30, .1)) button2 = Button(text ="2", font_size = 18, size_hint =(.39, .1)) button3 = Button(text ="3", font_size = 18, size_hint =(.30, .1)) button4 = Button(text ="3", font_size =18, size_hint =(.30, .1)) SL.add_widget(button1) SL.add_widget(button2) SL.add_widget(button3) TL.add_widget(button4) #problem is here return SL return TL #problem is here root = Head() root.run()

Replace:

    return SL
    return TL

with:

box = BoxLayout()
box.add_widget(SL)
box.add_widget(TL)
return box

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM