As far as I know, it is not possible.
What is possible is to create a wx.TextCtrl
is both panels and set up text entry events on both of them that update
the other text box as you type in the one.
I have this example which converts between
hex and decimal in real-time, should give you a place to start
import wx
DEBUG=True
def myInt(string):
try: return int(string)
except: return 0
def myHex(string):
try:
if string[0:2] in ["0x","0X"]:
return int(eval(string))
else:
return int(eval("0x"+string))
except: return 0
class QuickConvert(wx.MiniFrame):
"""A small Decimal to Hexidecimal converter window"""
def __init__(self, parent=None):
wx.MiniFrame.__init__(self, parent, wx.ID_ANY, "Quick Converter",
` style = wx.SYSTEM_MENU
wx.CAPTION | wx.CLOSE_BOX | wx.STAY_ON_TOP)`
panel=wx.Panel(self)
decButton = wx.Button(panel, wx.ID_ANY, " Dec:", size=(30,-1))
hexButton = wx.Button(panel, wx.ID_ANY, " Hex:", size=(30,-1))
self.dec = wx.TextCtrl(panel, wx.ID_ANY, "0" , size=(80,-1),style=wx.TE_RIGHT)
self.hex = wx.TextCtrl(panel, wx.ID_ANY, "0x0", size=(80,-1),style=wx.TE_RIGHT)
sizer=wx.GridBagSizer(vgap = 1, hgap = 1)
sizer.Add(decButton, pos = (0,0))
sizer.Add(hexButton, pos = (1,0))
sizer.Add(self.dec, pos=(0,1))
sizer.Add(self.hex, pos=(1,1))
panel.SetSizer(sizer)
sizer.Fit(self)
self.dec.Bind(wx.EVT_TEXT, self.OnDec)
self.hex.Bind(wx.EVT_TEXT, self.OnHex)
decButton.Bind(wx.EVT_BUTTON, self.OnDecPaste)
hexButton.Bind(wx.EVT_BUTTON, self.OnHexPaste)
def OnDec(self, event):
self.hex.ChangeValue("0x%x"%myInt(self.dec.GetValue()))
def OnHex(self, event):
print self.hex.GetValue()
print "%i"%myHex(self.hex.GetValue())
self.dec.ChangeValue("%i"%myHex(self.hex.GetValue()))
def OnDecPaste(self, event):
self.dec.Clear()
self.dec.Paste()
def OnHexPaste(self, event):
self.hex.Clear()
self.hex.Paste()
# Run the program
if __name__ == '__main__':
app = wx.App(redirect=not(DEBUG))
frame = QuickConvert().Show()
app.MainLoop()
-Brian
Brian Fett
1280 Disc Dr
SHK224
Shakopee, MN 55379
Phone: (952)402-2595
Brian.D.Fett@seagate.com
“Davidson, Josh”
josh.davidson@lmco.com
Sent by: wxpython-users-bounces@lists.wxwidgets.org
No Phone Info Available
05/08/2009 01:02 PM
Please respond to
wxpython-users@lists.wxwidgets.org
To
wxpython-users@lists.wxwidgets.org
cc
Subject
[wxpython-users] 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()
`_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
`