Can someone test my new widget (I'm on Windows only)?

One bug I’m still working on is that the scrollbars don’t show the correct size when wordWrap is being used… but I will let the other thread I started serve for debugging that.

Here I just want some folks to give this a try… it should essentially be like the Google Chrome URL bar… where the textbox acts as a search box for the history and shows results in a drop-down. With Chrome the browser history is used for searching, but with this widget you add items to the list just like any list… and can drop-down the full-list of items too.

Worked hard on this, and I think it is pretty good, but obviously it probably isn’t perfect!

P.S. I based this off of the combotreebox.py code, but I REALLY HATED the platform-specific subclassing that file has going on in it… It made hacking the code MUCH harder because all the sub/super class methods with identical names made tracing code flow really slow… so I moved platform-specific stuff to happen during the class construction.

ComboSearchVListBox.py (37.7 KB)

Hi Nathan,

One bug I'm still working on is that the scrollbars don't show the correct size when wordWrap is being used... but I will let the other thread I started serve for debugging that.

Here I just want some folks to give this a try... it should essentially be like the Google Chrome URL bar... where the textbox acts as a search box for the history and shows results in a drop-down. With Chrome the browser history is used for searching, but with this widget you add items to the list just like any list... and can drop-down the full-list of items too.

Worked hard on this, and I think it is pretty good, but obviously it probably isn't perfect!

I gave this a try, initially on Windows 8.1, but will also try it on Linux Mint.

Works well for me with the exception of the following.

Got following exception on the second control, typing into it "thi", but I can't reproduce it on demand, so it must be some other keys I used at the time.

File "d:\devOther\samplesTest\NathanMcCorkle\ComboSearchVListBox.py", line 1050, in <module>
   app.MainLoop()
File "c:\Python27\Lib\site-packages\wx-2.9.5-msw\wx\_core.py", line 8660, in MainLoop
   wx.PyApp.MainLoop(self)
File "c:\Python27\Lib\site-packages\wx-2.9.5-msw\wx\_core.py", line 7952, in MainLoop
   return _core_.PyApp_MainLoop(*args, **kwargs)
File "d:\devOther\samplesTest\NathanMcCorkle\ComboSearchVListBox.py", line 572, in OnKeyDown
   self.NotifyItemSelected(self._VListBox.GetItemText(item))
File "d:\devOther\samplesTest\NathanMcCorkle\ComboSearchVListBox.py", line 657, in NotifyItemSelected
   self._text.SetValue(text)
File "c:\Python27\Lib\site-packages\wx-2.9.5-msw\wx\_core.py", line 13078, in SetValue
   return _core_.TextEntryBase_SetValue(*args, **kwargs)

TypeError: String or Unicode type required

O.K. just got it again and as I am in Wing IDE I can see that 'text' in NotifyItemSelected is "None". You might change the debug line to:
logging.debug("ComboSearchVListBox NotifyItemSelected: %s", text)

It seems to happen each time if you enter text and then hit "Enter", with debug I have these last few entries:
DEBUG:root:**********************
DEBUG:root:keycode pressed: 97
DEBUG:root:searchFtestList STRING BEFORE: thi
DEBUG:root:alphanumeric key pressed
DEBUG:root:searchFtestList STRING AFTER: thia

DEBUG:root:IsPopupShown == True
DEBUG:root:textbox OnKeyDown
DEBUG:root:textbox OnKeyDown RETURN PRESSED on item: -1 --- itemText: None
DEBUG:root:ComboSearchVListBox NotifyItemSelected: None

You might want to make it compatible with Phoenix, following low hanging changes:
- wx.TE_PROCESS_ENTER instead of wx.PROCESS_ENTER
- wx.Bitmap instead of wx.EmptyBitmap

You might want to add '#!/usr/bin/env python' as the first line.

If you want to release it I think you might want to add more documentation, if you do consider the Phoenix style:
http://wxpython.org/Phoenix/docs/html/DocstringsGuidelines.html

Also seeing this exception, but can't recreate it:
File "d:\devOther\samplesTest\NathanMcCorkle\ComboSearchVListBox.py", line 1053, in <module>
   app.MainLoop()
File "c:\Python27\Lib\site-packages\wx-3.0.2-msw-phoenix\wx\core.py", line 1879, in MainLoop
   rv = wx.PyApp.MainLoop(self)
File "d:\devOther\samplesTest\NathanMcCorkle\ComboSearchVListBox.py", line 247, in OnMouseHover
   self._VListBox.SetSelection(item)

wx._core.wxAssertionError: C++ assertion "selection == (-1) || (selection >= 0 && (size_t)selection < GetItemCount())" failed at ..\..\src\generic\vlbox.cpp(286) in wxVListBox::SetSelection(): wxVListBox::SetSelection(): invalid item index

Will try and test on Linux Mint later today.

Wern

···

On 9/3/2014 1:11, Nathan McCorkle wrote:

Only have Phoenix on my Linux Mint box, so found one more:

  • wx.SystemSettings.GetColour instead of wx.SystemSettings_GetColour
    Besides that it works the same as on Windows, but from a UI point of
    view the buttons are not quite correctly sized.
    The button is slightly to high and the arrow is not centred
    horizontally.
    Werner
···

Hi Nathan,

  On 9/3/2014 1:11, Nathan McCorkle wrote:
    One bug I'm still working on is that the scrollbars

don’t show the correct size when wordWrap is being used… but I
will let the other thread I started serve for debugging that.

      Here I just want some folks to give this a try... it should

essentially be like the Google Chrome URL bar… where the
textbox acts as a search box for the history and shows results
in a drop-down. With Chrome the browser history is used for
searching, but with this widget you add items to the list just
like any list… and can drop-down the full-list of items too.

      Worked hard on this, and I think it is pretty good, but

obviously it probably isn’t perfect!

Hi Nathan,

Lets see if the image works this time:

Werner

gicjifba.png

Hi Nathan,

here's a couple of comments from a quick look:

Keyboard navigation:
If a valid item from the list is selected and the popup is not shown,
I would expect pressing an arrow key to show the popup, but not advance the selection.

If after typing in the text entry box there is only one selection left in the list,
it could be automatically copied to the text entry,
or selectable by pressing ENTER.

ENTER on the numpad does not work.

No mouse scrolling in the popup.

The popups are shown as separate windows in the windows taskbar.
Combotreebox does this, too.

If you open both popups, it's very hard to distinguish them.
The upper popup overlays part of the lower popup,
I can select an item from the lower popup which sticks out under the upper popup.
Confusing. I'd expect the lower popup to close when I open the upper one.
See attached image. Item-82 is from the lower popup.

Unicode:
Traceback (most recent call last):
   File "C:\Users\michael\Desktop\ComboSearchVListBox.py", line 450, in ProcessKeyboard
     string += chr(keycode)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 0: ordinal not in range(128)

Noticed, but can't reproduce:
Keyboard navigation in the popup worked only when opening the popup with arrow keys,
not when opening the popup with mouse-click on arrow.
Keyboard navigates only through first 3 list items.

Win7 / 3.0.0.0 classic

Michael

···

On Wed, 03 Sep 2014 01:11:53 +0200, Nathan McCorkle <nmz787@gmail.com> wrote:

One bug I'm still working on is that the scrollbars don't show the correct
size when wordWrap is being used... but I will let the other thread I
started serve for debugging that.

Here I just want some folks to give this a try... it should essentially be
like the Google Chrome URL bar... where the textbox acts as a search box
for the history and shows results in a drop-down. With Chrome the browser
history is used for searching, but with this widget you add items to the
list just like any list... and can drop-down the full-list of items too.

Worked hard on this, and I think it is pretty good, but obviously it
probably isn't perfect!

P.S. I based this off of the combotreebox.py code, but I REALLY HATED the
platform-specific subclassing that file has going on in it... It made
hacking the code MUCH harder because all the sub/super class methods with
identical names made tracing code flow really slow... so I moved
platform-specific stuff to happen during the class construction.

Hi Nathan,

One bug I’m still working on is that the scrollbars don’t show the
correct size when wordWrap is being used… but I will let the other
thread I started serve for debugging that.

Here I just want some folks to give this a try… it should
essentially be like the Google Chrome URL bar… where the textbox
acts as a search box for the history and shows results in a drop-down.
With Chrome the browser history is used for searching, but with this
widget you add items to the list just like any list… and can
drop-down the full-list of items too.

Worked hard on this, and I think it is pretty good, but obviously it
probably isn’t perfect!

I gave this a try, initially on Windows 8.1, but will also try it on
Linux Mint.

Works well for me with the exception of the following.

Got following exception on the second control, typing into it “thi”, but
I can’t reproduce it on demand, so it must be some other keys I used at
the time.

I think this is fixed, as I don’t get errors when I mash the keyboard while using the ALT and/or CTRL and/or Shift keys with the alphanumerics.

File “d:\devOther\samplesTest\NathanMcCorkle\ComboSearchVListBox.py”,
line 1050, in

app.MainLoop()

File “c:\Python27\Lib\site-packages\wx-2.9.5-msw\wx_core.py”, line
8660, in MainLoop

wx.PyApp.MainLoop(self)

File “c:\Python27\Lib\site-packages\wx-2.9.5-msw\wx_core.py”, line
7952, in MainLoop

return core.PyApp_MainLoop(*args, **kwargs)

File “d:\devOther\samplesTest\NathanMcCorkle\ComboSearchVListBox.py”,
line 572, in OnKeyDown

self.NotifyItemSelected(self._VListBox.GetItemText(item))

File “d:\devOther\samplesTest\NathanMcCorkle\ComboSearchVListBox.py”,
line 657, in NotifyItemSelected

self._text.SetValue(text)

File “c:\Python27\Lib\site-packages\wx-2.9.5-msw\wx_core.py”, line
13078, in SetValue

return core.TextEntryBase_SetValue(*args, **kwargs)

TypeError: String or Unicode type required

O.K. just got it again and as I am in Wing IDE I can see that ‘text’ in
NotifyItemSelected is “None”. You might change the debug line to:

logging.debug(“ComboSearchVListBox NotifyItemSelected: %s”, text)

It seems to happen each time if you enter text and then hit “Enter”,
with debug I have these last few entries:

DEBUG:root:**********************

DEBUG:root:keycode pressed: 97

DEBUG:root:searchFtestList STRING BEFORE: thi

DEBUG:root:alphanumeric key pressed

DEBUG:root:searchFtestList STRING AFTER: thia

DEBUG:root:IsPopupShown == True

DEBUG:root:textbox OnKeyDown

DEBUG:root:textbox OnKeyDown RETURN PRESSED on item: -1 — itemText: None

DEBUG:root:ComboSearchVListBox NotifyItemSelected: None

Pretty sure I fixed this.

You might want to make it compatible with Phoenix, following low hanging
changes:

  • wx.TE_PROCESS_ENTER instead of wx.PROCESS_ENTER

Done.

  • wx.Bitmap instead of wx.EmptyBitmap

Hmm, tried substituting but it looks like it isn’t that simple. Any suggestions for how to change the code to get a blank 10x16 Bitmap?

You might want to add ‘#!/usr/bin/env python’ as the first line.

Hmm, even though this wouldn’t normally be used standalone?

If you want to release it I think you might want to add more
documentation, if you do consider the Phoenix style:

http://wxpython.org/Phoenix/docs/html/DocstringsGuidelines.html

Also seeing this exception, but can’t recreate it:

line 247, in OnMouseHover

self._VListBox.SetSelection(item)

Fixed.

Will try and test on Linux Mint later today.

Wern

Thanks!

···

On Wednesday, September 3, 2014 2:39:24 AM UTC-7, werner wrote:

On 9/3/2014 1:11, Nathan McCorkle wrote:

OK, I put some more work into this and think I’ve got most of the bugs worked out.

Hi Nathan,

here’s a couple of comments from a quick look:

Keyboard navigation:

If a valid item from the list is selected and the popup is not shown,

I would expect pressing an arrow key to show the popup, but not advance

the selection.

Done.

If after typing in the text entry box there is only one selection left in

the list,

it could be automatically copied to the text entry,

or selectable by pressing ENTER.

Not done, checking Google Chrome now, they autocomplete with the first entry and highlight AFTER the caret, so subsequent typing overwrites the autocompleted text. That would be nice to add, once the existing bugs are all squashed!

ENTER on the numpad does not work.

Done.

No mouse scrolling in the popup.

Done, scrolling should work on the text box or on the popup (I actually am now binding LEFT_UP on the popup and setting focus back to the textbox when the event fires).

The popups are shown as separate windows in the windows taskbar.

Combotreebox does this, too.

Got rid of that by adding to the popup Frame style wx.FRAME_NO_TASKBAR

If you open both popups, it’s very hard to distinguish them.

The upper popup overlays part of the lower popup,
I can select an item from the lower popup which sticks out under the upper

popup.

Confusing. I’d expect the lower popup to close when I open the upper one.

See attached image. Item-82 is from the lower popup.

Ok that was definitely not my intention… hiding the popup if any non-popup-related item is clicked (though clicking the panel doesn’t generate a KILL_FOCUS, and I’m not sure I want to try relying on binding LEFT_DOWN or LEFT_UP on the widget.GetParent()… that doesn’t seem like it would work reliably in nested Panels for example)

Unicode:

Traceback (most recent call last):

File “C:\Users\michael\Desktop\ComboSearchVListBox.py”, line 450, in

ProcessKeyboard

 string += chr(keycode)

UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xe4 in position 0:

ordinal not in range(128)

Noticed, but can’t reproduce:

Keyboard navigation in the popup worked only when opening the popup with

arrow keys,

not when opening the popup with mouse-click on arrow.

I think this was focus related, bound the navigation to the popup and setting the focus back to the textbox after interacting with the popup.

Keyboard navigates only through first 3 list items.

Hmm, can you try again?

ComboSearchVListBox.py (47.6 KB)

···

On Wednesday, September 3, 2014 5:22:46 AM UTC-7, Michael Ross wrote:

Ermm, ok found another bug in the keyboard navigation. Try this one.

ComboSearchVListBox.py (47.9 KB)

···

On Friday, September 19, 2014 7:16:32 PM UTC-7, Nathan McCorkle wrote:

OK, I put some more work into this and think I’ve got most of the bugs worked out.


I do it like this in my stuff:
if ‘phoenix’ in wx.PlatformInfo:
bitmap = wx.Bitmap(size, size)
else:
bitmap = wx.EmptyBitmap(size, size)
I would as I always would have the “if name == “main”:”
stuff at the end for testing the widget.
Werner

···

Hi Nathan,

  I'll give it a try sometimes next week.

  On 9/20/2014 4:07, Nathan McCorkle wrote:
      -

wx.Bitmap instead of wx.EmptyBitmap

      Hmm, tried substituting but it looks like it isn't that

simple. Any suggestions for how to change the code to get a
blank 10x16 Bitmap?

      You

might want to add ‘#!/usr/bin/env python’ as the first line.

Hmm, even though this wouldn’t normally be used standalone?

In OnKeyUp and in OnMouseHover I sometimes get an exception
“TypeError: TextEntry.ChangeValue: argument 1 has unexpected type
‘NoneType’”.
Can make this happen all the time on my Mint install but only very
randomly on Windows 8.1.
Suggested correction:
def OnKeyUp(self, keyEvent):
item = self._VListBox.GetSelection()

···

Hi Nathan,

  On 9/20/2014 5:02, Nathan McCorkle wrote:
    On Friday, September 19, 2014 7:16:32 PM UTC-7, Nathan McCorkle

wrote:

          OK, I put some more work into this and think I've got

most of the bugs worked out.

      Ermm, ok found another bug in the keyboard navigation. Try

this one.

http://wxpython.org/Phoenix/docs/html/ComboCtrl.html#appearance-control-appearance

Much better.

Observations:

If I type a string into the text box which is not in the suggestion list,
and press <down> or <up> before confirming with <enter>,
the text I typed is deleted.

When I press an arrow key while the arrow control has focus,
focus jumps to the next control.
Like, set focus to the lower arrow control, press <down>,
focus jumps to the upper text control.

Have you thought of not having a separate control for the arrow but
putting it inside the text control, like Firefox does ( attached screenshot )?
This would take the arrow out of the tabbing loop as well.
( and you'd have only one control determining if the popup should be shown?
that could help closing it at the appropriate moment, see below )

Minor inconsistency:
Select a option from the suggestion list, confirm with enter.
Open suggestion list again, do *not* change selection, press <esc>.
Cursor is at end of text in text control.
Open suggestion list again, *do* change selection, press <esc>.
Cursor is at start of text in text control.

The search function could be enhanced to:
- be case insensitive
- search substrings too.

Really Bad Focus trouble:
Start the sample app,
press: <down> <tab> <tab>.
Now the focus is in a control that is not visible to the user.
Continue by pressing <down>.
Now you've opened the lower suggestion list, and if you type something,
you change the lower text, completely invisible to the user.

I had to delete the wxversion check at the top to get it running here
on 3.0.0 classic.

Soon as I find time I'll look at the actual code, too.
( Looks much more promising then wx.ComboControl,
I'll to plug a tree list in there )

Michael

Unbenannt.png

···

On Sat, 20 Sep 2014 05:02:22 +0200, Nathan McCorkle <nmz787@gmail.com> wrote:

On Friday, September 19, 2014 7:16:32 PM UTC-7, Nathan McCorkle wrote:

OK, I put some more work into this and think I've got most of the bugs
worked out.

Ermm, ok found another bug in the keyboard navigation. Try this one.