Change when using wx.FileDialog with 4.1.1

I am creating a dialog with code like this:

with wx.FileDialog(None, "Choose a file",
                           wildcard=wildcard,
                           style=wx.ID_OPEN) as dialog:
    path = dialog.GetPath()

However, in 4.1.1, this is throwing an assert:

Traceback (most recent call last):
  File "/Users/michael/Dropbox/image_viewer_working.py", line 42, in on_browse
    self.photo_txt.SetValue(dialog.GetPath())
wx._core.wxAssertionError: C++ assertion ""!HasFlag(wxFD_MULTIPLE)"" failed at ../../../ext/wxWidgets/include/wx/filedlg.h(109) in GetPath(): When using wxFD_MULTIPLE, must call GetPaths() instead

Why is FD_MULTIPLE now the default? How do I make this work the way that is used to? I don’t see a FD_SINGLE, for example?

Thanks,
Mike

False conclusion.
Try this: style=wx.FD_OPEN

1 Like

The ! in the expression !HasFlag(wxFD_MULTIPLE) means it is checking that it does not have that flag. Using GetPath is not correct in that case. As @wossx mentions, this is due to using a stock ID for the dialog’s style.

1 Like

Oh drat! I think I knew that and completely overlooked it. Sorry about that.