Re: [dabo-users] call dialog from button onHit

Author: JpoorRandP@aol.com

Posted: 2009-08-08 at 13:00:38

In a message dated 8/8/2009 12:48:57 P.M. Eastern Daylight Time,

ed@leafe.com writes:

In general, the "trick" is to use dialogs for these sorts of helper

forms, and use the fact that such modal dialogs stop the process that

called them until the dialog is either hidden or destroyed. You then

make sure that the ok/cancel buttons only *hide* the dialog, and not

close/destroy it. The calling code looks something like this:

dlg = MyDialogClass()

dlg.show()

# execution pauses here until the dialog is hidden

if dlg.Accepted:

# User clicked OK

result = dlg.someAttributeThatHoldsTheResult

self.doSomethingWithIt(result)

dlg.release()

The 'Accepted' property will be set to True when the user clicks

'OK'; otherwise, it is False. In your dialog code, you need to store

the user's input/selection into an attribute, or add a method to fetch

that value, so that the calling form can act on that value. And once

you have gotten the information from the dialog, you need to manually

call release() to destroy it.

Hope that gives you a general idea how to do this. If you have any

other questions, ask away!

-- Ed Leafe

Thanks, Ed, that's helpful. I do have some more questions! Paul also posted

some example code that parallels what you're saying:

def onHit_button1(self, evt):

dlg = MyDialog(self)

dlg.showModal()

ret_value = dlg.lookup.Value

dlg.release()

print ret_value

In this example, we have "dlg = MyDialog(self)" which instantiates your

MyDialog class as dlg. My question is how do I turn a dialog I've designed in

the class designer into a class that I can refer to in this way? I can't

seem to save the dialog form as anything but "cdxml" -- (why not as python

code?) -- I'm guessing there's a way to define the class using this cdxml

file? Is there a tool that will convert cdxml to python?

Thanks for you help!

--- StripMime Report -- processed MIME parts ---

multipart/alternative

text/plain (text body -- kept)

text/html

---

©2009 JpoorRandP@aol.com