Using dialogs

I see dialog code like this in tutorials and demos:

diag = wxSomeDiag(self, 'foobar')
if diag.ShowModal()==wx.ID_OK:
    print diag.GetFoo()
diag.Destroy()

Wouldn't it be more appropriate to do this:

diag = wxSomeDiag(self, 'foobar')
try:
    if diag.ShowModal()==wx.ID_OK:
        print diag.GetFoo()
finally:
    diag.Destroy()

Does anyone do this in practice?

···

--
Chuck
http://ChuckEsterbrook.com

Yes, this is how our our production dialog code is generally called.

Chuck Esterbrook wrote:

···

I see dialog code like this in tutorials and demos:

diag = wxSomeDiag(self, 'foobar')
if diag.ShowModal()==wx.ID_OK:
   print diag.GetFoo()
diag.Destroy()

Wouldn't it be more appropriate to do this:

diag = wxSomeDiag(self, 'foobar')
try:
   if diag.ShowModal()==wx.ID_OK:
       print diag.GetFoo()
finally:
   diag.Destroy()

Does anyone do this in practice?

Chuck Esterbrook wrote:

I see dialog code like this in tutorials and demos:

[...]

Wouldn't it be more appropriate to do this:

[...]

Yes. I was lust lazy.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Hi Robin,

Yes. I was lust lazy.

You were what!!?!

Don't you hate those typos...

  - Erik.

Which typo? I might believe "lust" before "lazy".

Donnal

···

--- Erik Westra <ewestra@wave.co.nz> wrote:

Hi Robin,

>Yes. I was lust lazy.

You were what!!?!

Don't you hate those typos...

  - Erik.

Erik Westra wrote:

Hi Robin,

Yes. I was lust lazy.

You were what!!?!

Don't you hate those typos...

Oops. :wink: I need to have a long talk with my fingers about being more obedient...

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!