Thanks very much for this answer. I will try them.
In the meantime I tried using pubsub (saw it mentioned in another
thread)
and this works fine.
However, I just struck another strange unrelated problem.
I am developing on Linux (at home) and testing on Windows (at work).
I have a statusbar that seems to work OK on Linux but does not display
on Windows, just leaves an empty space.
The relevant code is:
class CustomStatusBar(wx.StatusBar):
def __init__(self, parent):
wx.StatusBar.__init__(self, parent, -1)
# This status bar has three fields
self.SetFieldsCount(3)
# Sets the three fields to be relative widths to each other.
self.SetStatusWidths([-1, -2, -2])
self.sizeChanged = False
self.SetStatusText("Bucket Status - Idle", 0)
self.SetStatusText("Selected Controller %s" %
selectedController, 1)
self.SetStatusText("Selected Emulator %s" % selectedEmulator,
2)
pub.subscribe(self.onChange, 'update')
def onChange(self,msg):
if msg.topic == ('update','controller'):
self.SetStatusText("Selected Controller %s" % msg.data, 1)
elif msg.topic == ('update','emulator'):
self.SetStatusText("Selected Emulator %s" % msg.data, 2)
=== and I use it inside my frame subclass ===
class David(wx.Frame):
def __init__(self):
wx.Frame.__init__(self,None,title='Emulator Farm')
p = wx.Panel(self)
p.SetBackgroundColour("White")
nb = wx.Notebook(p)
self.sb = CustomStatusBar(p)
b = wx.BoxSizer(orient=wx.VERTICAL)
b.Add(self.sb,0)
etc etc etc ...
I will post this latest question as a separate topic.
Thanks
David
···
On May 12, 7:56 pm, Robin Dunn <ro...@alldunn.com> wrote:
On 5/12/10 9:30 AM, dubiboy wrote:
> Coming from the tcl/tl world, I am used to defining a label, for
> example, with a
> -textvariable myvariable
> parameter.
> Then, any time the value of myvariable changes, the display of the
> label widget follows suit automatically.
> Is there a way to do this in wxPython with for example StaticText
The GetLabel/SetLabel methods are used to make a Label property, so you
can treat staticText.Label as if it was one of these magic variables.
But that doesn't automatically update from arbitrary variables like what
you are probably wanting. You can do that with EVT_UPDATE_UI events,
something like this:
stxt = wx\.StaticText\(self, label="Hello World"\)
self\.Bind\(wx\.EVT\_UPDATE\_UI, self\.onUpdateLabel, stxt\)
def onUpdateLabel\(self, evt\):
evt\.SetText\(self\.someOtherStringVariable\)
> or
> StatusText (in statusbar)?
I don't think that update UI events know how to deal with status bar
since it doesn't have a single simple label, but you can do something
similar yourself using EVT_IDLE events. For example:
def onIdle\(self, evt\):
sbar = self\.GetStatusBar\(\)
if sbar\.GetStatusText\(0\) \!= self\.someOtherStringVariable:
sbar\.SetStatusText\(self\.someOtherStringVariable, 0\)
--
Robin Dunn
Software Craftsmanhttp://wxPython.org
--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visithttp://groups.google.com/group/wxPython-users?hl=en
--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en