An event between different widgets

The easiest way to code it would be:
self.list = wx.ListCtrl(style=wx.LC_SINGLE_SEL)
self.Bind(wx.EVT_BUTTON, self.OnDelButton, delBtn)

def OnDelButton(self, event):
        if self.list.SelectedItemCount > 0:
            self.list.DeleteItem(self.list.GetFirstSelected())
        else:
            dlg = wx.MessageDialog(self, "An entry must be selected
first", "Error", style=wx.OK|wx.ICON_ERROR)
            dlg.ShowModal()
            dlg.Destroy()

···

On Wed, Apr 23, 2008 at 12:59 PM, Gerard Petersen <lijssies@gp-net.nl> wrote:

Hi all,

I've been around wx.python for a couple of months now, and gathered quite an
application already (mostly sorting out boxsizers ... :slight_smile:

I want to be able to manage (add/remove/edit) a listctrl with seperate
buttons. See image link: http://www.gp-net.nl/userdl/snippet1.jpg

I've read a good piece on bind methods and events on the wxpywiki, but I'm a
bit lost. When I select an entry in the list, I want to remove it with the
button so there needs to be a function for the button-down event but
it also is listctrl related. I don't really know where to put the method (or
it's trigger) that actually kicks the entry from the list.

Any tips, URL's with examples or code snippets are very welcome.

Thanx a lot.

Regards,

Gerard.

--
~
~
:wq!

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

Hi again,

Both Mark and C M a big THANX for the feedback. Worked like a charm! Also the
explanation gave me a better understanding on what to put where. I see a big
refactor event on the horizon .. :slight_smile:

I have one more question. On the listctrl I can do single selects without
enabling the "wx.LC_SINGLE_SEL". I was digging in the API docs but I couldn't
find the styles explained anywhere. Is this info to be found there or am I
looking in the wrong place?

Thanx again guys!!

Regards,

Gerard.

···

On Wednesday 23 April 2008 21:14:01 C M wrote:

The example given is the way to think about it. It is not that you
are passing the event from one widget to another; the way to think
about it is: you have an event from one widget. Then, in the event
handler for that widget, you can do anything, including mucking about
with the state/contents of other widgets by using their (many)
methods. Also, you can also make the event handler simply call
another function which really does the work. This way, if you change
the GUI, you still have the function, and so the GUI is separate from
the logic. So for the above it would be more like (realizing it was
written just to make the point):

def OnDelButton(self, event):
    self.delete_listctrl()

def delete_listctrl(self):
    if self.list.SelectedItemCount > 0
        self.list.DeleteItem(self.list.GetFirstSelected())
    else:
        dlg = wx.MessageDialog(self, "An entry must be selected
first", "Error",
            style=wx.OK|wx.ICON_ERROR)
        dlg.ShowModal()
        dlg.Destroy()
_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

--
My $Grtz =~ Gerard;
~
:wq!

IIRC, wx.LC_SINGLE_SEL makes it so you can ONLY select one at a time. Without setting this, it is possible to select multiple items by use of ctrl-click or shift-click. If you specify single-selection, then ctrl-click and shift-click act like regular clicks do.

Gre7g

···

On 4/23/08, Gerard Petersen lijssies@gp-net.nl wrote:

I have one more question. On the listctrl I can do single selects without
enabling the “wx.LC_SINGLE_SEL”. I was digging in the API docs but I couldn’t

find the styles explained anywhere. Is this info to be found there or am I
looking in the wrong place?