Reputation: 413
I am trying to make a "whiteboard" application in wxPython. I am trying to figure out how to draw a line that follows the mouse when the user is clicking down.
def __init__(self, parent):
wx.Frame.__init__(self, parent, title="White Board")
self.Bind(wx.EVT_LIST_BEGIN_DRAG, self.OnDrag)
def OnDrag(self, e):
print "drag"
The first step is trying to get the mouse coordinates while the user is dragging the mouse, but I am unable to get the word "drag" to print no matter what I do and don't understand why it isn't working.
Upvotes: 2
Views: 332
Reputation: 69232
The mouse event, wx.EVT_MOTION
, will give you continuous updates as the mouse moves. Then determine whether the button is down, and also get the X and Y positions, using, say, wx.MouseState.
wx.EVT_LIST_BEGIN_DRAG
won't work because: 1) it's a list control event; 2) it only fires when you begin to drag, not the entire time.
Upvotes: 1