Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import kivy
- from kivy.app import App
- from kivy.uix.gridlayout import GridLayout
- from kivy.uix.label import Label
- from kivy.uix.textinput import TextInput
- from kivy.uix.button import Button
- class LoginScreen(GridLayout):
- def __init__(self, **kwargs):
- super(LoginScreen, self).__init__(**kwargs)
- self.cols = 2
- self.add_widget(Label(text='Livro1:'))
- self.bookone = TextInput(multiline=False)
- self.add_widget(self.bookone)
- self.add_widget(Label(text='Livro2:'))
- self.booktwo = TextInput(multiline=False)
- self.add_widget(self.booktwo)
- self.add_widget(Button(text='Submit2', on_press=self.callback ))
- self.add_widget(Button(text='Submit1', on_press=self.callback ))
- def callback(self, args): # need self, args
- print('[DEBUG] args:', args)
- print('[DEBUG] args.text:', args.text)
- if args.text == 'Submit1':
- txt = self.bookone.text # get text from input
- elif args.text == 'Submit2':
- txt = self.booktwo.text # get text from input
- else:
- txt = '???'
- print('I am being pressed', args.text, txt)
- class MyApp(App):
- def build(self):
- return LoginScreen()
- if __name__ == '__main__':
- MyApp().run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement