本文整理汇总了Python中wx.ListBox方法的典型用法代码示例。如果您正苦于以下问题:Python wx.ListBox方法的具体用法?Python wx.ListBox怎么用?Python wx.ListBox使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wx
的用法示例。
在下文中一共展示了wx.ListBox方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _do_layout
# 需要导入模块: import wx [as 别名]
# 或者: from wx import ListBox [as 别名]
def _do_layout(self):
self.SetDoubleBuffered(True)
self.SetBackgroundColour('#f2f2f2')
self.SetSize((180, 0))
self.SetMinSize((180, 0))
STD_LAYOUT = (0, wx.LEFT | wx.RIGHT | wx.EXPAND, 10)
container = wx.BoxSizer(wx.VERTICAL)
container.AddSpacer(15)
container.Add(wx_util.h1(self, 'Actions'), *STD_LAYOUT)
container.AddSpacer(5)
self.listbox = wx.ListBox(self, -1)
container.Add(self.listbox, 1, wx.LEFT | wx.RIGHT | wx.EXPAND, 10)
container.AddSpacer(20)
self.SetSizer(container)
self.Bind(wx.EVT_LISTBOX, self.selection_change, self.listbox)
示例2: _do_layout
# 需要导入模块: import wx [as 别名]
# 或者: from wx import ListBox [as 别名]
def _do_layout(self):
self.SetDoubleBuffered(True)
self.SetBackgroundColour('#f2f2f2')
self.SetSize((180, 0))
self.SetMinSize((180, 0))
STD_LAYOUT = (0, wx.LEFT | wx.RIGHT | wx.EXPAND, 10)
container = wx.BoxSizer(wx.VERTICAL)
container.AddSpacer(15)
container.Add(wx_util.h1(self, 'Actions'), *STD_LAYOUT)
container.AddSpacer(5)
thing = wx.ListBox(self, -1, choices=self.contents)
container.Add(thing, 1, wx.LEFT | wx.RIGHT | wx.EXPAND, 10)
container.AddSpacer(20)
self.SetSizer(container)
thing.SetSelection(0)
self.Bind(wx.EVT_LISTBOX, self.onClick, thing)
示例3: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import ListBox [as 别名]
def __init__(self, parent, id, title):
wx.Dialog.__init__(self, parent, id, title)
self.selection_idx = None
self.selection_text = None
vbox = wx.BoxSizer(wx.VERTICAL)
stline = wx.StaticText(
self,
11,
'Duplicate Component values found!'
'\n\nPlease select which format to follow:')
vbox.Add(stline, 0, wx.ALIGN_CENTER|wx.TOP)
self.comp_list = wx.ListBox(self, 331, style=wx.LB_SINGLE)
vbox.Add(self.comp_list, 1, wx.ALIGN_CENTER_HORIZONTAL | wx.EXPAND)
self.SetSizer(vbox)
self.comp_list.Bind(wx.EVT_LISTBOX_DCLICK, self.on_selection, id=wx.ID_ANY)
self.Show(True)
示例4: _on_text_click
# 需要导入模块: import wx [as 别名]
# 或者: from wx import ListBox [as 别名]
def _on_text_click(self, event):
if self.deactivated and not self.auto_activated and self.text:
text_rect = self.text.GetClientRect()
text_rect.Offset(self.text.Position)
if text_rect.Contains(event.Position):
self.toggle_active(active=True)
return
event.Skip()
#class ListBoxProperty(ComboBoxProperty):
#def __init__(self, value="", choices=[], default_value=_DefaultArgument, name=None):
#self.choices = choices
#TextProperty.__init__(self, value, False, default_value, name)
#def create_text_ctrl(self, panel, value):
#style = wx.LB_SINGLE
#combo = wx.ListBox( panel, -1, self.value, choices=self.choices, style=style )
#combo.Bind(wx.EVT_LISTBOX, self.on_combobox)
##combo.Bind(wx.EVT_KILL_FOCUS, self.on_kill_focus)
##combo.Bind(wx.EVT_CHAR, self.on_char)
#return combo
示例5: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import ListBox [as 别名]
def __init__(self, *args, **kwds):
# begin wxGlade: TemplateListDialog.__init__
kwds["style"] = wx.DEFAULT_DIALOG_STYLE
wx.Dialog.__init__(self, *args, **kwds)
self.template_names = wx.ListBox(self, wx.ID_ANY, choices=[])
self.template_name = wx.StaticText(self, wx.ID_ANY, _("wxGlade template:\n"))
self.author = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_READONLY)
self.description = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_MULTILINE | wx.TE_READONLY)
self.instructions = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_MULTILINE | wx.TE_READONLY)
self.btn_open = wx.Button(self, wx.ID_OPEN, "")
self.btn_edit = wx.Button(self, ID_EDIT, _("&Edit"))
self.btn_delete = wx.Button(self, wx.ID_DELETE, "")
self.btn_cancel = wx.Button(self, wx.ID_CANCEL, "")
self.__set_properties()
self.__do_layout()
self.Bind(wx.EVT_LISTBOX_DCLICK, self.on_open, self.template_names)
self.Bind(wx.EVT_LISTBOX, self.on_select_template, self.template_names)
self.Bind(wx.EVT_BUTTON, self.on_open, self.btn_open)
self.Bind(wx.EVT_BUTTON, self.on_edit, id=ID_EDIT)
self.Bind(wx.EVT_BUTTON, self.on_delete, self.btn_delete)
# end wxGlade
示例6: SetChoices
# 需要导入模块: import wx [as 别名]
# 或者: from wx import ListBox [as 别名]
def SetChoices(self, choices):
max_text_width = 0
max_text_height = 0
self.ListBox.Clear()
for choice in choices:
self.ListBox.Append(choice)
w, h = self.ListBox.GetTextExtent(choice)
max_text_width = max(max_text_width, w)
max_text_height = max(max_text_height, h)
itemcount = min(len(choices), MAX_ITEM_SHOWN)
width = self.Parent.GetSize()[0]
height = \
max_text_height * itemcount + \
LISTBOX_INTERVAL_HEIGHT * max(0, itemcount - 1) + \
2 * LISTBOX_BORDER_HEIGHT
if max_text_width + 10 > width:
height += 15
size = wx.Size(width, height)
if wx.Platform == '__WXMSW__':
size.width -= 2
self.ListBox.SetSize(size)
self.SetClientSize(size)
示例7: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import ListBox [as 别名]
def __init__(self, parent):
wx.ListBox.__init__(self, parent, -1)
wx.EVT_LISTBOX(self, self.GetId(), self.OnPageChange)
# get a list of all the pages
示例8: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import ListBox [as 别名]
def __init__(self, parent, size, data, *args, **kwargs):
wx.ListBox.__init__(self, parent, size, **kwargs)
if isinstance(data,(pd.RangeIndex,pd.Int64Index)):
# RangeIndex is not supported by self._update_columns
data = pd.Index([str(i) for i in data])
self.data = data
self.InsertItems(self.data, 0)
self.Bind(wx.EVT_LISTBOX, self.on_selection_changed)
self.Bind(wx.EVT_LEFT_DOWN, self.on_left_down)
self.Bind(wx.EVT_RIGHT_DOWN, self.on_right_down)
self.Bind(wx.EVT_RIGHT_UP, self.on_right_up)
self.Bind(wx.EVT_MOTION, self.on_move)
self.index_iter = range(len(self.data))
self.selected_items = [True] * len(self.data)
self.index_mapping = list(range(len(self.data)))
self.drag_start_index = None
self.update_selection()
self.SetFocus()
示例9: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import ListBox [as 别名]
def __init__(self, parent, buildSpec, configPanels, *args, **kwargs):
super(Sidebar, self).__init__(parent, *args, **kwargs)
self._parent = parent
self.buildSpec = buildSpec
self.configPanels = configPanels
self.activeSelection = 0
self.options = list(self.buildSpec['widgets'].keys())
self.leftPanel = wx.Panel(self)
self.label = wx_util.h1(self.leftPanel, self.buildSpec.get('sidebar_title'))
self.listbox = wx.ListBox(self.leftPanel, -1, choices=self.options)
self.Bind(wx.EVT_LISTBOX, self.swapConfigPanels, self.listbox)
self.layoutComponent()
self.listbox.SetSelection(0)
示例10: getWidget
# 需要导入模块: import wx [as 别名]
# 或者: from wx import ListBox [as 别名]
def getWidget(self, parent, *args, **options):
height = self._options.get('height', 60)
return wx.ListBox(
parent=parent,
choices=self._meta['choices'],
size=(-1, height),
style=wx.LB_MULTIPLE
)
示例11: _remove_prefix
# 需要导入模块: import wx [as 别名]
# 或者: from wx import ListBox [as 别名]
def _remove_prefix(self, string):
if string[:len(self.TEXT_PREFIX)] == self.TEXT_PREFIX:
return string[len(self.TEXT_PREFIX):]
return string
# wx.ListBox methods
示例12: GetString
# 需要导入模块: import wx [as 别名]
# 或者: from wx import ListBox [as 别名]
def GetString(self, index):
if index < 0 or index >= self.GetCount():
# Return empty string based on the wx.ListBox docs
# for some reason parent GetString does not handle
# invalid indices
return ""
return self._remove_prefix(super(ListBoxWithHeaders, self).GetString(index))
示例13: crt_listbox
# 需要导入模块: import wx [as 别名]
# 或者: from wx import ListBox [as 别名]
def crt_listbox(self, choices, style=None):
if style is None:
listbox = wx.ListBox(self, choices=choices, size=self.LISTBOX_SIZE)
else:
listbox = wx.ListBox(self, choices=choices, style=style, size=self.LISTBOX_SIZE)
return listbox
示例14: create_widget
# 需要导入模块: import wx [as 别名]
# 或者: from wx import ListBox [as 别名]
def create_widget(self):
choices = [c[0] for c in self.choices]
self.widget = wx.ListBox(self.parent_window.widget, self.id, choices=choices)
if self.selection>=0: self.widget.SetSelection(self.selection)
self.widget.Bind(wx.EVT_LEFT_DOWN, self.on_set_focus)
示例15: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import ListBox [as 别名]
def __init__(self, *args, **kwds):
# begin wxGlade: Frame194.__init__
kwds["style"] = kwds.get("style", 0)
wx.Frame.__init__(self, *args, **kwds)
self.SetSize((800, 600))
self.SetTitle(_("frame_1"))
sizer_1 = wx.GridSizer(2, 3, 0, 0)
self.list_box_single = wx.ListBox(self, wx.ID_ANY, choices=[_("Listbox wxLB_SINGLE")])
self.list_box_single.SetSelection(0)
sizer_1.Add(self.list_box_single, 1, wx.ALL | wx.EXPAND, 5)
self.list_box_multiple = wx.ListBox(self, wx.ID_ANY, choices=[_("Listbox wxLB_MULTIPLE")], style=wx.LB_MULTIPLE)
self.list_box_multiple.SetSelection(0)
sizer_1.Add(self.list_box_multiple, 1, wx.ALL | wx.EXPAND, 5)
self.list_box_extended = wx.ListBox(self, wx.ID_ANY, choices=[_("Listbox wxLB_EXTENDED")], style=wx.LB_EXTENDED)
self.list_box_extended.SetSelection(0)
sizer_1.Add(self.list_box_extended, 1, wx.ALL | wx.EXPAND, 5)
self.check_list_box_single = wx.CheckListBox(self, wx.ID_ANY, choices=[_("CheckListBox wxLB_SINGLE")], style=wx.LB_SINGLE)
self.check_list_box_single.SetSelection(0)
sizer_1.Add(self.check_list_box_single, 1, wx.ALL | wx.EXPAND, 5)
self.check_list_box_multiple = wx.CheckListBox(self, wx.ID_ANY, choices=[_("CheckListBox wxLB_MULTIPLE")], style=wx.LB_MULTIPLE)
self.check_list_box_multiple.SetSelection(0)
sizer_1.Add(self.check_list_box_multiple, 1, wx.ALL | wx.EXPAND, 5)
self.check_list_box_extended = wx.CheckListBox(self, wx.ID_ANY, choices=[_("CheckListBox wxLB_EXTENDED")], style=wx.LB_EXTENDED)
self.check_list_box_extended.SetSelection(0)
sizer_1.Add(self.check_list_box_extended, 1, wx.ALL | wx.EXPAND, 5)
self.SetSizer(sizer_1)
self.Layout()
# end wxGlade
# end of class Frame194