techteej
Aug 07, 2015 - 21:15
self.var = str(dialogs.list_dialog(title='Select a file type', items=[".txt", ".py"], multiple=False))
print self.var
Returns none when I select an item, any ideas why?
self.var = str(dialogs.list_dialog(title='Select a file type', items=[".txt", ".py"], multiple=False))
print self.var
Returns none when I select an item, any ideas why?
Possible reason: You're calling this from the main UI thread (e.g. from a button action etc.). Blocking that thread would effectively "hang" the app, so list_dialog returns immediately, without waiting for a return value.
Try decorating your action/function with @ui.in_background, like this:
@ui.in_background
def my_action(sender):
self.var = str(dialogs.list_dialog(title='Select a file type', items=[".txt", ".py"], multiple=False))
print self.var
@omz That was it, thanks. You could tell it's been a while!