[wxPython-users] LB_MULTIPLE on wxVListBox
Diego Jacobi
jacobidiego at gmail.com
Sat Sep 1 19:43:06 PDT 2007
Finally got it working:
Desc:
The next code makes a VListBox with LB_MULTIPLE to select and deselect with
just one mouse click and have a work around to fire an event when the last
item is deselected.
class ......(..):
def __init__(self, *args, **kwargs):
wx.VListBox.__init__(self, *args, **kwargs)
self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp)
def OnLeftUp(self, evt):
evt.Skip()
if self.GetSelectedCount() =3D=3D 0:
event =3D wx.CommandEvent(self.GetId(),
wx.wxEVT_COMMAND_LISTBOX_SELECTED)
event.SetEventObject(self)
# i cant change the event.Selection value
event.GetSelection =3D self.GetSelection
self.ProcessEvent(event)
def OnLeftDown(self, evt):
evt.Skip()
if 'wxMac' in wx.PlatformInfo:
evt.m_metaDown =3D True
else:
evt.m_controlDown =3D True
Cheers
2007/9/1, Robin Dunn <robin at alldunn.com>:
>
> Diego Jacobi wrote:
> > Cool!
> > Thanks Robin. :-D
> >
> > I didnt know about the abilities of wxMouseEvents. Now i know.
> >
> > But there is one still missing thing, and it is that, in the frame where
> > i use MyVListBox y have binded the event wx.EVT_LISTBOX , and with it i
> > do some task in another VListBox but when i deselect the last selected
> > item (so no items keep selected) no event is fired (a bug?).
>
> I don't know, maybe. Enter a bug report about it.
>
> >
> > How can i force it to fire wx.EVT_LISTBOX?
>
> You'll probably have to special case it somehow.
>
> >
> >
> > Also, on the other hand, i have maked a switch-color feature between
> > rows, and to use the system defined colors i choose to use the same
> > color as the scrollbar.
> >
> > def OnDrawBackground(self, dc, rect, n):
> > #Draw the background and maybe a border if desired.
> > if self.IsSelected(n):
> > bg =3D wx.SystemSettings.GetColour(wx.SYS_COLOUR_HIGHLIGHT )
> > else:
> > if n % 2:
> > bg =3D wx.SystemSettings.GetColour(wx.SYS_COLOUR_SCROLL=
BAR
> )
> > else:
> > bg =3D self.GetBackgroundColour()
> > dc.SetBrush(wx.Brush (bg, wx.SOLID))
> > dc.DrawRectangle(rect[0],rect[1],rect[2],rect[3])
> >
> > I couldn't find a system color for that use. Is there any?
>
> No, I don't think so.
>
>
> > Should i keep
> > using scrollbars color?
>
> If it works for you then I'd keep doing it that way. Another way would
> be to calculate the color based on the system selection color, such as a
> lighter version of the same color, or the same color tinted with grey.
>
>
> > It is very goodlooking to have 2 colors for use alternatively in each
> row.
> >
> >
> > PD:
> > In my opinion VListBox is a great ctrl. There could be a better example
> > in the demo showing some magics with it. Like showing icons per item,
> > showing some other ctrl when selected and maybe an expand effect.
> > Also it seems a little forgeted. As there are common methods in
> > ListBoxes not present in VListBox, like toggle.
>
> If you like you can enhance the demo and send me a patch.
>
>
> --
> Robin Dunn
> Software Craftsman
> http://wxPython.org Java give you jitters? Relax with wxPython!
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wxPython-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wxPython-users-help at lists.wxwidgets.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/200709=
01/c99e2bf2/attachment.htm
More information about the wxpython-users
mailing list