kivy
kivyでButtonを押したときに別のBoxLayoutを開きたいです
(MainScreenとSubScreenの切り替えをButto'Hello'とButton'Today?'で行いたい)
from kivy.app import App from kivy.uix.boxlayout import BoxLayout from kivy.uix.button import Button from kivy.lang.builder import Builder Builder.load_string(''' <MainScreen>: orientation: 'horizontal' Button: text: 'Hello' on_press: ************** Button: text: 'everyone' <SubScreen>: orientation: 'vertical' Button: text: 'How' Button: text: 'are' Button: text: 'you' Button: text: 'today?' on_press: ************** ''') class MainScreen(BoxLayout): def __init__(self, **kwargs): super().__init__(**kwargs) class SubScreen(BoxLayout): def __init__(self, **kwargs): super().__init__(**kwargs) class MainApp(App): def build(self): hoge = True #hoge = False if hoge: return MainScreen() else: return SubScreen() if __name__=='__main__': MainApp().run()
よろしくお願いいたします
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。