ho dovuto fare parecchie modifiche:
codice:
import subprocess
import wx
import sys
from wx._controls import Button
class Form(wx.Frame):
txtUrl = None
lblWait = None
def __init__(self):
wx.Frame.__init__(self, None, title = "Python", size = (410, 400), style = wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER)
btnGo = Button(self, label = "GO", pos = (5, 40))
btnGo.Bind(wx.EVT_BUTTON, self.comando)
self.txtResult = wx.TextCtrl(self, pos = (5, 100), size = (400, 300), style = wx.TE_MULTILINE | wx.TE_READONLY | wx.HSCROLL)
def comando(self, strUrl):
c = subprocess.Popen(["ls", "-lR", "/home/casa/.netbeans"], shell = True, stdout = subprocess.PIPE)
outThread = RedirectText(c.stdout, self.txtResult.AppendText)
class RedirectText(threading.Thread):
def __init__(self, stdOut, cb):
super(RedirectText, self).__init__()
self.stdOut = stdOut
self.cb = cb
def run(self):
text = None
while text != '':
text = self.stdOut.readline()
self.cb(text)
ho usato i thread e Popen al posto di call.
diciamo che funziona, tranne per il fatto che Popen mi fa il comando ls sulla cartella dove c'è il file che lancio, e non sul percorso che intendo io.
ma forse sbaglio io a lanciarlo.