I'm new to Python and wxPython, and have been studying hfx2.py to try to
understand how build a gui in python to handle SoftRock radios.
I'm able to execute the code, but there are a couple of things that appear
not to work.
In the code there are the following lines:
class MyFrame(wx.frame) #Establishes a frame
.
.
.
self.panel_2 = wx.Panel(self, =1) #Establishes a panel on the frame
.
.
.
self.fft = fftsink2.fft_sink_c (self.panel_2, .... several parameters about
the fft here ...)
.
.
.
em.eventManager.Register(self.Mouse, wx.EVT_MOTION, self.fft.win)
#self.fft.win is the event source
#wx.EVT_MOTION is the event
#self.Mouse is the handler
.
.
.
def Mouse(self, event):
if self.AM_mode:
fRel = ( event.GetX() - 330. ) / 14.266666 - 7.5
else:
fRel = ( event.GetX() - 330. ) / 14.266666
self.fft.win.SetToolTip(wx.ToolTip(eng_notation.num_to_str(self.frequency +
(fRel*1e3))))
.
.
.
# end of class MyFrame
As I understand it, a frame is generated, a panel is placed on the frame,
and the fft.win is placed on the panel.
What is intended to happen when the user places the mouse on the fft.win is
a ToolTip with particular
information will appear. A ToolTip does appear, but it does not contain the
desired information.
Trying to trace what is happening lead me to fftsink2.fft_sink_c. A method
can be found there that is
called when an EVT_MOTION event is generated.
It appears to me that the EVT_MOTION event is captured in
fftsink2.fft_sink_c. Is there anything that
can be done without changing fftsink2.fft_sink_c to get it to bypass
catching EVT_MOTION and let the event be handled by panel_2, MyFrame, etc.?
I realize I could be phrasing this all wrong, but I'd appreciate any help.
Thanks.
···
--
View this message in context: http://www.nabble.com/Event-handling-in-wxPython-tp22109513p22109513.html
Sent from the wxPython-users mailing list archive at Nabble.com.
Flash3843 wrote:
I'm new to Python and wxPython, and have been studying hfx2.py to try to
understand how build a gui in python to handle SoftRock radios.
I'm able to execute the code, but there are a couple of things that appear
not to work.
In the code there are the following lines:
class MyFrame(wx.frame) #Establishes a frame
.
self.panel_2 = wx.Panel(self, =1) #Establishes a panel on the frame
.
self.fft = fftsink2.fft_sink_c (self.panel_2, .... several parameters about
the fft here ...)
.
em.eventManager.Register(self.Mouse, wx.EVT_MOTION, self.fft.win) #self.fft.win is the event source
#wx.EVT_MOTION is the event
#self.Mouse is the handler
.
def Mouse(self, event):
if self.AM_mode:
fRel = ( event.GetX() - 330. ) / 14.266666 - 7.5
else:
fRel = ( event.GetX() - 330. ) / 14.266666
self.fft.win.SetToolTip(wx.ToolTip(eng_notation.num_to_str(self.frequency +
(fRel*1e3))))
.
# end of class MyFrame
As I understand it, a frame is generated, a panel is placed on the frame,
and the fft.win is placed on the panel.
What is intended to happen when the user places the mouse on the fft.win is
a ToolTip with particular information will appear. A ToolTip does appear, but it does not contain the
desired information.
Trying to trace what is happening lead me to fftsink2.fft_sink_c. A method
can be found there that is called when an EVT_MOTION event is generated.
It appears to me that the EVT_MOTION event is captured in
fftsink2.fft_sink_c. Is there anything that
can be done without changing fftsink2.fft_sink_c to get it to bypass
catching EVT_MOTION and let the event be handled by panel_2, MyFrame, etc.?
I realize I could be phrasing this all wrong, but I'd appreciate any help.
Thanks.
You can try calling event.Skip() in the event handler that is capturing the event. That way the event should go up the event handler hierarchy...
You could also link to the file so others can take a look...
···
-------------------
Mike Driscoll
Blog: http://blog.pythonlibrary.org
Python Extension Building Network: http://www.pythonlibrary.org
Mike Driscoll wrote:
Flash3843 wrote:
I'm new to Python and wxPython, and have been studying hfx2.py to try to
understand how build a gui in python to handle SoftRock radios.
I'm able to execute the code, but there are a couple of things that appear
not to work.
In the code there are the following lines:
class MyFrame(wx.frame) #Establishes a frame
.
self.panel_2 = wx.Panel(self, =1) #Establishes a panel on the frame
.
self.fft = fftsink2.fft_sink_c (self.panel_2, .... several parameters about
the fft here ...)
.
em.eventManager.Register(self.Mouse, wx.EVT_MOTION, self.fft.win) #self.fft.win is the event source
#wx.EVT_MOTION is the event
#self.Mouse is the handler
.
def Mouse(self, event):
if self.AM_mode:
fRel = ( event.GetX() - 330. ) / 14.266666 - 7.5
else:
fRel = ( event.GetX() - 330. ) / 14.266666
self.fft.win.SetToolTip(wx.ToolTip(eng_notation.num_to_str(self.frequency +
(fRel*1e3))))
.
# end of class MyFrame
As I understand it, a frame is generated, a panel is placed on the frame,
and the fft.win is placed on the panel.
What is intended to happen when the user places the mouse on the fft.win is
a ToolTip with particular information will appear. A ToolTip does appear, but it does not contain the
desired information. Trying to trace what is happening lead me to fftsink2.fft_sink_c. A method
can be found there that is called when an EVT_MOTION event is generated.
It appears to me that the EVT_MOTION event is captured in
fftsink2.fft_sink_c. Is there anything that
can be done without changing fftsink2.fft_sink_c to get it to bypass
catching EVT_MOTION and let the event be handled by panel_2, MyFrame, etc.?
I realize I could be phrasing this all wrong, but I'd appreciate any help.
Thanks.
You can try calling event.Skip() in the event handler that is capturing the event. That way the event should go up the event handler hierarchy...
You could also link to the file so others can take a look...
-------------------
Mike Driscoll
Mike,
It turns out that the event handling was not the problem, but your tip sent me looking at the fft_sink_c code. It turns out that a canvas is created on which to write the fft display. All I needed to do to make everything work in my code was to change the "source" in em.eventManager.Register(self.Mouse, wx.EVT_MOTION, self.fft.win) to self.fft.win.plot.
Thanks again.
Cheers,
Mel Seyle
···
Blog: http://blog.pythonlibrary.org
Python Extension Building Network: http://www.pythonlibrary.org
_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users