Okay, I am writing a script that might be impossible to fully explain in words. Therefore, I am going to come up with an example that shows the same problem, so please do not tell me to simply combine the scripts or anything, as I am unable to.
#!/usr/bin/python # MyScriptGUI.py class GUIClass: def __init__(self): # create a text area named "textArea" # bind the function "OnEnterDown" to the Enter key def OnEnterDown(self): # Call the function 'combine' in MyScript.py
Here is the code for MyScript:
#!/usr/bin/python # MyScript.py import random class MyClass: def __init__(self): self.myNumber = random.randint(1, 10) self.myWord = "Hello" def combine(self): # I want this function to be called when the Enter key is pressed phrase = self.myWord+str(self.myNumber) print phrase
So, how would I go about calling the 'combine' method in MyScript.py? I cannot create a new instance from within MyScriptGUI.py, since I obviously need to preserve the values of "self.myNumber" and "self.myWord" in order to run the 'combine' method. If I create a new instance, these will be lost.
EDIT: I figured out that I can do this crudely by passing the 'self' argument to the GUI script, but I would rather not do that unless it is the only way.
Thanks in advance.
Edited 6 Years Ago by SoulMazer: n/a