John Salerno <[EMAIL PROTECTED]> writes: > > def create_db_name(self): > > try: > > while True: > > dlg = wx.TextEntryDialog(self.frame, 'Enter a database > > name:', > > 'Create New Database') > > if dlg.ShowModal() != wx.ID_OK: > > return None > > db_name = dlg.GetValue() > > if db_name: > > return db_name > > pop_up_error_dialog("please enter a value or press cancel") > > finally: > > dlg.Destroy() > > Interesting. Some variation of this might suit me, but I think one > other problem I'm having is that the ShowModal() method returns > whenever a button is pressed, so even if OK is pressed with an empty > string in the box, the dialog disappears and returns an "OK" value.
Right. The above handles that case, I believe. If the user clicks with an empty string, showModal() returns wx.ID_OK, GetValue() returns the empty string, db_name gets set to that empty string, db_name gets tested (maybe I should have made the comparison with the empty string explicit), the error dialog pops up since db_name is empty, and the loop repeats. -- http://mail.python.org/mailman/listinfo/python-list