[Tutor] passing variables between frames?

Alan G alan.gauld at freenet.co.uk
Tue May 24 08:54:45 CEST 2005


> want to access the values from the parent frame in the dialog.  
> for example say I had a listbox in the parent frame and I choose 
> the first entry 'a' from the list.  I then launch the child 
> dialog and I want to put the value of the selection from the 
> list box into a text field - when I lauch the child dialog 
> a text field appears with the value '0'. From within Frame1 
> I can use the getselection() function to get the listbox 
> selection. although in the child dialog I tried to use 
> Frame1.listBox.getselection() to get the selection from Frame1. 
> this doesn't work. not sure what to do here? any ideas? thanks.

The dialog should be subclassed and you can add a parameter to 
the constructor. When you create the dialog pass in Frame1 as 
the value of your new parameter. Within the constructor assign 
the parameter to an attribute of the object, self.parent say. 
Within the event handlers in the dialog you can now reference 
Frame1 as self.parent.

HTH

Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld


More information about the Tutor mailing list