Python kivy _instance_ 的 Widget
我开始编写我的 python kivy 应用程序,但遇到了一些问题: App.root 必须是 Widget 的_实例_
。我看到了一些关于它的主题,但我仍然不明白。即使我尝试用谷歌搜索它。代码在这里:
from kivy.app import App
from kivy.uix.button import Button
class TestApp(App):
def build(self):
btn1 = Button(text ="btn1",
font_size ="20sp",
background_color =(1, 1, 1, 1),
color =(1, 1, 1, 1),
size =(32, 32),
size_hint =(.2, .2),
pos =(50, 425))
btn2 = Button(text ="btn2",
font_size ="20sp",
background_color =(1, 1, 1, 1),
color =(1, 1, 1, 1),
size =(32, 32),
size_hint =(.2, .2),
pos =(50, 50))
return btn1, btn2
TestApp().run()
感谢帮助
I started coding my python kivy app, but I am having some problems:App.root must be an _instance_ of Widget
. I saw some topics about it, but I still don't understand it. Even when I tried to Google it. Code is here:
from kivy.app import App
from kivy.uix.button import Button
class TestApp(App):
def build(self):
btn1 = Button(text ="btn1",
font_size ="20sp",
background_color =(1, 1, 1, 1),
color =(1, 1, 1, 1),
size =(32, 32),
size_hint =(.2, .2),
pos =(50, 425))
btn2 = Button(text ="btn2",
font_size ="20sp",
background_color =(1, 1, 1, 1),
color =(1, 1, 1, 1),
size =(32, 32),
size_hint =(.2, .2),
pos =(50, 50))
return btn1, btn2
TestApp().run()
Thanks for help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论