Josiah,
I'm back to this project: Could you please explain why you have the lines
if self.sl.GetValue() == v:
return
?
And why do you have them in _both_ OnText() _and_ OnScroll() !?
First I thought self.sl.SetValue(v) *should* trigger OnScroll() -
But now I see that self.tc.SetValue triggering OnText() is causing a
*feedback-loop* (which seems to fatal on Windows - but not on Linux)
Thanks for your help
Sebastian Haase
UCSF
···
On Monday 07 November 2005 12:30, Josiah Carlson 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
I'm sorry, that should have been:
#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.tc.GetValue() == v:
# ^^
#changed
return
self.tc.SetValue(str(self.sl.GetValue()))
Essentially I am checking to see if the values are the same before I
update the other one, to prevent the recursive calling on the SetValue
() calls.
- Josiah
···
Sebastian Haase <haase@msg.ucsf.edu> wrote:
Josiah,
I'm back to this project: Could you please explain why you have the lines
if self.sl.GetValue() == v:
return
?
And why do you have them in _both_ OnText() _and_ OnScroll() !?
First I thought self.sl.SetValue(v) *should* trigger OnScroll() -
But now I see that self.tc.SetValue triggering OnText() is causing a
*feedback-loop* (which seems to fatal on Windows - but not on Linux)
Thanks for your help
Sebastian Haase
UCSF
On Monday 07 November 2005 12:30, Josiah Carlson 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
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org