例如,我试图用Kivy(1.9)制作一个简单的GUI,使用弹出窗口来更改列表中的一些选项并将其保存到数据库中。当我调用popup()时,Python(3.4.5)崩溃。。在
在主.py公司名称:
from kivy.app import App
from kivy.uix.button import Button
from kivy.uix.popup import Popup
from kivy.properties import ListProperty
from kivy.lang import Builder
Builder.load_string('''
<PopView>:
title: 'Popup'
size_hint: (.8, .8)
Button:
text: 'Save'
''')
class MainApp(App):
def build(self):
b = Button(text='click to open popup')
b.bind(on_click=self.view_popup())
return b
def view_popup(self):
a=PopView()
a.data=[1,2,3,4] #e.g.
a.open()
class PopView(Popup):
def __init__(self):
self.data = ListProperty()
def save_data(self):
#db.query(self.data)
pass
if __name__ in ('__main__', '__android__'):
MainApp().run()
这里有几件事。在
首先,如果您要覆盖
__init__
,记得打电话给super
但在这个简单的例子中,您不需要
__init__
那么,}
on_click
上没有on_click
事件。使用on_press
或{最后但并非最不重要的是:您不需要在bind函数中调用该方法。只传递它(不带
()
)现在你的例子是这样的。在
相关问题 更多 >
编程相关推荐