Getting Data From A Combo Box - Odd results

The demo shows how to to this (2.6.1), but when clicking on the textboxes, my
screen output dosn't show it.

I'm not sure why both the combo's in the demo are called by the same name,
however, I changed the name of the second combo box so I could be sure what
was happening:

        # This combobox is created with no values initially.
        cb1 = wx.ComboBox(
            self, 501, "default value", (90, 80), (95, -1), [],
wx.CB_DROPDOWN)

        # Here we dynamically add our values to the second combobox.
        for item in sampleList:
            cb1.Append(item, item.upper())

        self.Bind(wx.EVT_COMBOBOX, self.EvtComboBox, cb1)
  
and re-ran the demo.

When one selects each item, the data pulled back seems almost random. Eg at
first if click on zero, gives backing nothing, then on one, gives back ZERO,
two gives back ONE, but then if one clicks further down the list, then jumps
a couple of entries back, the data returned seems to bear no relationship to
what was put in.

I am BTW really trying hard - I've brought Robin's book at great expense to me
($100 AU including shipping to Oz) and have enjoyed the first 4 chapters on
the early release scheme. Looking forward to the rest.

Regards

Richard

Richard Terry wrote:
[...]

When one selects each item, the data pulled back seems almost random. Eg at first if click on zero, gives backing nothing, then on one, gives back ZERO, two gives back ONE, but then if one clicks further down the list, then jumps a couple of entries back, the data returned seems to bear no relationship to what was put in.

I thought this was fixed already, but maybe that was done only in 2.7... The problem is that during the event there is a discrepancy between the selection reported in the event, and what the control thinks of as the current selection. The combo.GetSelection() will still return the old selection until after the event has completed. If you change the line in the EvtComboBox function that fetches the item's data to use evt.GetSelection then it will work as expected.

I am BTW really trying hard - I've brought Robin's book at great expense to me ($100 AU including shipping to Oz)

Wow! I would think that a ream of paper and a printer ink cartridge would be more cost effective. :wink:

and have enjoyed the first 4 chapters on the early release scheme. Looking forward to the rest.

Glad to hear it!

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Richard Terry wrote:

Pity I can't show you all the piccies, I don't have any ftp site to put my stuff. Wonder if anyone else does, cause would be interesting perhaps for others to see the efforts of those of us trying to learn.

You could make a page here with images, descriptions, etc.

http://wiki.wxpython.org/index.cgi/wxPythonPit_20Apps

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!