wx.ListCtrl and EVT_LEFT_UP?

Hi,

I’m
having trouble receiving mouse up events from a wx.ListCtrl. LeftDown events
are fine, but I don’t seem to receive LeftUp events. There is a LeftUp
after a LeftDClick. What am I doing wrong?

Regards,

Phillip

image001.jpg

···

Phillip Piper www.bigfoot.com/~phillip_piper phillip_piper@bigfoot.com

A man’s life
does not consist in the abundance of his possessions

Example
program:

import wx

class
MyFrame(wx.Frame):

def init(self, *args, **kwds):

kwds[“style”] = wx.DEFAULT_FRAME_STYLE

wx.Frame.init(self, *args, **kwds)

self.panel = wx.Panel(self, -1)

self.list = wx.ListCtrl(self.panel, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER)

sizer_2 = wx.BoxSizer(wx.VERTICAL)

sizer_2.Add(self.list, 1, wx.ALL|wx.EXPAND, 4)

self.panel.SetSizer(sizer_2)

self.panel.Layout()

sizer_1 = wx.BoxSizer(wx.VERTICAL)

sizer_1.Add(self.panel, 1, wx.EXPAND)

self.SetSizer(sizer_1)

self.Layout()

self.list.Bind(wx.EVT_LEFT_DOWN, self._HandleLeftDown)

self.list.Bind(wx.EVT_LEFT_UP, self._HandleLeftUp)

self.list.Bind(wx.EVT_LEFT_DCLICK, self._HandleLeftDClick)

self.list.InsertColumn(0, “Artist”)

self.list.InsertColumn(1, “Title”)

self.list.InsertColumn(2, “Genre”)

musicdata = {

1 : (“Bad English”, “The Price Of Love”, “Rock”),

2 : (“DNA featuring Suzanne Vega”, “Tom’s Diner”,
“Rock”),

3 : (“George Michael”, “Praying For Time”,
“Rock”),

4 : (“Gloria Estefan”, “Here We Are”, “Rock”),

5 : (“Linda Ronstadt”, “Don’t Know Much”,
“Rock”),

6 : (“Michael Bolton”, “How Am I Supposed To Live Without
You”, “Blues”),

}

items = musicdata.items()

for key, data in items:

index = self.list.InsertStringItem(99999, data[0])

self.list.SetStringItem(index, 1, data[1])

self.list.SetStringItem(index, 2, data[2])

def _HandleLeftDown(self, evt):

print “_HandleLeftDown”

evt.Skip()

def _HandleLeftUp(self, evt):

print “_HandleLeftUp”

evt.Skip()

def _HandleLeftDClick(self, evt):

print “_HandleLeftDClick”

evt.Skip()

app =
wx.PySimpleApp(1)

wx.InitAllImageHandlers()

frame_1 =
MyFrame(None, -1, “”)

app.SetTopWindow(frame_1)

frame_1.Show()

app.MainLoop()