I have an Python application with a wx.dirPicker control that can be manually changed and I need to be sure that the chosen path exists before running my code. To do that I'm using this:
def m_dirPicker1OnUpdateUI( self, event ):
src_directory = self.m_dirPicker1.GetTextCtrlValue()
if os.path.exists(src_directory)==False:
dlg = wx.MessageDialog( self, "The specified path doesn't exist", "Warning", wx.ICON_ERROR | wx.ICON_EXCLAMATION )
dlg.ShowModal()
#print(dlg.GetReturnCode())
if dlg.GetReturnCode() == 0:
self.Destroy()
It works fine, detecting if the path exists.
However, when the path doesn't exist the message dialog appears but I can't close it after pressing the OK button, and I don't understand why.
Thank you.