I have a problem (newly created by me) for which I cannot see the error; I
also don't know how to create a little applet that illustrates the problem.
Perhaps more experienced wxPython users can point out my error(s) by
examining the code.
On a notebook tab is a wx.ComboBox() holding a list of subcomponents
associated with each component. When the displayed subcomponent is changed,
I want the combo box list reorganized so the selected item is displayed and
the others are available via the drop-down arrow widget. It's no longer
working. Here's the beginning of the method:
def OnSubNameChngd(self, event): # The subcomponent only has changed.
# Get the new subcomponent name.
current = self.vsub.GetValue()
# Re-load all subcomponents into that combo box after clearing it of all entries
self.vsub.Clear() # clear the widget
for subterm in self.appData.subComps:
if subterm[1] == self.vcomp.GetValue():
if subterm[0] == current:
continue
else:
self.vsub.Append(subterm[0]) # add any other subcomponents back to the list
What stumps me is seeing all the subcomponents for the selected component
selected and supposedly appended to the combo box list when I run the
application with the winpdb debugger.
I must have a logic or syntax error that I'm just not seeing. I am hoping
that one of you can point out the error of my ways.
TIA,
Rich
···
--
Richard B. Shepard, Ph.D. | The Environmental Permitting
Applied Ecosystem Services, Inc. | Accelerators(TM)
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863
> Attached is a standalone that works for me. Note that calling Clear() on
> the combobox was clearing the selected value, and I had to use
> wx.CallAfter to set it after the event handler completed.
Chris,
When Clear() works, it clears the entire list. If I didn't issue that call
the displayed string was added a second time to the list as they were all
Appended().
I understand that, and thats why I have the Clear() in there. I was
explaining why it needed to be called with wx.CallAfter.
> For the record, I'd advise against implementing this - it's a change in
> the UI convention for the platform (scrolling through the items with the
> mouse wheel no longer works, for example) that seems gratuitous.
Implementing which? I'm not following.
If I understand your code correctly, you're removing the current
selection from the combobox dropdown. This is a UI change that can
interfere with user expectations.
···
On 9/18/07, Rich Shepard <rshepard@appl-ecosys.com> wrote:
On Tue, 18 Sep 2007, Chris Mellon wrote:
Rich
--
Richard B. Shepard, Ph.D. | The Environmental Permitting
Applied Ecosystem Services, Inc. | Accelerators(TM)
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org
The sample that I attached works correctly for me. Does it work for
you?
Aha! Isolated the problem to some code later in the method! Haven't yet
identified what, but commenting out everything after this initial code --
yours or mine -- and it works as intended.
If not, how does it differ from what you are doing? Remove the code that
does this from your application. Does it still work?
Your sample uses AppendItems() while I knew only of Append().
I _should_ have commented out all following code earlier in the process
and I would have saved a lot of your time as well as mine. Now I can figure
out just what I broke.
Many thanks, Chris,
Rich
···
On Tue, 18 Sep 2007, Chris Mellon wrote:
--
Richard B. Shepard, Ph.D. | The Environmental Permitting
Applied Ecosystem Services, Inc. | Accelerators(TM)
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863