Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

on click event in wx.Panel?

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

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

Thanks in advance! :)

like image 202
aF. Avatar asked Mar 02 '10 21:03

aF.


1 Answers

A quick google for wxpython mouse events turns up 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
like image 79
mrooney Avatar answered Oct 17 '22 09:10

mrooney