I want a script in python which opens a logger window when the test is running and the output I want to see will be pushed to the logger window. I found baisc GUI script using wxpython but I dont know how to push my output to the gui being opened. Can anyone help me?
My Code:
import wx
import thread
import threading
class ExamplePanel(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent)
self.quote = wx.StaticText(self, label="Your Log :", pos=(10, 10))
self.logger = wx.TextCtrl(self, pos=(0,40), size=(1100,1100), style=wx.TE_MULTILINE | wx.TE_READONLY)
def append_txt(self,txt):
self.logger.AppendText(txt)
def sample_Window():
app = wx.App(False)
frame = wx.Frame(None)
panel = ExamplePanel(frame)
frame.Show()
panel.append_txt("Log Starts Here\n First line of code \n Second line of code ")
app.MainLoop()
sample_Window()
Once I give the app.Mainloop I am not able give further input to the appendtext method. I got suggestions to use threading to run the append_txt as a separate thread to pass the argument but i am not sure how to do it. My goal is call a method and pass on the text as argument which will show the text in logger window.
The simpliest way to do it is to embed your task into the panel, and start it with a thread:
Update:
Well, here's another way to do it: