Hey all. So I'm attempting to include mouse gestures as a part of a GUI I'm designing. I'm using the following code, and it works great HOWEVER only when the gesture is draw away from widgets/controls (such as buttons, statictext's, etc). If I start a gesture and cross the path of a widget, the gesture gets interrupted. Anyone know how I can use gestures on top of widgets? Thanks

Note: In the following code, drawing an 'L' closes the window. Code from: http://wiki.wxpython.org/AnotherTutorial

import wx
import wx.lib.gestures as gest

class MyMouseGestures(wx.Frame):
    def __init__ (self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title, size=(600, 500))

        panel = wx.Panel(self, -1)
        mg = gest.MouseGestures(panel, True, wx.MOUSE_BTN_LEFT)
        mg.SetGesturePen(wx.Colour(255, 0, 0), 2)
        mg.AddGesture('DR', self.OnDownRight)

    def OnDownRight(self):

class MyApp(wx.App):
    def OnInit(self):
        frame = MyMouseGestures(None, -1, "mousegestures.py")
        return True

app = MyApp(0)

Edited 6 Years Ago by convoluted: n/a

Associate you guesture with the top/main panel. Example.


#Now the buttons and other stuffs on pan2.
#make pan2  inherit pan1 as the parent.
#Associate the gusture on the pan1

That will fix it buddy ;)

Edited 6 Years Ago by richieking: n/a

Thanks for the reply richieking. I'm intrigued, but would this not make the buttons/controls on pan1 inaccessible? And forgive my lack of knowledge, but how would I make pan2 inherit pan1 as the parent? Would I do something like:

class pan1(wx.Panel):
    self.create_pan2 = pan2(self)
    self.[create gesture...]

class pan2(wx.Panel):
    self.[create other cotrols...]

...then obviously call pan1 from wx.Frame


You are welcome.

just make 2 panels.
say pan1 and pan2


That is it

Edited 6 Years Ago by richieking: n/a

This article has been dead for over six months. Start a new discussion instead.