Python mouse EVT_COMMAND_LEFT_CLICK, EVT_LEFT_DOWN

S

SMALLp

Hy!
I'm not able to tu bind mouse click event. Code:

class MouseClass(wx.Panel):
def __init__(self, parent, id):

wx.Panel.__init__(self, parent, id, size=(500, 300))
self.SetBackgroundColour("WHITE")

sizer = wx.BoxSizer(wx.VERTICAL)

testPanel.SetBackgroundColour("BLACK")
self.Bind(wx.EVT_COMMAND_LEFT_CLICK, self.open, id=testPanel.GetId())
sizer.Add(testPanel, 0, wx.EXPAND)
self.SetSizerAndFir(sizer)

def open(self, event):
print "yea"

U tried EVT_LEFT_DOWN as I found on goofle and couldnt get it to work.
Please help.
 
K

kyosohma

Hy!
I'm not able to tu bind mouse click event. Code:

class MouseClass(wx.Panel):
def __init__(self, parent, id):

wx.Panel.__init__(self, parent, id, size=(500, 300))
self.SetBackgroundColour("WHITE")

sizer = wx.BoxSizer(wx.VERTICAL)

testPanel.SetBackgroundColour("BLACK")
self.Bind(wx.EVT_COMMAND_LEFT_CLICK, self.open, id=testPanel.GetId())
sizer.Add(testPanel, 0, wx.EXPAND)
self.SetSizerAndFir(sizer)

def open(self, event):
print "yea"

U tried EVT_LEFT_DOWN as I found on goofle and couldnt get it to work.
Please help.


It would help if you included working code, for one thing. Maybe I'm
blind, but I don't see a sub-panel getting instantiated with the name
"testPanel".

SetSizerAndFir is not a valid wx command.

All you need can be found here: http://www.wxpython.org/docs/api/wx.MouseEvent-class.html

If you do the following, it works:

<code>

import wx

class MouseClass(wx.Panel):
def __init__(self, parent, id):

wx.Panel.__init__(self, parent, id, size=(500, 300))
self.SetBackgroundColour("WHITE")

self.Bind(wx.EVT_LEFT_DOWN, self.open, id=self.GetId())


def open(self, event):
print "yea"

if __name__ == '__main__':
app = wx.PySimpleApp()
frm = wx.Frame(None, wx.ID_ANY, 'Mouse-click test')
panel = MouseClass(frm, wx.ID_ANY)
frm.Show()
app.MainLoop()

</code>

One other note: wxPython issues should be reported to the wxPython
user's group.

HTH

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,062
Latest member
OrderKetozenseACV

Latest Threads

Top