Я создал раскрывающийся список, используя wxcomboctrl.wxWidgets - как добавить полосы прокрутки в ListBox, созданные с помощью виджета comboctrl в wxpython
self.Worker = wx.combo.ComboCtrl(self, -1, size=(250, -1), style=wx.CB_DROPDOWN)
self.testWorkloadComboCtrl = self.ListCtrlComboPopup()
self.worker.SetPopupControl(self.workerComboCtrl)
class ListCtrlComboPopup(wx.ListCtrl, wx.combo.ComboPopup):
def __init__(self):
self.PostCreate(wx.PreListCtrl())
# Also init the ComboPopup base class.
wx.combo.ComboPopup.__init__(self)
def AddItem(self, txt):
for t in txt:
self.InsertStringItem(self.GetItemCount(), t)
def OnMotion(self, evt):
item, flags = self.HitTest(evt.GetPosition())
if item >= 0:
self.Select(item)
self.curitem = item
def OnLeftDown(self, evt):
self.value = self.curitem
self.Dismiss()
# The following methods are those that are overridable from the
# ComboPopup base class.
def Init(self):
""" This is called immediately after construction finishes. You can
use self.GetCombo if needed to get to the ComboCtrl instance. """
self.value = -1
self.curitem = -1
def Create(self, parent):
""" Create the popup child control. Return True for success. """
wx.ListCtrl.Create(self, parent,
style=wx.LC_LIST|wx.LC_SINGLE_SEL|wx.SIMPLE_BORDER)
self.Bind(wx.EVT_MOTION, self.OnMotion)
self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
return True
def GetControl(self):
""" Return the widget that is to be used for the popup. """
return self
def SetStringValue(self, val):
""" Called just prior to displaying the popup, you can use it to
'select' the current item. """
idx = self.FindItem(-1, val)
if idx != wx.NOT_FOUND:
self.Select(idx)
def GetStringValue(self):
""" Return a string representation of the current item. """
if self.value >= 0:
return self.GetItemText(self.value)
return ""
def OnPopup(self):
""" Called immediately after the popup is shown. """
wx.combo.ComboPopup.OnPopup(self)
def OnDismiss(self):
" Called when popup is dismissed. """
wx.combo.ComboPopup.OnDismiss(self)
Выпадающий список, отображающий элементы, такие как 2 или 3 столбца с горизонтальной полосой прокрутки.
Но я хочу отобразить один список элементов с горизонтальными и вертикальными полосами прокрутки.
Я искал свойства comboctrl, но до сих пор не понял о comboctrl.
Может ли кто-нибудь предложить мне об этом.
Вы пробовали использовать wxFormBuilder https://sourceforge.net/projects/wxformbuilder/ – macroland