Hello,
Using classic ( 2.8 / 2.9 / 3.0 ) on Windows 7.
I've been trying a couple of hours now,
but I can't figure out how to get around this:
The code managing the ComboTreeBox popup is ( from wx.lib.combotreebox )
def OnMouseClick(self, event):
if self._popupFrame.IsShown():
self.Hide()
else:
self.Popup()
# Note that we don't call event.Skip() to prevent popping up the
# ComboBox's own box.
def OnKeyDown(self, keyEvent):
if self._keyShouldNavigate(keyEvent):
self._navigateUpOrDown(keyEvent)
elif self._keyShouldPopUpTree(keyEvent):
self.Popup()
else:
keyEvent.Skip()
OnMouseClick works as expected.
OnKeyDown w/ ALT+DOWN pops up *both* the ComboTreeBox popup and the ComboBox own popup.
If I disable the OnKeyDown method above,
only the ComboBox own popup shows,
and don't seem to be able to figure out how to avoid this.
I've caught KeyEvents all over the used classes, no success.
Fails in the demo as well, screenshot: https://gurder.ross.cx/public/combotreebox.png
Hints would be much appreciated.
Additional: With OpenSUSE and wxGTK this works as expected.
Michael
Is OnKeyDown getting called twice, since you’re sequentially pressing the two keyboard buttons?
···
On Sunday, July 13, 2014 9:47:09 AM UTC-7, Michael Ross wrote:
Hello,
Using classic ( 2.8 / 2.9 / 3.0 ) on Windows 7.
I’ve been trying a couple of hours now,
but I can’t figure out how to get around this:
The code managing the ComboTreeBox popup is ( from wx.lib.combotreebox )
def OnMouseClick(self, event):
if self._popupFrame.IsShown():
self.Hide()
else:
self.Popup()
# Note that we don't call event.Skip() to prevent popping up the
# ComboBox's own box.
def OnKeyDown(self, keyEvent):
if self._keyShouldNavigate(keyEvent):
self._navigateUpOrDown(keyEvent)
elif self._keyShouldPopUpTree(keyEvent):
self.Popup()
else:
keyEvent.Skip()
OnMouseClick works as expected.
OnKeyDown w/ ALT+DOWN pops up both the ComboTreeBox popup and the
ComboBox own popup.
If I disable the OnKeyDown method above,
only the ComboBox own popup shows,
and don’t seem to be able to figure out how to avoid this.
I’ve caught KeyEvents all over the used classes, no success.
Fails in the demo as well, screenshot:
https://gurder.ross.cx/public/combotreebox.png
Hints would be much appreciated.
Additional: With OpenSUSE and wxGTK this works as expected.
Michael
Is OnKeyDown getting called twice, since you're sequentially pressing the
two keyboard buttons?
I hold ALT down and it gets called over and over.
I press DOWN, ComboTreeBox popup ( well, both popups ) shows,
focus changes to ComboTreeBox popup. Method does not get called again.
I tried with
def OnKeyDown(self, keyEvent):
return
which as expected does disable the ComboTreeBox popup.
But not the ComboBox own popup.
Returning without action from def Popup() in wx._controls.ComboBox does not stop this
from popping up either, this method does not get called.
Thanks,
Michael
···
On Mon, 14 Jul 2014 19:33:11 +0200, Nathan McCorkle <nmz787@gmail.com> wrote:
On Sunday, July 13, 2014 9:47:09 AM UTC-7, Michael Ross wrote:
Hello,
Using classic ( 2.8 / 2.9 / 3.0 ) on Windows 7.
I've been trying a couple of hours now,
but I can't figure out how to get around this:
The code managing the ComboTreeBox popup is ( from wx.lib.combotreebox )
def OnMouseClick(self, event):
if self._popupFrame.IsShown():
self.Hide()
else:
self.Popup()
# Note that we don't call event.Skip() to prevent popping up the
# ComboBox's own box.
def OnKeyDown(self, keyEvent):
if self._keyShouldNavigate(keyEvent):
self._navigateUpOrDown(keyEvent)
elif self._keyShouldPopUpTree(keyEvent):
self.Popup()
else:
keyEvent.Skip()
OnMouseClick works as expected.
OnKeyDown w/ ALT+DOWN pops up *both* the ComboTreeBox popup and the
ComboBox own popup.
If I disable the OnKeyDown method above,
only the ComboBox own popup shows,
and don't seem to be able to figure out how to avoid this.
I've caught KeyEvents all over the used classes, no success.
Fails in the demo as well, screenshot:
https://gurder.ross.cx/public/combotreebox.png
Hints would be much appreciated.
Additional: With OpenSUSE and wxGTK this works as expected.
Michael
Hi Michael,
I just tried on Windows 8.1, wxPython 3.0 classic and Python 2.7 and either I don't get what your problem is or I can not recreate it.
I see the following which I think is correct.
Werner

Hi Werner,
Your screenshot looks as if you opened the popup by clicking on the arrow at the right?
This works ok here, too.
Problem arises when opening the popup with the keyboard, using ALT-DOWN.
I've attached a better screenshot, this time from the actual application.
You can see the ComboTreeBox popup in white, much wider than the TextCtrl,
( this is as I want it ),
and laying over it the ComboBox(?) own popup with the background color inherited from the TextCtrl.
For comparison another screenshot, how it looks like if I open the popup with the mouse.
I see this behaviour on Windows 7 and on Windows Server 2008 R2. Python 2.7.5.
Thanks,
Michael
···
On Mon, 14 Jul 2014 20:12:50 +0200, Werner <wernerfbd@gmx.ch> wrote:
Hi Michael,
I just tried on Windows 8.1, wxPython 3.0 classic and Python 2.7 and
either I don't get what your problem is or I can not recreate it.
I see the following which I think is correct.
Werner
I was able to replicate the problem on wxPython 3.0 and Python 2.7.5 on Win 7 Pro.
I was able to fix the problem in the wxPython demo ComboTreeBox.py by adding these lines:
def _bindEventHandlers(self, comboBox):
for eventType, handler in [(wx.EVT_COMBOBOX, self.OnItemSelected),
(wx.EVT_TEXT, self.OnItemEntered)]:
comboBox.Bind(eventType, handler)
comboBox.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
comboBox.Bind(wx.EVT_KEY_UP, self.OnKeyUp)
def OnKeyDown(self, keyEvent):
return
def OnKeyUp(self, keyEvent):
obj = keyEvent.GetEventObject()
if obj._keyShouldNavigate(keyEvent):
obj._navigateUpOrDown(keyEvent)
elif obj._keyShouldPopUpTree(keyEvent):
obj.Popup()
else:
keyEvent.Skip()
I think the KeyDown was propagating to the native control, and getting drawn, but after the Popup() method was drawn. Since KeyUp happens after KeyDown, I’m assuming the native control get’s drawn first, then the KeyUp and Popup() happen, drawing on top of the native combo box.
It would be good to create a ticket () and
attach a patch (IIRC Robin prefers it in ‘unified’ format) to it.
Werner
P.S.
When using ‘alt-down’ I can see the issue also and it is still in
Phoenix too.
···
Hi Nathan and Michael,
On 7/14/2014 22:09, Nathan McCorkle wrote:
I was able to replicate the problem on wxPython 3.0
and Python 2.7.5 on Win 7 Pro.
I was able to fix the problem in the wxPython demo
ComboTreeBox.py by adding these lines:
def
_bindEventHandlers(self, comboBox):
for
eventType, handler in [(wx.EVT_COMBOBOX,
self.OnItemSelected),
(wx.EVT_TEXT, self.OnItemEntered)]:
comboBox.Bind(eventType, handler)
comboBox.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
comboBox.Bind(wx.EVT_KEY_UP, self.OnKeyUp)
def OnKeyDown(self,
keyEvent):
return
def OnKeyUp(self,
keyEvent):
obj =
keyEvent.GetEventObject()
if
obj._keyShouldNavigate(keyEvent):
obj._navigateUpOrDown(keyEvent)
elif
obj._keyShouldPopUpTree(keyEvent):
obj.Popup()
else:
keyEvent.Skip()
I think the KeyDown was propagating to the native
control, and getting drawn, but after the Popup() method was
drawn. Since KeyUp happens after KeyDown, I’m assuming the
native control get’s drawn first, then the KeyUp and Popup()
happen, drawing on top of the native combo box.
http://trac.wxwidgets.org/
Hi Nathan,
This fixes the problem thusly:
The ComboBox popup still gets drawn, but *under* the ComboTreeBox popup,
plus it is destroyed immediately.
( I had to set the ComboTreeBox to 20px to be able to observe that the wrong popup is drawn at all,
so this should be transparent to the user. )
Thanks a lot! I've spent countless hours on this.
As per Werner's suggestion, I created a ticket
wxTrac has been migrated to GitHub Issues - wxWidgets
with the solution attributed to you.
Michael
···
On Mon, 14 Jul 2014 22:09:24 +0200, Nathan McCorkle <nmz787@gmail.com> wrote:
I was able to replicate the problem on wxPython 3.0 and Python 2.7.5 on Win
7 Pro.
I was able to fix the problem in the wxPython demo ComboTreeBox.py by
adding these lines:
def _bindEventHandlers(self, comboBox):
for eventType, handler in [(wx.EVT_COMBOBOX, self.OnItemSelected),
(wx.EVT_TEXT, self.OnItemEntered)]:
comboBox.Bind(eventType, handler)
comboBox.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
comboBox.Bind(wx.EVT_KEY_UP, self.OnKeyUp)
def OnKeyDown(self, keyEvent):
return
def OnKeyUp(self, keyEvent):
obj = keyEvent.GetEventObject()
if obj._keyShouldNavigate(keyEvent):
obj._navigateUpOrDown(keyEvent)
elif obj._keyShouldPopUpTree(keyEvent):
obj.Popup()
else:
keyEvent.Skip()
I think the KeyDown was propagating to the native control, and getting
drawn, but after the Popup() method was drawn. Since KeyUp happens after
KeyDown, I'm assuming the native control get's drawn first, then the KeyUp
and Popup() happen, drawing on top of the native combo box.