The code below produces a blank screen entitled "Test", but that is all. No error messages. What am I doing wrong, please?
#!/usr/bin/env python3
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.uix.label import Label
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.scatter import Scatter
class MyScreen(Widget):
def __init__(self):
Widget.__init__(self)
f = FloatLayout()
s = Scatter()
l = Label(text="Hello, World!", font_size=100)
f.add_widget(s)
s.add_widget(l)
class TestApp(App):
def build(self):
return MyScreen()
if __name__ == "__main__":
TestApp().run()
f = FloatLayout()
s = Scatter()
l = Label(text="Hello, World!", font_size=100)
f.add_widget(s)
s.add_widget(l)
These added the widgets to the layouts - but you didn't add the layout to the main App Class
try
self.add_widget(f)
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.