Am Dienstag, 6. September 2016 18:44:04 UTC+2 schrieb Tim Roberts:
Leon wrote:
thanks for trying to help me. But I still do not get it!
Yes, in my real program, I start with a Frame which calls a Dialog.
This dialog then calls Frame2.
I have adjusted my example.
I have also tried to implement CallAfter:
I try to call the function “printValue”, after the Dialog is closed.
But it seems to be called to early: the variable is not yet defined 
Yes, you haven’t thought about what this does. Show() is going to
return immediately. You then immediately try to fetch “userinput” to
pass to CallAfter, but the dialog hasn’t even been displayed yet, so
naturally the value does not exist.
There are two choices. The way you have it now, as soon as
OnButton1Button returns, your frame no longer has any way to contact the
dialog, because you don’t have a reference to it. Thus, there is no way
for you to ask it for information, even if you knew when it was done.
Thus, you will need to have the dialog be in charge. Right now, you are
passing “None” as the parent of Dialog1. That’s wrong – the frame is
the parent – and that makes it impossible to get any back
communication. Instead, pass the frame as the parent, and hand the
dialog a function for it to call when it is done:
def OnButton1Button( self, event ):
myDialog1 = Dialog1( self, self.printValue )
myDialog1.Show()
event.Skip()
Now the dialog has what it needs to notify the parent when it is done:
class Dialog1(wx.Dialog):
...
def __init__(self, parent, callme):
self.notify= callme
self._init_ctrls(parent)
…
def OnDialog1Close(self, event):
self.notify( 'Hello' )
self.Destroy()
event.Skip()
The other alternative is to store the dialog in a member variable
instead of a local variable, but then you still have the problem of
knowing when the dialog is complete.
–
Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.