is there a global eventhook in wxPython ?

thanks,
Stef

I'm not sure if this is what you mean but you can see all events before they are delivered to their widgets by overriding FilterEvent in the app object. You then use SetCallFilterEvent(True) to turn it on. Be sure to return -1 from your FilterEvent if you want to allow the event to continue to be processed normally.

···

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

I'm not sure if this is what you mean but you can see all events before they are delivered to
their widgets by overriding FilterEvent in the app object. You then use SetCallFilterEvent(True)
to turn it on. Be sure to return -1 from your FilterEvent if you want to allow the event to
continue to be processed normally.

thanks Robin,

I think that's exactly what I meant.

I want to record all events,
and then use these events later on in a test suite.

unfortunately, it doesn't seem to work:
the following code doesn't print anyting:

# app = wx.PySimpleApp ()
    app = wx.App ()

    app.FilterEvent_Old = app.FilterEvent
    def My_FilterEvent ( *args, **kwargs ) :
        print '&&&&&', args
        #app.FilterEvent_Old ( *args, **kwargs )
        return -1
    app.FilterEvent = My_FilterEvent
    app.SetCallFilterEvent ( True )

now searching on FilterEcent on Google,
I came across this message from you (august 2004):

<quote>
Chris Mellon wrote:

When using the wxWidgets C++ api, you can override wxApp::FilterEvents
in order to intercept/log/etc all events. FilterEvents doesn't seem to
be exposed in the wx.App wrapper object.

Correct. I left it out because the overhead of checking for the
existence of a Python FilterEvents method on every event in the 99.9% of
apps that wouldn't use it seems excessive. I do however have a ToDo
list item to create a new wx.FilterableApp class that would let you do
it for the other 0.1% of apps, but I havn't gotten to it yet.

Is there any other way to
intercept all events as they come?

Not without explicitly binding all the events.

···

On 11-05-2011 01:29, Robin Dunn wrote:

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
</quote>

Maybe FilterEvent is still not implemented ?

thanks,
Stef

It needs to be an actual overridden method, not a monkey-patched one. Try it like this:

import wx

class MyApp(wx.App):
     def FilterEvent(self, evt):
         print evt
         return -1

app = MyApp(redirect=False)
app.SetCallFilterEvent(True)
frm = wx.Frame(None, title='Hello')
frm.Show()
app.MainLoop()

···

On 5/11/11 11:25 AM, Stef Mientki wrote:

On 11-05-2011 01:29, Robin Dunn wrote:

I'm not sure if this is what you mean but you can see all events before they are delivered to
their widgets by overriding FilterEvent in the app object. You then use SetCallFilterEvent(True)
to turn it on. Be sure to return -1 from your FilterEvent if you want to allow the event to
continue to be processed normally.

thanks Robin,

I think that's exactly what I meant.

I want to record all events,
and then use these events later on in a test suite.

unfortunately, it doesn't seem to work:
the following code doesn't print anyting:

# app = wx.PySimpleApp ()
     app = wx.App ()

     app.FilterEvent_Old = app.FilterEvent
     def My_FilterEvent ( *args, **kwargs ) :
         print '&&&&&', args
         #app.FilterEvent_Old ( *args, **kwargs )
         return -1
     app.FilterEvent = My_FilterEvent
     app.SetCallFilterEvent ( True )

--
Robin Dunn
Software Craftsman

Thanks Robin,
works great !!

cheers,
Stef

···

On 11-05-2011 20:52, Robin Dunn wrote:

It needs to be an actual overridden method, not a monkey-patched one. Try it like this:

import wx

class MyApp(wx.App):
    def FilterEvent(self, evt):
        print evt
        return -1

app = MyApp(redirect=False)
app.SetCallFilterEvent(True)
frm = wx.Frame(None, title='Hello')
frm.Show()
app.MainLoop()

hello Robin,

one additional question, which probably you can answer,
if I store all the (important) events in a log file,
and I want to playback the recorded events,
how shouls I inject these events ?

thanks,
Stef

···

On 11-05-2011 21:12, Stef Mientki wrote:

Thanks Robin,
works great !!

cheers,
Stef
On 11-05-2011 20:52, Robin Dunn wrote:

It needs to be an actual overridden method, not a monkey-patched one. Try it like this:

import wx

class MyApp(wx.App):
    def FilterEvent(self, evt):
        print evt
        return -1

app = MyApp(redirect=False)
app.SetCallFilterEvent(True)
frm = wx.Frame(None, title='Hello')
frm.Show()
app.MainLoop()

There isn't a clean and easy way to do it in 2.8, at least not if you want the native widgets to see real native events as if they are coming from the system. Starting with 2.9.2 we'll have wx.UIActionSimulator. wxWidgets: wxUIActionSimulator Class Reference

···

On 5/12/11 2:35 AM, Stef Mientki wrote:

hello Robin,

one additional question, which probably you can answer,
if I store all the (important) events in a log file,
and I want to playback the recorded events,
how shouls I inject these events ?

--
Robin Dunn
Software Craftsman

thanks Robin,

for the moment I'll if there are other (simple) solutions (autoit?)

cheers,
Stef

···

On 12-05-2011 18:25, Robin Dunn wrote:

On 5/12/11 2:35 AM, Stef Mientki wrote:

hello Robin,

one additional question, which probably you can answer,
if I store all the (important) events in a log file,
and I want to playback the recorded events,
how shouls I inject these events ?

There isn't a clean and easy way to do it in 2.8, at least not if you want the native widgets to
see real native events as if they are coming from the system. Starting with 2.9.2 we'll have
wx.UIActionSimulator. wxWidgets: wxUIActionSimulator Class Reference