理论上,把Kivy-Label放进Stack Layout(或其他布局)应该是最简单和最常见的事情,但它目前让我陷入绝望。下面的语法显示一个简单的单键应用程序(在kivy1.8或1.9下,win7),直到我取消对标签生成行的注释,这一行始终失败,并显示诸如AttributeError: 'LabelPygame' object has no attribute 'bind'
或{layout.py
)中):
from kivy.app import App
from kivy.uix.button import Button
from kivy.core.text import Label
from kivy.uix.stacklayout import StackLayout
class TestApp(App):
def build(self):
mylayout = StackLayout(orientation='lr-tb')
mylayout.add_widget(Button(text='This button can always be rendered.'))
# mylayout.add_widget(Label(text='This label seems to cause trouble.'))
return mylayout
TestApp().run()
我有一种预感,我忽略了一些非常明显或愚蠢的事情,但却无法理解它是什么。基于Builder
和runTouchApp
的另一个调用似乎工作得很好(布局的类型似乎没有什么不同):
您正在导入
kivy.core.text.Label
,但您确实想要kivy.uix.label.Label
。在相关问题 更多 >
编程相关推荐