[Tutor] global variables and getting/setting controlvalues/variables between frames?? (original) (raw)
Alan Gauld alan.gauld at blueyonder.co.uk
Wed Jul 7 21:59:25 CEST 2004
- Previous message: [Tutor] global variables and getting/setting control values/variables between frames??
- Next message: [Tutor] help with global variables?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hello, I have an application I am writing with wxpython and the boa constructor.
Dunno anything about Boa so that might invalidate my reply...
I am unsure how to "talk between frames and dialogs". Global variables don't seem to be passed into child dialog and other frames from the parent frame,
Global variables exist at the file level and should be visible within any function within that file. However global variables are almnost certainly the wrong answer! :-)
I am unsure as to how to get a value from a control in the parent dialog from the child dialog.
Just to be clear, we are talking about GUI control here not class inheritance or widget containment? ie You have a dialog whereby you hit a button and a new "child" dialog opens?
myValue = self.textCtrl2.GetValue() but what if the above line is in a different dialog or frame than the text field?
If its in a different object then one of two situations arises:
- If you know the new dialog needs to know it you pass a refernce to the parent dialog into the child dialog constructor when you call it. The child dialog can then call
parent.textCtrl2.GetValue()
OR
- If the parent needs to know the value from the child dialog you return it as a result. Without knowing more about the design of your application its hard to be definite.
But one thing you should never be doing is mixing up GUI widget code and application logic... So if its an application object that needs to know then pass a reference to the app object to the dialog or a reference to the dialog to the app (latter is best for reuse).
HTH
Alan G.
- Previous message: [Tutor] global variables and getting/setting control values/variables between frames??
- Next message: [Tutor] help with global variables?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]