Computer Science Canada Use the GUI class within another class |
Author: | ItsMe [ Mon Jan 11, 2010 12:17 am ] | ||||
Post subject: | Use the GUI class within another class | ||||
What is it you are trying to achieve? I'm trying to use a GUI class within another class. What is the problem you are having? It can't compile and the status bar shows "Class subprograms cannot be subprogram variables". Describe what you have tried to solve this problem A workaround, I found, was to use module instead of class. Ignoring this, is there any other possible ways? Test.tu
Test.t
Please specify what version of Turing you are using 4.1.1 and 4.1 Thanks, A noob who tries to learn OOP |
Author: | TerranceN [ Mon Jan 11, 2010 5:15 pm ] |
Post subject: | RE:Use the GUI class within another class |
I don't think this is possible, because the integer that GUI.CreateButton returns is just a number to identify the button, so if the object gets destroyed, the button still exists. Therefore if the function the button activates was part of the object and would now be deleted, the button which still exists would no longer have a function to call. In other words, you are hitting the limitations of Turing (or at least its GUI module) Hope that helps. |
Author: | DemonWasp [ Mon Jan 11, 2010 10:24 pm ] |
Post subject: | RE:Use the GUI class within another class |
You may want to try passing self.print into GUI.CreateButton. No guarantees, but it seems more likely to work as that's a proper method invocation, which is what GUI.CreateButton is expecting. You can't call print(), but you can call <instance-of-Test>->print() . |