【发布时间】:2020-02-22 10:29:06
【问题描述】:
class Main(Screen):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.name = "main"
self.cols = 1
self.Main_firstISS = Button(size_hint = (0.45,0.2) , pos_hint = {'center_x': 0.5 , 'y': 0.2})
self.Main_secISS = Button(size_hint = (0.2,0.1) , pos_hint = {'x':0.8, 'y': 0} , text = "Exit")
self.Main_thirdISS = Label(text = "Wellcome to Guess Game\n play and enjoy")
self.add_widget(self.Main_firstISS)
self.add_widget(self.Main_secISS)
self.add_widget(self.Main_thirdISS)
class Second(Screen):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.name = "second"
self.cols = 1
self.Second_firstISS = TextInput(hint_text = "What's your guess" , size_hint = (0.2,0.05) , pos_hint = {'center_x':0.5 , 'y': 0.7})
self.Second_secISS = Button(size_hint = (0.1,0.1) , pos_hint = {'x':0.9 , 'y': 0})
self.Second_firstISS.bind(on_press=self.callback)
self.add_widget(self.Second_firstISS)
self.add_widget(self.Second_secISS)
def callback(self , instance):
print(f"{self.Second_firstISS.text}")
class Manager(ScreenManager , Main , Second):
def __init__(self , **kwargs):
super().__init__(**kwargs)
my_main_page = Main()
my_second_page = Second()
my_main_page.__init__()
my_second_page.__init__()
【问题讨论】:
标签: python python-3.x kivy