userista
Aug 06, 2014 - 23:20
If I have a call to keychain.get_password in a delegate and have a master_password set it will lock up the ui even if using a @ui.in_background function decorator. What am I doing wrong here?
(Don't mind the messed up indentation - posting on mobile...)
import keychain, ui, console
class Test (ui.View):
def __init__(self):
tv = ui.TableView()
tv.frame = self.bounds
tv.flex = 'WH'
ds = ui.ListDataSource(['foo','bar','baz'])
ds.action = self.item_selected
tv.data_source = ds
tv.delegate = ds
self.tableview = tv
self.add_subview(self.tableview)
@ui.in_background
def item_selected(self,sender):
#this will lock up bec of the keychain.master_password alert
#(make sure that u have an entry in the keychain 'name'/'user'/'foobar')
print keychain.get_password('name','user')
#if you comment out the line above, you can see that the @ui.in_background is working
#bec the next line does not lock up the ui
console.alert('test')
test = Test()
test.present('sheet')
This only happens when subclassing ui.View. When making a "standalone" view there's no lock up:
import keychain, ui
@ui.in_background
def cell_tapped(sender):
print keychain.get_password('name','user')
tv = ui.TableView()
tv.flex = 'WH'
ds = ui.ListDataSource({'title':x,'accessory_type':'detail_button'} for x in ['foo','bar','baz'])
ds.action = cell_tapped
tv.data_source = tv.delegate = ds
tv.present('sheet')