在wx.Panel中单击事件?

时间:2021-02-20 07:10:56

how can I click on a wx.Panel and that changes its color? What is the name of the event.

如何单击wx。面板会改变颜色吗?事件的名字是什么?

(I want to do a similar thing as Firefox Extras)

(我想做一个类似Firefox的额外功能)

Thanks in advance! :)

提前谢谢!:)

1 个解决方案

#1


7  

A quick google for wxpython mouse events turns up http://www.wxpython.org/docs/api/wx.MouseEvent-class.html

wxpython鼠标事件的一个快速谷歌出现在http://www.wxpython.org/docs/api/wx.MouseEvent-class.html中。

So using this, you could do something like:

因此,你可以这样做:

class MyFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None)
        self.panel = wx.Panel(self)
        self.panel.BackgroundColour = wx.RED
        self.panel.Bind(wx.EVT_LEFT_UP, self.onClick)

    def onClick(self, event):
        self.panel.BackgroundColour = wx.GREEN

#1


7  

A quick google for wxpython mouse events turns up http://www.wxpython.org/docs/api/wx.MouseEvent-class.html

wxpython鼠标事件的一个快速谷歌出现在http://www.wxpython.org/docs/api/wx.MouseEvent-class.html中。

So using this, you could do something like:

因此,你可以这样做:

class MyFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None)
        self.panel = wx.Panel(self)
        self.panel.BackgroundColour = wx.RED
        self.panel.Bind(wx.EVT_LEFT_UP, self.onClick)

    def onClick(self, event):
        self.panel.BackgroundColour = wx.GREEN