I have an app with 3 tabbed panels. I am currently sending AppendText to wx.TextCtrl in the same panel wx.CallAfter(self.running_log1.AppendText, line)
but also want to send AppendText to wx.TextCtrl in another tabbed panel, RunningPane2, wx.CallAfter(RunningPane2.running_log2.AppendText, line)
which I can't get working. How do I do that, or can I just do away with the RunningPane2 class altogether and create the self.running_log2 = wx.TextCtrl
from RunningPane1 panel?
class MainWindow(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, size=(900, 700))
self.tabbed = wx.Notebook(self, -1, style=(wx.NB_TOP))
self.running1 = RunningPane1(self.tabbed, run_params)
self.running2 = RunningPane2(self.tabbed, run_params)
self.submissions = SubmissionPane(self.tabbed, self.running1, self.running2, run_params)
self.tabbed.AddPage(self.submissions, "Submit Job")
self.tabbed.AddPage(self.running1, "Running Jobs 1")
self.tabbed.AddPage(self.running2, "Running Jobs 2")
self.Show()
#---
class SubmissionPane(wx.Panel):
def __init__(self, parent, running_pane1, running_pane2, run_params):
wx.Panel.__init__(self, parent)
...............
class RunningPane1(wx.Panel):
def __init__(self, parent, run_params):
wx.Panel.__init__(self, parent, -1)
self.running_log1 = wx.TextCtrl(self, -1, pos=(5, 5), size=(875,605),
style = wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL)
def StartWork(self, indir1, the_queue_pane, runningMode, showBox1, tvtitle):
..............
wx.CallAfter(self.running_log1.AppendText, line)
wx.CallAfter(RunningPane2.running_log2.AppendText, line)
..............
#---
class RunningPane2(wx.Panel):
def __init__(self, parent, run_params):
wx.Panel.__init__(self, parent, -1)
self.running_log2 = wx.TextCtrl(self, -1, pos=(5, 5), size=(875,605),
style = wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL)
self.Show()
It is not going to work in this way: RunningPane2.running_log2
.
You should get the instance of running_log2
, you can pass the MainWindow
instance into RunningPanel
and then you can get running_log2
from it.
class MainWindow(wx.Frame):
def __init__(self, parent, id, title):
...........
self.running1 = RunningPane1(self.tabbed, self, run_params)
class RunningPane1(wx.Panel):
def __init__(self, parent, frame, run_params):
wx.Panel.__init__(self, parent, -1)
..............
self.frame = frame
def StartWork(self, indir1, the_queue_pane, runningMode, showBox1, tvtitle):
..............
wx.CallAfter(self.running_log1.AppendText, line)
wx.CallAfter(self.frame.running2.running_log2.AppendText, line)