【问题标题】:How can I use wxPython to create plain 2D space and plot points on that by mouse clicks?如何使用 wxPython 通过鼠标点击创建普通的 2D 空间和绘图点?
【发布时间】:2017-09-15 03:30:17
【问题描述】:

我想使用 wxPython 构建一个 2D 空间,用户可以通过单击空间来绘制点。

之后,我想将点的坐标存储到一个文件中。

【问题讨论】:

    标签: python-2.7 plot wxpython 2d


    【解决方案1】:

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

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

    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 演示是一个非常有价值的资源。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-05-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多