from kivy.app import Appfrom kivy.uix.label import Labelfrom kivy.uix.gridlayout import GridLayoutfrom kivy.uix.textinput import TextInput
class LoginScreen(GridLayout): def __init__(self, **kwargs): super(LoginScreen, self).__init__(**kwargs) self.cols = 2 self.add_widget(Label('User Name:')) self.username = TextInput(multiline=False) self.add_widget(self.username) self.add_widget(Label('Password:')) self.password = TextInput(password=True, multiline=False) self.add_widget(self.password)
class MyApp(App): def build(self): return LoginScreen()
if __name__ == '__main__': MyApp().run()(tut) Jeremys-MacBook-Pro:tut home$ python my.py
[INFO ] [Logger ] Record log in /Users/home/.kivy/logs/kivy_20-04-20_0.txt
[INFO ] [Kivy ] v1.11.1
[INFO ] [Kivy ] Installed at "/Users/home/Documents/python-virtual-environments/tut/lib/python3.7/site-packages/kivy/__init__.py"
[INFO ] [Python ] v3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 16:52:21)
[Clang 6.0 (clang-600.0.57)]
[INFO ] [Python ] Interpreter at "/Users/home/Documents/python-virtual-environments/tut/bin/python"
[INFO ] [Factory ] 184 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_imageio, img_dds, img_sdl2, img_gif (img_pil, img_ffpyplayer ignored)
[INFO ] [Text ] Provider: sdl2
[INFO ] [Window ] Provider: sdl2
[INFO ] [GL ] Using the "OpenGL ES 2" graphics system
[INFO ] [GL ] Backend used <sdl2>
[INFO ] [GL ] OpenGL version <b'2.1 INTEL-12.10.14'>
[INFO ] [GL ] OpenGL vendor <b'Intel Inc.'>
[INFO ] [GL ] OpenGL renderer <b'Intel Iris OpenGL Engine'>
[INFO ] [GL ] OpenGL parsed version: 2, 1
[INFO ] [GL ] Shading version <b'1.20'>
[INFO ] [GL ] Texture max size <16384>
[INFO ] [GL ] Texture max units <16>
[INFO ] [Window ] auto add sdl2 input provider
[INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
Traceback (most recent call last):
File "my.py", line 24, in <module>
MyApp().run()
File "/Users/home/Documents/python-virtual-environments/tut/lib/python3.7/site-packages/kivy/app.py", line 829, in run
root = self.build()
File "my.py", line 20, in build
return LoginScreen()
File "my.py", line 10, in __init__
self.add_widget(Label('User Name:'))
TypeError: __init__() takes 1 positional argument but 2 were given