python kivy异步存储
我的应用程序使用同步JsonStorage,并希望切换到异步 我的同步呼叫是:python kivy异步存储,python,storage,kivy,Python,Storage,Kivy,我的应用程序使用同步JsonStorage,并希望切换到异步 我的同步呼叫是: store.exists(store_index) 我的非工作异步调用是: def callback_function(store,key,result): print "exists:",result store.exists(store_index, callback=callback_function) 此异步调用引发以下异常: store.exists(key=store_index,callb
store.exists(store_index)
我的非工作异步调用是:
def callback_function(store,key,result):
print "exists:",result
store.exists(store_index, callback=callback_function)
此异步调用引发以下异常:
store.exists(key=store_index,callback=callback_function)
TypeError: exists() got an unexpected keyword argument 'callback'
我也试过:
store.async_exists(store_index, callback=callback_function)
但这引起了:
File "main.py", line 199, in __init__ store.async_exists(key=store_index,callback=colorButtonCallback)
File "/home/mike/Dokumente/py-spielwiese/venv/local/lib/python2.7/sitepackages/kivy/storage/__init__.py", line 152, in async_existskey=key, callback=callback)
TypeError: _schedule() got multiple values for keyword argument 'callback'
我做错了什么?
async\u存在
将回调作为参数,然后使用键,因此请尝试更改为:
store.async_exists(callback_function, store_index)
您可以阅读以查看详细信息
希望这有帮助。这是Kivy中的一个bug。您上次的尝试非常正确(相当于@Anzel答案中的代码,尽管@Anzel的代码是编写相同内容的更好方法)。但最终您仍然会从
\u schedule
中抛出错误。我只是想在kivy-dev中解决这个问题