wx鼠标拖动事件

#coding:UTF-8  
import wx  
  
app = wx.App()  
def dragEVT(event):  
    if event.ButtonDown():  
        panel1.SetPosition(event.GetPosition())  
    elif event.Dragging():  
        panel1.SetPosition(event.GetPosition())  
    elif event.ButtonUp():  
        panel1.SetPosition(event.GetPosition())  
          
frame = wx.Frame(None, -1, "Hello World")  
page1BoxSizer = wx.BoxSizer(wx.HORIZONTAL)  
frame.SetSizer(page1BoxSizer)  
panel1 = wx.Panel(frame,wx.ID_ANY,size = wx.Size(100,100))  
panel1.SetBackgroundColour("#aa0000")  
frame.Bind(wx.EVT_MOUSE_EVENTS,dragEVT)  
  
frame.Show()  
app.MainLoop()   

 

posted @ 2018-06-10 12:14  萌新上路  阅读(126)  评论(0编辑  收藏  举报