我在my.kv
文件中有以下代码:
<UIWidget>:
AnchorLayout:
anchor_x: 'right'
anchor_y: 'top'
Button:
size_hint: None, None
text: 'Build'
UI Widget是一个空的Widget子类。
class UIWidget(Widget):
pass
我的根小部件将UIWidget加载到自身中,如下所示:
class SimplifiedGameWidget(Widget):
def __init__(self, **kwargs):
super().__init__(self, **kwargs)
self.layout = RelativeLayout(size_hint=(None, None))
self.layout.size = (1024, 768)
ui_widget = UIWidget()
ui_widget.size_hint = (1, 1)
self.layout.add_widget(ui_widget)
self.add_widget(self.layout)
class MyApp(App):
def build(self):
return SimplifiedGameWidget()
(完整代码:http://pastie.org/10791067)
我期望获得:
我真正得到的是:
我做错了什么?