Hi, Look at this package - pytkapp. See demo script in this package - <packagedir>/demo/run_ptamdidemo.py, after start - select ThreadChild btn from toolbar (button with lighting)
2015-02-24 22:46 GMT+06:00, Kamlendra Chandra <kamlendra.chandr...@gmail.com>: > Hi, > > I want to redirect the console or command line output to a python gui in > realtime. > > But most of the codes i have seen waits for the script to complete than > show up in gui. > > My script is long and it shows is progress while executing, i want a > realtime output on gui. > > Code snippet: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > *import wxfrom wx.lib.delayedresult import startWorker from subprocess > import Popen, PIPEclass MainWindow(wx.Frame): def __init__(self, *args, > **kwargs): wx.Frame.__init__(self, *args, **kwargs) > self.panel = wx.Panel(self) self.button = wx.Button(self.panel, > label="Run!") self.command = wx.TextCtrl(self.panel) > self.result = wx.TextCtrl(self.panel, style=wx.TE_MULTILINE) > self.sizer = wx.BoxSizer(wx.VERTICAL) self.sizer.Add(self.command, > 0, wx.EXPAND) self.sizer.Add(self.button, 0, wx.EXPAND) > self.sizer.Add(self.result, 1, wx.EXPAND) > self.command.SetValue("dir") self.button.Bind(wx.EVT_BUTTON, > self.CallCommand) self.panel.SetSizerAndFit(self.sizer) > self.Show() def CallCommand(self, e): > startWorker(self.WorkCommandDone, self.WorkCommand) def > WorkCommand(self): self.button.Disable() p = > Popen(self.command.GetValue(), shell=True, stdin=PIPE, > stdout=PIPE, stderr=PIPE) while True: line = > p.stdout.readline() if line != '': > wx.CallAfter(self.result.AppendText, line) else: > break def WorkCommandDone(self, result): self.button.Enable()app > = wx.App(False)win = MainWindow(None)app.MainLoop()* > help me to modify to this code to suit my requirement, or suggest me any > other way, > > Thanks, > kamlendra > > On Tue, Feb 24, 2015 at 10:07 PM, inq1ltd <inq1...@inqvista.com> wrote: > >> Kamlendra, >> >> Please explain in more detail what you are >> trying to accomplish. >> >> jimonlinux, >> inqvista.com >> >> >> >> >> On Tuesday, February 24, 2015 06:38:08 AM >> kamal_17 wrote: >> > Hi, >> > >> > I want to redirect output of a script into >> > a gui window in realtime. >> > >> > Please share some code snippet where u have >> > encountered similar issue. >> > >> > Thanks, >> > Kamlendra >> > >> > >> > >> > -- >> > View this message in context: >> > http://python.6.x6.nabble.com/Redirecting-> >> command-prompt-to-a-gui-realtime-tp5087377. >> > html Sent from the Python - tkinter-discuss >> > mailing list archive at Nabble.com. >> > __________________________________________ >> > _____ Tkinter-discuss mailing list >> > Tkinter-discuss@python.org >> > https://mail.python.org/mailman/listinfo/tk >> > inter-discuss >> > _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss@python.org https://mail.python.org/mailman/listinfo/tkinter-discuss