I have written a command line widget in my pyside program. The structure is like this:
class CommandWidget(QWidget):
def __init__(self, parent = None):
super(CommandWidget, self).__init__(parent)
self.buffer=PyInterp(self)
self.buffer.initInterpreter(locals())
self........
class PyInterp(QTextEdit):
u3000u3000u3000u3000class InteractiveInterpreter(code.InteractiveInterpreter):
u3000u3000u3000u3000def __init__(self, locals):
u3000u3000u3000u3000code.InteractiveInterpreter.__init__(self, locals)
u3000u3000u3000u3000def runIt(self, command):
u3000u3000u3000u3000code.InteractiveInterpreter.runsource(self, command)
u3000u3000u3000u3000def __init__(self, parent = None):
u3000u3000u3000u3000super(PyInterp, self).__init__(parent)
I also have a mainwindow program ruing together with some other widgets. My question is how can i import some functions in other widget class in this interpreter, run the function and output the result to the global space. Or in other words, I want to share some variables between the local space of the interpreter and the global mainwindow space. How can I achieve that ?
