Forum Archive

List Dialog Returns None

techteej
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?

omz

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
techteej

@omz That was it, thanks. You could tell it's been a while!