2017-09-15 18 views

回答

0

你可以在wxPython演示中找到一个工作示例。从官方网站下载并找到“光标”示例。下面,我复制“光标”中的相关部分。

在面板构造函数中,绑定向左的事件。

self.win.Bind(wx.EVT_LEFT_DOWN, self.OnDrawDot) 

而且,这样做

def OnDrawDot(self, evt): 
    # Draw a dot so the user can see where the hotspot is 
    dc = wx.ClientDC(self.win) 
    dc.SetPen(wx.Pen("RED")) 
    dc.SetBrush(wx.Brush("RED")) 
    pos = evt.GetPosition() 
    dc.DrawCircle(pos.x, pos.y, 4) 

wxPython的演示是相当宝贵的资源。