- by aF
Hello,
I have 3 panels and I want to make drags on them.
The problem is that when I do a drag on one this happens:
How can I refresh the frame to happear its color when the panel is no longer there?
This is the code that I have to make the drag:
def onMouseMove(self, event):
(self.pointWidth, self.pointHeight) = event.GetPosition()
(self.width, self.height) = self.GetSizeTuple()
if (self.pointWidth>100 and self.pointWidth<(self.width-100) and self.pointHeight < 15) or self.parent.dragging:
self.SetCursor(wx.StockCursor(wx.CURSOR_SIZING))
"""implement dragging"""
if not event.Dragging():
self.w = 0
self.h = 0
return
self.CaptureMouse()
if self.w == 0 and self.h == 0:
(self.w, self.h) = event.GetPosition()
else:
(posw, posh) = event.GetPosition()
displacement = self.h - posh
self.SetPosition( self.GetPosition() - (0, displacement))
else:
self.SetCursor(wx.StockCursor(wx.CURSOR_ARROW))
def onDraggingDown(self, event):
if self.pointWidth>100 and self.pointWidth<(self.width-100) and self.pointHeight < 15:
self.parent.dragging = 1
self.SetCursor(wx.StockCursor(wx.CURSOR_ARROW))
self.SetBackgroundColour('BLUE')
self.parent.SetTransparent(220)
self.Refresh()
def onDraggingUp(self, event):
self.parent.dragging = 0
self.parent.SetTransparent(255)
self.SetCursor(wx.StockCursor(wx.CURSOR_ARROW))
and this are the binds for this events:
self.Bind(wx.EVT_MOTION, self.onMouseMove)
self.Bind(wx.EVT_LEFT_DOWN, self.onDraggingDown)
self.Bind(wx.EVT_LEFT_UP, self.onDraggingUp)
With this, if I click on the top of the panel, and move down or up, the panel position changes (I drag the panel) to the position of the mouse.