ANN-Revisited: ExtendedChoice Control For wxPython

Hello Andrea,

Puh :wink:

I could imagine:

(dropdown ist open)
example:
abc
six
two
three

all keystrokes applies only for the first char:
pressing b: not in the list: jumps to "nearest" char (here 'a')
pressing then t: jumps to "two", t again to "tree", t again to "two".
the dropdownlist stays open.

Each Time a EVT_EXT_CHOICE_CONTROL or similar is fired.

maybe optional in addition by pressing enter or leave focus with tab or
mouse:
EVT_EXT_CHOICE_CONTROL_ENTER (if it put out to be useful for someone)
and in any case close the dropdownbox.

the closing of the dropdownbox could aslo apply by pressing mouse again,
or alt-down again.

So I think, this is close to wx.Choice, with the exception, that here
the dropdownlist stays open and two different events are fired.

But plse wait for other opinions from other wxPython-users :wink:

路路路

On Tue, 24 May 2005 23:23:16 +0200, andrea_gavana@tin.it wrote:

Hello Franz & NG,

about this comment:

* alt-down cursor key should (could) open the whold dropdown list as in
the Combobox (as it is in Choice).

I have seen that wx.Choice and wx.ComboBox behave differently (after having
opened the drop-down list). So, suppose you open the drop-down list (that
applies also with the mouse-click opening). Then, if you want to use only
the keyboard, these are the behaviors:

1) wx.Choice: after whatever key press, the drop-down list is destroyed
(but the navigation with keyboard works correctly);
2) wx.ComboBox: the drop-down list remains opened and allows you to use
keys to navigate between choices (but the top textctrl is updated at every
navigation changes, so it receives a wx.EVT_COMBO_WHATEVER event on every
key press). When you have finished to navigate, an ESC key (or a wx.EVT_KILL_FOCUS)
destroys the drop-down list.

So, here is my questions:

a) Should I implement one of them and choose between wx.Choice behavior
and wx.ComboBox behavior?

b) Should I implement it really close to wx.ComboBox behavior but not sending
events to every navigation (with keyboard), and send the event only when
the navigation is finished (and the user has done his choice)?

c) Should I give the user the possibility to specify another "style" input
parameter that allows to switch (not in runtime, but during class construction)
between wx.Choice behavior and wx.Combobox behavior? And, in the wx.ComboBox
case, does the same limitations on (b) will apply?

Thank you for every suggestion.

Andrea.

--
Franz Steinh盲usler
http://drpython.sourceforge.net/
http://mitglied.lycos.de/drpython/

Hello Franz & NG,

Puh :wink:

?!?!?!?!?!?

So I think, this is close to wx.Choice, with the exception, that here
the dropdownlist stays open and two different events are fired.

This is what I have done:

1) I subclassed GenStaticText and GenBitmapButton as Robin suggested, so
they behave correctly now and I don't have to bind useless event like the
wx.EVT_KILL_FOCUS for the button;

2) Now ExtendedChoice has an input parameter in the __init__ method called
"extrastyle". This parameter is the switch between the wx.Choice behavior
(the dropdown closes after any wx.EVT_KEY_DOWN or wx.EVT_CHAR) and the wx.Combobox
behavior (the dropdown remains opened until you press ESC/TAB/RETURN or
it loses the focus for other reasons.
This parameter can have the values EC_COMBO or EC_CHOICE (I think they are
self explaining);

3) Regardless extrastyle you are using, TAB character moves to the next
control, either if the dropdown list is opened or not. If it is opened,
it is destroyed.
ESC character destroys the dropdown and leaves the previous choice as it
was before opening the dropdown list.
RETURN key set the current value of the top StaticText as the one selected
in the list.

I could imagine:

(dropdown ist open)
example:
abc
six
two
three

all keystrokes applies only for the first char:
pressing b: not in the list: jumps to "nearest" char (here 'a')

I still have not implemented this one... I see that neither wx.Choice nor
wx.ComboBox are able to "interpolate" your choice in order to find the nearest
character. Do you think it would be a useful feature to have? It is not
that difficult, I am asking only for curiosity...

pressing then t: jumps to "two", t again to "tree", t again to "two".

This was already present. If you try the demo, try to press "SHIFT-h" to
make capital H, and you will see that ExtendedChoice will loop between all
the choices that begin with "H".

Each Time a EVT_EXT_CHOICE_CONTROL or similar is fired.

Yes, each time an EVT_EXTENDEDCHOICE event is sent.

the closing of the dropdownbox could aslo apply by pressing mouse again,
or alt-down again.

Yes, this is how ExtendedChoice behaves. alt-down close the dropdown list
if it is already opened, and it opens it if it is not opened.

I have modified a little bit the demo: now, the ExtendedChoice controls
alternate between extrastyle=EC_CHOICE and extrastyle=EC_COMBO (You'll see
in the title of each ExtendedChoice). Try it out and see!

I had to modify a little bit the main ExtendedChoice class in order to handle
the different behaviours of the 2 extrastyle, so there may be some other
bugs/misbehaviors that I was not able to catch.

As usual, I'll thank everyone that just try the class and post some comments
(or bug reports).

The code is always here:

http://xoomer.virgilio.it/infinity77/ExtendedChoice.zip

Thanks for all your suggestions.

Andrea.

Hello Andrea,

Hello Franz & NG,

Puh :wink:

?!?!?!?!?!?

So I think, this is close to wx.Choice, with the exception, that here
the dropdownlist stays open and two different events are fired.

This is what I have done:

1) I subclassed GenStaticText and GenBitmapButton as Robin suggested, so
they behave correctly now and I don't have to bind useless event like the
wx.EVT_KILL_FOCUS for the button;

Ah, again learned something useful :wink:

2) Now ExtendedChoice has an input parameter in the __init__ method called
"extrastyle". This parameter is the switch between the wx.Choice behavior
(the dropdown closes after any wx.EVT_KEY_DOWN or wx.EVT_CHAR) and the wx.Combobox
behavior (the dropdown remains opened until you press ESC/TAB/RETURN or
it loses the focus for other reasons.
This parameter can have the values EC_COMBO or EC_CHOICE (I think they are
self explaining);

That is convenient.

3) Regardless extrastyle you are using, TAB character moves to the next
control, either if the dropdown list is opened or not. If it is opened,
it is destroyed.
ESC character destroys the dropdown and leaves the previous choice as it
was before opening the dropdown list.
RETURN key set the current value of the top StaticText as the one selected
in the list.

Good, I have no comment to add here :wink:

I could imagine:

(dropdown ist open)
example:
abc
six
two
three

all keystrokes applies only for the first char:
pressing b: not in the list: jumps to "nearest" char (here 'a')

I still have not implemented this one... I see that neither wx.Choice nor
wx.ComboBox are able to "interpolate" your choice in order to find the nearest
character. Do you think it would be a useful feature to have? It is not
that difficult, I am asking only for curiosity...

Hm, it was only a quick guess; no, I don't find it is so important.
It could be annoying too(?)

pressing then t: jumps to "two", t again to "tree", t again to "two".

This was already present. If you try the demo, try to press "SHIFT-h" to
make capital H, and you will see that ExtendedChoice will loop between all
the choices that begin with "H".

Each Time a EVT_EXT_CHOICE_CONTROL or similar is fired.

Yes, each time an EVT_EXTENDEDCHOICE event is sent.

the closing of the dropdownbox could aslo apply by pressing mouse again,
or alt-down again.

Yes, this is how ExtendedChoice behaves. alt-down close the dropdown list
if it is already opened, and it opens it if it is not opened.

I have modified a little bit the demo: now, the ExtendedChoice controls
alternate between extrastyle=EC_CHOICE and extrastyle=EC_COMBO (You'll see
in the title of each ExtendedChoice). Try it out and see!

I had to modify a little bit the main ExtendedChoice class in order to handle
the different behaviours of the 2 extrastyle, so there may be some other
bugs/misbehaviors that I was not able to catch.

As usual, I'll thank everyone that just try the class and post some comments
(or bug reports).

The code is always here:

http://xoomer.virgilio.it/infinity77/ExtendedChoice.zip

Thanks for all your suggestions.

Andrea.

thank you, all seems to be fine (for me).

路路路

On Wed, 25 May 2005 22:51:06 +0200, andrea_gavana@tin.it wrote:

--
Franz Steinh盲usler
http://drpython.sourceforge.net/
http://mitglied.lycos.de/drpython/