What I'm trying to do is just get the output of some terminal commands to the wx.TextCtrl widget. I realized that the easiest way to achieve this is to create your own stdout class and overload the write function into the widget function.
class stdout:
class StdOut(sys.stdout): def __init__(self,txtctrl): sys.stdout.__init__(self) self.txtctrl = txtctrl def write(self,string): self.txtctrl.write(string)
And then I would do something like:
sys.stdout = StdOut(createdTxtCtrl) subprocess.Popen('echo "Hello World!"',stdout=sys.stdout,shell=True)
As a result, the following error occurs:
Traceback (most recent call last): File "mainwindow.py", line 12, in <module> from systemconsole import SystemConsole File "systemconsole.py", line 4, in <module> class StdOut(sys.stdout): TypeError: Error when calling the metaclass bases file() argument 2 must be string, not tuple
Any ideas for fixing this would be appreciated.
python stdout
Duck
source share