Bell on Enter with FloatSpin object

I am using a wx.lib.agw.floatspin.FloatSpin with Windows. When I enter a
value and press enter I get the annoying audible bell sound.

Any ideas on how to get rid of this bell?

Thanks.

···

--
View this message in context: http://wxpython-users.1045709.n5.nabble.com/Bell-on-Enter-with-FloatSpin-object-tp4828816p4828816.html
Sent from the wxPython-users mailing list archive at Nabble.com.

Haven't had time to try it but I would think that if you handle the
enter key event and do something with it maybe the sound will go away -
worth a try anyway.

Gadget/Steve

···

On 22/09/2011 4:13 AM, rocketman wrote:

I am using a wx.lib.agw.floatspin.FloatSpin with Windows. When I enter a
value and press enter I get the annoying audible bell sound.

Any ideas on how to get rid of this bell?

Thanks.

--
View this message in context: http://wxpython-users.1045709.n5.nabble.com/Bell-on-Enter-with-FloatSpin-object-tp4828816p4828816.html
Sent from the wxPython-users mailing list archive at Nabble.com.

GadgetSteve: Thanks for the suggestion it pointed me in the right direction.

I went and checked out the code and this is what I found:

1. The bell is occurring because the EVT_TEXT_ENTER handler is calling
Skip(). Therefore it gets passed up the hierarchy and at some point I guess
when it gets to the OS it generates the bell.

2. I also found another "bug" (or at least behavior I did not want). When
you enter values outside of the min or max more than once in succession -
the second entry does not update the underlying wx.TextCtrl even though the
value is correct. This only occurs if you go "high" twice in a row or "low"
twice in a row. This is a pretty minor nit - but easily fixed nontheless
...

To solve both of these I override the OnTextEnter method.

BTW - Is wx.lib.agw.floatspin being actively maintained? Where I look to
submit bug reports or update the source?

For completeness I though I would post the solution that I am using.
Clearly some of this would best be addressed in the source itself.

···

-----------------------------------------------
import wx
from wx.lib.agw import floatspin

class MyFloatSpin(floatspin.FloatSpin):
    def __init__(self, *args, **kwds):
        floatspin.FloatSpin.__init__(self, *args, **kwds)
    
    def OnTextEnter(self, evt):
        self.SyncSpinToText()
        self.SetValue(self.GetValue())
        
app = wx.PySimpleApp()
frame = wx.Frame(None)
panel = wx.Panel(frame)

float_spin = MyFloatSpin(panel, -1, value=0,
                       increment=0.1,
                       min_val = 0,
                       max_val = 10,
                       agwStyle=floatspin.FS_CENTRE)
float_spin.SetDigits(2)

frame.Show()
app.MainLoop()

--
View this message in context: http://wxpython-users.1045709.n5.nabble.com/Bell-on-Enter-with-FloatSpin-object-tp4828816p4831934.html
Sent from the wxPython-users mailing list archive at Nabble.com.

Andrea keeps all his widgets maintained and always welcomes patches. Go to the wxPython website and click the “Report a bug” link in the left hand column if you think those are bugs. I think you need to specify wxPython and probably AGW too to make sure he sees it.

···

On Thu, Sep 22, 2011 at 7:06 PM, rocketman tobin@vanpelts.net wrote:

GadgetSteve: Thanks for the suggestion it pointed me in the right direction.

I went and checked out the code and this is what I found:

  1. The bell is occurring because the EVT_TEXT_ENTER handler is calling

Skip(). Therefore it gets passed up the hierarchy and at some point I guess

when it gets to the OS it generates the bell.

  1. I also found another “bug” (or at least behavior I did not want). When

you enter values outside of the min or max more than once in succession -

the second entry does not update the underlying wx.TextCtrl even though the

value is correct. This only occurs if you go “high” twice in a row or “low”

twice in a row. This is a pretty minor nit - but easily fixed nontheless

To solve both of these I override the OnTextEnter method.

BTW - Is wx.lib.agw.floatspin being actively maintained? Where I look to

submit bug reports or update the source?


Mike Driscoll

Blog: http://blog.pythonlibrary.org