Hello again, dear list.
A few days ago I wondered how to access wxPythons eventqueue. With
Mikes and Robins help I did this:
class App(wx.App):
def __init__(self):
wx.App.__init__(self, redirect=False)
self.SetCallFilterEvent(True)
def FilterEvent(self, event):
# A lot of things going on here, for example print every event's
EventType.
This works fine!
Whenever I get the event's EventType, there's an integer returned. Is
there somewhere deep within wxPython a dictionary or something where I
can look up the constant's name? (For example 10123:'wx.EVT_EXP'.)
The thing is: I want to view every event fired within (certain parts)
of my app and I want to know _when_ and _what_ event has been fired.
Another question:
As mentioned above, I want only to do something with all events fired
within a certain part of my app (events occuring within a certain
window).
In my FilterEvent I did this:
if event.GetEventObject() not in List and event.GetEventType() !
= 10006 and event.GetEventType() != 10117 and event.GetEventObject()
is not None:
# Do something here.
With 10006 and 10117 I excluded some events (seems to be something
like mousestuff or so .... see my question above). Also I want the
event only to be examined when it's fired by widgets who are not in
List (For example I don't want to view events coming from a "control"-
window). Sometimes I got ObjectTypes of type "None".
Now my question: Where do this None-ObjectType originate from?
I hope someone can help - thanks a lot in advance!
Benjamin
PS: Here's the code shortened as far as I could:
class Frame(wx.Frame):
def __init__(self, parent=None, id=-1, title="Frame"):
wx.Frame.__init__(self, parent, id, title)
self.panel = wx.Panel(self)
self.button1 = wx.Button(self.panel, 1, "Button 1", pos =
(0,0))
self.button2 = wx.Button(self.panel, 1, "Button 2", pos =
(0,25))
class CtrlFrame(wx.Frame):
def __init__(self, parent=None, id=-1, title="CtrlFrame"):
wx.Frame.__init__(self, parent, id, title)
self.panel = wx.Panel(self)
self.panel.button1 = wx.Button(self.panel, id=-1, label="START",
pos = (0,0))
self.panel.button2 = wx.Button(self.panel, id=-1, label="STOP",
pos = (0,25))
self.panel.button1.Bind(wx.EVT_BUTTON, self.btn1click)
self.panel.button2.Bind(wx.EVT_BUTTON, self.btn2click)
Manager.List.append(self)
Manager.List.append(self.panel)
Manager.List.append(self.panel.button1)
Manager.List.append(self.panel.button2)
def btn1click(self, event):
Manager.evtViewActive = True
event.StopPropagation()
def btn2click(self, event):
Manager.evtViewActive = False
event.StopPropagation()
class Manager():
evtViewActive = False
List = []
class App(wx.App):
def __init__(self):
wx.App.__init__(self, redirect=False)
Manager.List.append(self)
self.SetCallFilterEvent(True)
def FilterEvent(self, event):
if Manager.evtViewActive and event.GetEventObject() not in
Manager.List and event.GetEventType() != 10006 and event.GetEventType
() != 10117 and event.GetEventObject() is not None:
print "Eventnumber: " + str(event.GetEventType()) + "\tObject:
" + str(event.GetEventObject())
app = App()
frame1 = Frame()
frame1.Show()
frame2 = CtrlFrame()
frame2.Show()
app.MainLoop()