Learner's Problem With Dialog

The wx.TextEntryDlg() in my application is not functioning as intended. I
extracted the code and put it in a stub wrapper for testing. The source is
attached.

   The main frame comes up, but there's no button or dialog box. I know it's a
simple error, but my reading and testing does not show me where the problem
is to be found. Running it within winpdb didn't help; I either get deep into
a wxWidget init function or I find myself at the end of the file without
reaching the breakpoint in the dialog box.

   Neither the WriteItYourself wiki page nor the wxWidgets book has turned on
the light here.

Rich

testdlg.py (1.03 KB)

···

--
Richard B. Shepard, Ph.D. | Author of "Quantifying Environmental
Applied Ecosystem Services, Inc. (TM) | Impact Assessments Using Fuzzy Logic"
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863

Rich Shepard wrote:

  The wx.TextEntryDlg() in my application is not functioning as intended. I
extracted the code and put it in a stub wrapper for testing. The source is
attached.

Well, right away I spot two spelling errors:

1) You've spelt '__init__' '__init_'
2) You need to set the EVT_BUTTON binding to 'self.TextEntryDlg', not 'TextEntryDlg'.

Immediately, I suspected your init code wasn't firing. So, to confirm that, I added a 'print "here"' to the top of the init function, and re-ran the script. Didn't see the message. Found the spelling error.

···

--
Paul McNett
http://paulmcnett.com
http://dabodev.com

Well, right away I spot two spelling errors:

1) You've spelt '__init__' '__init_'
2) You need to set the EVT_BUTTON binding to 'self.TextEntryDlg', not 'TextEntryDlg'.

   Aw, gee! That's really embarrassing. Not the best way to begin a Friday.

Immediately, I suspected your init code wasn't firing. So, to confirm that,
I added a 'print "here"' to the top of the init function, and re-ran the
script. Didn't see the message. Found the spelling error.

   Even with syntax coloring in emacs I didn't catch those. Seeing what I
expected to see rather than what's there. I'll start adding print statements,
too.

Many thanks, Paul,

Rich

···

On Fri, 9 Dec 2005, Paul McNett wrote:

--
Richard B. Shepard, Ph.D. | Author of "Quantifying Environmental
Applied Ecosystem Services, Inc. (TM) | Impact Assessments Using Fuzzy Logic"
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863

Now that I corrected the spelling errors I see that what I expected is
happening: the information message box is not entered and the OK button
results in a direct step to the Destroy() function on line 23. I must have
something wrong in the line, ' if (newVar.ShowModal() == wx.OK):'. I'm not
seeing that, either. Another pair of eyes would be very helpful.

Thanks,

Rich

testdlg.py (1.08 KB)

···

On Fri, 9 Dec 2005, Rich Shepard wrote:

The wx.TextEntryDlg() in my application is not functioning as intended. I
extracted the code and put it in a stub wrapper for testing. The source is
attached.

--
Richard B. Shepard, Ph.D. | Author of "Quantifying Environmental
Applied Ecosystem Services, Inc. (TM) | Impact Assessments Using Fuzzy Logic"
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863

Rich Shepard wrote:

  Now that I corrected the spelling errors I see that what I expected is
happening: the information message box is not entered and the OK button
results in a direct step to the Destroy() function on line 23. I must have
something wrong in the line, ' if (newVar.ShowModal() == wx.OK):'. I'm not
seeing that, either. Another pair of eyes would be very helpful.

Change your check for wx.OK to wx.ID_OK. This IMO isn't your fault, it is one of many wx inanities that we are supposed to remember the difference between the two.

···

--
Paul McNett
http://paulmcnett.com
http://dabodev.com

Thanks again, Paul. I know that the wx.ID_OK is the unique identifier, but
I also saw the call to the button on the line above as 'wx.OK' so I thought
that was what was tested. The code was (partially) modified from the
wxWidgets book, and I certainly missed that one, too.

   Well, I now owe you two pints of handcrafted ale from one of our many local
brewpubs.

Rich

···

On Fri, 9 Dec 2005, Paul McNett wrote:

Change your check for wx.OK to wx.ID_OK. This IMO isn't your fault, it is
one of many wx inanities that we are supposed to remember the difference
between the two.

--
Richard B. Shepard, Ph.D. | Author of "Quantifying Environmental
Applied Ecosystem Services, Inc. (TM) | Impact Assessments Using Fuzzy Logic"
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863