Discussion:
Can someone test my new widget (I'm on Windows only)?
Nathan McCorkle
2014-09-02 23:11:53 UTC
Permalink
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.
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Werner
2014-09-03 09:39:34 UTC
Permalink
Hi Nathan,
Post by Nathan McCorkle
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
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Nathan McCorkle
2014-09-20 02:07:38 UTC
Permalink
Post by Werner
Hi Nathan,
Post by Nathan McCorkle
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.
Post by Werner
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
logging.debug("ComboSearchVListBox NotifyItemSelected: %s", text)
It seems to happen each time if you enter text and then hit "Enter",
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.
Post by Werner
You might want to make it compatible with Phoenix, following low hanging
- wx.TE_PROCESS_ENTER instead of wx.PROCESS_ENTER
Done.
Post by Werner
- 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?
Post by Werner
You might want to add '#!/usr/bin/env python' as the first line.
Hmm, even though this wouldn't normally be used standalone?
Post by Werner
If you want to release it I think you might want to add more
http://wxpython.org/Phoenix/docs/html/DocstringsGuidelines.html
line 247, in OnMouseHover
self._VListBox.SetSelection(item)
Fixed.
Post by Werner
Post by Nathan McCorkle
Will try and test on Linux Mint later today.
Wern
Thanks!
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Werner
2014-09-20 06:28:11 UTC
Permalink
Hi Nathan,

I'll give it a try sometimes next week.

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

...
Post by Werner
- 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?
I do it like this in my stuff:
if 'phoenix' in wx.PlatformInfo:
bitmap = wx.Bitmap(size, size)
else:
bitmap = wx.EmptyBitmap(size, size)
Post by Werner
You might want to add '#!/usr/bin/env python' as the first line.
Hmm, even though this wouldn't normally be used standalone?
I would as I always would have the "if __name__ == "__main__":" stuff at
the end for testing the widget.

Werner
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Werner
2014-09-03 11:30:40 UTC
Permalink
Hi Nathan,
Post by Nathan McCorkle
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!
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
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Werner
2014-09-03 11:38:45 UTC
Permalink
Hi Nathan,

Lets see if the image works this time:



Werner
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Michael Ross
2014-09-03 12:22:33 UTC
Permalink
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
Post by Nathan McCorkle
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.
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Nathan McCorkle
2014-09-20 02:16:31 UTC
Permalink
OK, I put some more work into this and think I've got most of the bugs
worked out.
Post by Werner
Hi Nathan,
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.
Post by Werner
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!
Post by Werner
ENTER on the numpad does not work.
Done.
Post by Werner
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).
Post by Werner
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
Post by Werner
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
Post by Werner
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)
Post by Werner
File "C:\Users\michael\Desktop\ComboSearchVListBox.py", line 450, in
ProcessKeyboard
string += chr(keycode)
ordinal not in range(128)
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.
Post by Werner
Keyboard navigates only through first 3 list items.
Hmm, can you try again?
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Nathan McCorkle
2014-09-20 03:02:22 UTC
Permalink
Post by Nathan McCorkle
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.
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Werner
2014-09-22 09:47:38 UTC
Permalink
Hi Nathan,
Post by Nathan McCorkle
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.
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()
- self.GetParent()._text.ChangeValue(self._VListBox.GetItemText(item))
+ v = self._VListBox.GetItemText(item)
+ if v:
+ self.GetParent()._text.ChangeValue(v)


def OnMouseHover(self, event):
if not self._VListBox.hoverEnabled:
return
item = self._VListBox.HitTest(event.GetPosition())
- if item>=0:
- self.GetParent()._text.ChangeValue(self._VListBox.GetItemText(item))
+ v = self._VListBox.GetItemText(item)
+ if v:
+ self.GetParent()._text.ChangeValue(v)
self._VListBox.SetSelection(item)

The little arrows looks much better on Mint now, but the alignment is
not the same. The down one is right aligned in the button and the up
one is left aligned.

Maybe instead of using two buttons for that use 'SetBitmap' on only one
button.

BTW, did you consider basing it all on wx.ComboCtrl, that seems to
support different bitmaps depending on state of control and control
adjusts appearance to the platforms.
http://wxpython.org/Phoenix/docs/html/ComboCtrl.html#appearance-control-appearance

Werner
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Michael Ross
2014-09-26 09:53:09 UTC
Permalink
Post by Nathan McCorkle
Post by Nathan McCorkle
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.
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
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Continue reading on narkive:
Loading...