In terms of what I’m trying to accomplish, I have an
application with multiple views of domain data in the form of custom widgets.
There is overlap in some of the data displays in each of the views, and at the
rate the widgets are updated, I was hoping to save some performance by not
having to update multiple widgets with identical data.
Josh
···
From: Davidson, Josh
Sent: Friday, May 08, 2009 12:02 PM
To: ‘wxpython-users@lists.wxwidgets.org’
Subject: One Widget Multiple Parents
Is it possible to add a single widget to multiple parents
(containers)? For example, in the following example, would it be possible
to add the TextCtrl object, text, to both subPanel1 and subPanel2?
#!/usr/bin/env python
import wx
class Test(wx.Panel):
def init(self, parent):
wx.Panel.init(self, parent, -1)
sizer =
wx.BoxSizer(wx.VERTICAL)
nb =
wx.Notebook(self,style=wx.NB_LEFT)
sizer2 =
wx.BoxSizer(wx.VERTICAL)
sizer3 =
wx.BoxSizer(wx.VERTICAL)
subPanel1
= wx.Panel(nb)
nb.AddPage(subPanel1, “Panel 1”)
subPanel2
= wx.Panel(nb)
nb.AddPage(subPanel2, “Panel 2”)
text =
wx.TextCtrl(subPanel1, -1, “Hide the key”)
sizer2.Add(text, 0, wx.EXPAND)
sizer3.Add(text, 0, wx.EXPAND)
subPanel1.SetSizer(sizer2)
subPanel2.SetSizer(sizer3)
sizer.Add(nb, 1, wx.EXPAND)
self.SetSizer(sizer)
app = wx.App(0)
frame = wx.Frame(None, -1)
sizerOuter = wx.BoxSizer(wx.VERTICAL)
sizerOuter.Add(Test(frame), 1, wx.EXPAND)
frame.Center()
frame.Show(True)
frame.SetAutoLayout(True)
frame.SetSizer(sizerOuter)
frame.Layout()
app.MainLoop()