typing in readonly TextCtrl - avoiding alert sounds

Hi all,
I'd like to ask, whether it is possible to suppress the alert sounds
on specific events.
I have some readonly text controls, where single keys may be used to
control the behaviour of the app.
The function itself is called in a char event, which works fine,
however, there is also an alert sound, while it is being typed to a
read-only widget.
Can this sound be somehow disabled/Vetoed from within wxpython?

The simplified sample can look like the following: the function is
successfully called on an char event, but there is an acoustic alert
suggesting rather a failure. (win XP, SP3)

Thanks in advance for any suggestions,
Vlasta

TextCtrl-Readonly-Char-evt.py (579 Bytes)

···

===================================================

#! Python
# -*- coding: utf-8 -*-

import wx

def check_first_line_visible(evt=None):
    first_visible_line = testTxtCtrl.HitTest((0, 5))[2]
    info_txt = u"top line: %s" % (first_visible_line,)
    frm.SetTitle(info_txt)
    evt.Skip()

appl = wx.App(redirect=False)
frm = wx.Frame(None, -1, "top line - ??")

testTxtCtrl = wx.TextCtrl(frm, -1, style=wx.TE_MULTILINE | wx.TE_RICH2

wx.TE_READONLY)

testTxtCtrl.SetValue("\n".join(str(x).zfill(3) for x in range(0,101)))

testTxtCtrl.Bind(wx.EVT_CHAR, check_first_line_visible)

frm.Show()
appl.MainLoop()

Vlastimil Brom wrote:

Hi all,
I'd like to ask, whether it is possible to suppress the alert sounds
on specific events.
I have some readonly text controls, where single keys may be used to
control the behaviour of the app.
The function itself is called in a char event, which works fine,
however, there is also an alert sound, while it is being typed to a
read-only widget.
Can this sound be somehow disabled/Vetoed from within wxpython?

The simplified sample can look like the following: the function is
successfully called on an char event, but there is an acoustic alert
suggesting rather a failure. (win XP, SP3)

Try it without calling evt.Skip. That should prevent the native handler for EVT_CHAR from being called which I think is where the read-only alert sound is coming from.

···

--
Robin Dunn
Software Craftsman

Thank for the suggestion Robin,
I can't believe, I didn't try something that simple ...
Originally I used the wx.WXK_RETURN, however this is probably somehow
specific, as it triggers system "beep" even without Skip().
After changing it to wx.WXK_SPACE, not calling Skip() successfully
prevents the alert sound and the program works as expected.

Thanks again for the help!
  Vlasta

···

2009/8/11 Robin Dunn <robin@alldunn.com>:

Vlastimil Brom wrote:

...
however, there is also an alert sound, while it is being typed to a
read-only widget.
Can this sound be somehow disabled/Vetoed from within wxpython?

The simplified sample can look like the following: the function is
successfully called on an char event, but there is an acoustic alert
suggesting rather a failure. (win XP, SP3)

Try it without calling evt.Skip. That should prevent the native handler
for EVT_CHAR from being called which I think is where the read-only
alert sound is coming from.

--
Robin Dunn
Software Craftsman
http://wxPython.org