【发布时间】:2015-01-26 18:33:34
【问题描述】:
我似乎无法打开我的弹出窗口,因为它没有“定义”。一切都从 Python 传递到 Kivy 语言(因为我更容易跟踪一切),这就是问题所在。
<StoryScreen>:
name: "story"
BoxLayout:
id: storyScreen
Popup:
id: "popup"
title: "Settings"
on_parent:
if self.parent == storyScreen: self.parent.remove_widget(self)
GridLayout:
cols: 2
Accordion:
orientation: "vertical"
AccordionItem:
title: "Main Character"
size_hint:.9, 0.10
pos_hint: {'x':0.05, 'y':0.85}
Label:
id: first
text: "First Name"
AccordionItem:
title: "Love Interest"
size_hint: .9, 0.10
pos_hint: {'x':0.05, 'y':0.70}
Button:
text: "What's up"
Button:
text: "Press to open popup"
on_release: popup.open()
Label:
text: "This is a label"
我的回溯错误显示:
File "/Applications/Kivy.app/Contents/Resources/kivy/kivy/lang.py", line 1299, in custom_callback
exec(__kvlang__.co_value, idmap)
File "./story.kv", line 54, in <module>
on_release: popup.open()
NameError: name 'popup' is not defined
即使我尝试添加到 Python
class popup(Popup):
pass
它仍然会引发定义错误。帮忙?
【问题讨论】:
标签: python-2.7 popup kivy