Hi,
I would like to configure my wxcombox in a way that when it gets the focus, it automaticly opens his listpart.
Any ideas ?
tia
Rony
A simple, portable way to make a wx.ComboBox open its drop‑down when it receives focus is to bind the focus event and then call the control's popup method from the focus handler. As noted, there are widget extensions that can provide extra behaviors, but the plain wxPython approach below works on most versions if you allow for small API/name differences across releases.
import wx
class TestFrame(wx.Frame):
def __init__(self):
super(TestFrame, self).__init__(None, title="Combo focus popup")
panel = wx.Panel(self)
self.combo = wx.ComboBox(panel, choices=["One", "Two", "Three"])
self.combo.Bind(wx.EVT_SET_FOCUS, self.OnComboFocus)
s = wx.BoxSizer(wx.VERTICAL)
s.Add(self.combo, 0, wx.ALL | wx.EXPAND, 10)
panel.SetSizer(s)
self.Show()
def OnComboFocus(self, event):
# let native focus handling finish, then show popup
wx.CallAfter(self._show_popup)
event.Skip()
def _show_popup(self):
for name in ("ShowPopup", "Popup"):
fn = getattr(self.combo, name, None)
if callable(fn):
fn()
break
if __name__ == "__main__":
app = wx.App(False)
TestFrame()
app.MainLoop() Notes and troubleshooting:
Jump to Post— vegaseat 1,735Andrea Gavana has created quite a few extensions to wxPython widgets in PyAUI, see:
http://www.daniweb.com/techtalkforums/thread40355.html
Andrea Gavana has created quite a few extensions to wxPython widgets in PyAUI, see:
http://www.daniweb.com/techtalkforums/thread40355.html
Andrea Gavana has created quite a few extensions to wxPython widgets in PyAUI, see:
http://www.daniweb.com/techtalkforums/thread40355.html
Thanks for the link ! I'll see what I can do with those
Rony
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.