I have a textentrydialog and my goal is that the user cannot leave the the text entry blank or just empty whitespace. So the dialog should not go away until the user enters some characters in the box or hits cancel. This is what I have:
def OnNewButton(self,event): error=1 while error==1: newName = wx.TextEntryDialog(self, 'Question?:','Title') newName.SetValue("") if newName.ShowModal() == wx.ID_OK: if len(newName.GetValue().strip())!=0: error=0 self.Destroy() elif newName.ShowModal() == wx.ID_CANCEL: error=0 newName.Destroy()
However, this does not work if the user hits cancel. They actually have to hit cancel twice for the dialog to go away. I cannot see why. Or maybe there is just a better way to do this...Any help is greatly appreciated!