combining a textctrl with a slider

Thanks for the replys,
Hate to say though that it would be nice if that was already in wxPython :wink:
ALSO: I already had an OnSlider that did something else, this now seems to to
get triggered by the slider.SetValue() call from inside the OnText()...
Would it make sense to just call self.OnSlider "manually" from OnText() or is
these not a good style !?

Thanks
Sebastian Haase

路路路

On Monday 07 November 2005 12:30, you wrote:

#in __init__():
    self.tc = tc = wx.TextCtrl(...)
    tc.Bind(wx.EVT_TEXT, self.OnText)

    self.sl = sl = wx.Slider(...)
    sl.Bind(wx.EVT_SCROLL, self.OnScroll)

def OnText(self, evt):
    try:
        v = int(self.tc.GetValue())
    except:
        return
    if self.sl.GetValue() == v:
        return
    if self.sl.GetMin() <= v <= self.sl.GetMax():
        self.sl.SetValue(v)

def OnScroll(self, evt):
    try:
        v = int(self.tc.GetValue())
    except:
        return
    if self.sl.GetValue() == v:
        return
    self.tc.SetValue(str(self.sl.GetValue()))

- Josiah

Sebastian Haase <haase@msg.ucsf.edu> wrote:
> Hi,
> What is the best way of getting a textcontrol that shows the value of
> slider (right next to it)? that slider should adjust when the user types
> into the text control.
>
> I was considering validators !? Could TransferFromWindow and
> TransferToWindow be called on every interactive change ?
>
> Thanks,
> Sebastian Haase
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
> For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org