Python wx.ListCtrl() Examples

The following are 30 code examples of wx.ListCtrl(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module wx , or try the search function .
Example #1
Source File: __init__.py    From EventGhost with GNU General Public License v2.0 7 votes vote down vote up
def __init__(self, parent, id, evtList, ix, plugin):
        width = 205
        wx.ListCtrl.__init__(self, parent, id, style=wx.LC_REPORT |
            wx.LC_NO_HEADER | wx.LC_SINGLE_SEL, size = (width, -1))
        self.parent = parent
        self.id = id
        self.evtList = evtList
        self.ix = ix
        self.plugin = plugin
        self.sel = -1
        self.il = wx.ImageList(16, 16)
        self.il.Add(wx.BitmapFromImage(wx.Image(join(eg.imagesDir, "event.png"), wx.BITMAP_TYPE_PNG)))
        self.SetImageList(self.il, wx.IMAGE_LIST_SMALL)
        self.InsertColumn(0, '')
        self.SetColumnWidth(0, width - 5 - SYS_VSCROLL_X)
        self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnSelect)
        self.Bind(wx.EVT_SET_FOCUS, self.OnChange)
        self.Bind(wx.EVT_LIST_INSERT_ITEM, self.OnChange)
        self.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.OnChange)
        self.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.OnRightClick)
        self.SetToolTipString(self.plugin.text.toolTip) 
Example #2
Source File: namesdlg.py    From trelby with GNU General Public License v2.0 6 votes vote down vote up
def __init__(self, parent):
        wx.ListCtrl.__init__(self, parent, -1,
            style = wx.LC_REPORT | wx.LC_VIRTUAL | wx.LC_SINGLE_SEL |
                    wx.LC_HRULES | wx.LC_VRULES)

        self.sex = ["Female", "Male"]

        self.InsertColumn(0, "Name")
        self.InsertColumn(1, "Type")
        self.InsertColumn(2, "Sex")
        self.SetColumnWidth(0, 120)
        self.SetColumnWidth(1, 120)

        # we can't use wx.LIST_AUTOSIZE since this is a virtual control,
        # so calculate the size ourselves since we know the longest string
        # possible.
        w = util.getTextExtent(self.GetFont(), "Female")[0] + 15
        self.SetColumnWidth(2, w)

        util.setWH(self, w = 120*2 + w + 25) 
Example #3
Source File: JobSpooler.py    From meerk40t with MIT License 6 votes vote down vote up
def __init__(self, *args, **kwds):
        # begin wxGlade: JobSpooler.__init__
        kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE | wx.FRAME_TOOL_WINDOW | wx.STAY_ON_TOP
        wx.Frame.__init__(self, *args, **kwds)
        Module.__init__(self)
        self.SetSize((661, 402))
        self.list_job_spool = wx.ListCtrl(self, wx.ID_ANY, style=wx.LC_HRULES | wx.LC_REPORT | wx.LC_VRULES)

        self.__set_properties()
        self.__do_layout()

        self.Bind(wx.EVT_LIST_BEGIN_DRAG, self.on_list_drag, self.list_job_spool)
        self.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.on_item_rightclick, self.list_job_spool)
        # end wxGlade
        self.dirty = False
        self.update_buffer_size = False
        self.update_spooler_state = False
        self.update_spooler = False

        self.elements_progress = 0
        self.elements_progress_total = 0
        self.command_index = 0
        self.listener_list = None
        self.list_lookup = {}
        self.Bind(wx.EVT_CLOSE, self.on_close, self) 
Example #4
Source File: mainframe.py    From youtube-dl-gui with The Unlicense 6 votes vote down vote up
def _set_columns(self):
        """Initializes ListCtrl columns.
        See MainFrame STATUSLIST_COLUMNS attribute for more info. """
        for column_item in sorted(self.columns.values()):
            self.InsertColumn(column_item[0], column_item[1], width=wx.LIST_AUTOSIZE_USEHEADER)

            # If the column width obtained from wxLIST_AUTOSIZE_USEHEADER
            # is smaller than the minimum allowed column width
            # then set the column width to the minumum allowed size
            if self.GetColumnWidth(column_item[0]) < column_item[2]:
                self.SetColumnWidth(column_item[0], column_item[2])

            # Set auto-resize if enabled
            if column_item[3]:
                self.setResizeColumn(column_item[0])

# REFACTOR Extra widgets below should move to other module with widgets 
Example #5
Source File: Keymap.py    From meerk40t with MIT License 6 votes vote down vote up
def __init__(self, *args, **kwds):
        # begin wxGlade: Keymap.__init__
        kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE | wx.FRAME_TOOL_WINDOW | wx.STAY_ON_TOP
        wx.Frame.__init__(self, *args, **kwds)
        Module.__init__(self)
        self.SetSize((500, 530))
        self.list_keymap = wx.ListCtrl(self, wx.ID_ANY, style=wx.LC_HRULES | wx.LC_REPORT | wx.LC_VRULES)
        self.button_add = wx.Button(self, wx.ID_ANY, _("Add Hotkey"))
        self.text_key_name = wx.TextCtrl(self, wx.ID_ANY, "")
        self.text_command_name = wx.TextCtrl(self, wx.ID_ANY, "")

        self.__set_properties()
        self.__do_layout()

        self.Bind(wx.EVT_BUTTON, self.on_button_add_hotkey, self.button_add)
        # end wxGlade
        self.Bind(wx.EVT_CLOSE, self.on_close, self)
        self.text_key_name.Bind(wx.EVT_KEY_DOWN, self.on_key_press)
        self.SetFocus() 
Example #6
Source File: ListCtrl.py    From BitTorrent with GNU General Public License v3.0 6 votes vote down vote up
def SortItems(self, sorter=None):

        if sorter is None:
            sorter = self.GetColumnSorter()

        # TODO:
        # this step is to see if the list needs resorted.
        # improve this by stopping the first time the order would be changed.
        d = [None,] * self.GetItemCount()
        for i in xrange(len(d)):
            # use real GetItemData, so the sorter can translate
            d[i] = wx.ListCtrl.GetItemData(self, i)
        n = list(d)
        n.sort(sorter)

        if n != d:
            wx.ListCtrl.SortItems(self, sorter)

            self._update_indexes()

        self.SelectColumn(self.enabled_columns[self._col]) 
Example #7
Source File: ListCtrl.py    From BitTorrent with GNU General Public License v3.0 6 votes vote down vote up
def selectBeforePopup(ctrl, pos):
    """Ensures the item the mouse is pointing at is selected before a popup.

    Works with both single-select and multi-select lists."""

    if not isinstance(ctrl, wx.ListCtrl):
        return

    n, flags = ctrl.HitTest(pos)
    if n < 0:
        return

    if not ctrl.GetItemState(n, wx.LIST_STATE_SELECTED):
        for i in xrange(ctrl.GetItemCount()):
            ctrl.SetItemState(i, 0, SEL_FOC)
        ctrl.SetItemState(n, SEL_FOC, SEL_FOC) 
Example #8
Source File: notebook.py    From admin4 with Apache License 2.0 6 votes vote down vote up
def DoInsertPage(self, page, pos):
    if not isinstance(page, wx.Window):
      page=page(self)
      
    ctl=page.GetControl()
    if pos == None:
      self.AddPage(ctl, page.name)
      self.pages.append(page)
    else:
      self.InsertPage(pos, ctl, page.name)
      self.pages.insert(pos, page)
    if isinstance(ctl, wx.ListCtrl):
      ctl.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemDoubleClick)
      ctl.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.OnItemRightClick)
      ctl.Bind(wx.EVT_LIST_COL_CLICK, self.OnColClick)
      if wx.Platform == "__WXMSW__":
        ctl.Bind(wx.EVT_RIGHT_UP, self.OnItemRightClick) 
Example #9
Source File: menubar.py    From wxGlade with MIT License 6 votes vote down vote up
def __init__(self, parent, owner, items=None):
        style = wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.WANTS_CHARS
        wx.Dialog.__init__(self, parent, -1, _("Menu editor"), style=style)

        self.create_gui()
        self.bind_event_handlers()
        self._set_tooltips()
        self.owner = owner

        import re
        self.handler_re = self.name_re = re.compile(r'^[a-zA-Z_]+[\w-]*(\[\w*\])*$')

        self.selected_index = -1  # index of the selected element in the wx.ListCtrl menu_items
        self._ignore_events = False

        if items:
            self.add_items(items)
            self._select_item(0)
        else:
            self._enable_fields(False) 
Example #10
Source File: toolbar.py    From wxGlade with MIT License 6 votes vote down vote up
def __init__(self, parent, owner, items=None):
        style = wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER|wx.WANTS_CHARS
        wx.Dialog.__init__(self, parent, -1, _("Toolbar editor"), style=style)

        self.create_gui()
        self.bind_event_handlers()
        self._set_tooltips()
        self.owner = owner

        self.handler_re = self.name_re = re.compile(r'^[a-zA-Z_]+[\w-]*(\[\w*\])*$')

        self.selected_index = -1  # index of the selected element in the wx.ListCtrl menu_items
        self._ignore_events = False

        if items:
            self.add_items(items)
            self._select_item(0)
        else:
            self._enable_fields(False) 
Example #11
Source File: listviews.py    From pyFileFixity with MIT License 6 votes vote down vote up
def __init__(
        self, parent,
        id=-1,
        pos=wx.DefaultPosition, size=wx.DefaultSize,
        style=wx.LC_REPORT|wx.LC_VIRTUAL|wx.LC_VRULES|wx.LC_SINGLE_SEL,
        validator=wx.DefaultValidator,
        columns=None,
        sortOrder=None,
        name=_("ProfileView"),
    ):
        wx.ListCtrl.__init__(self, parent, id, pos, size, style, validator,
                             name)

        if columns is not None:
            self.columns = columns

        if not sortOrder:
            sortOrder = [(x.defaultOrder,x) for x in self.columns if x.sortDefault]
        self.sortOrder = sortOrder or []
        self.sorted = []
        self.CreateControls() 
Example #12
Source File: ListCtrl_Report_Phoenix.py    From wxGlade with MIT License 6 votes vote down vote up
def __init__(self, *args, **kwds):
        # begin wxGlade: MyFrame.__init__
        kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        self.SetTitle("frame")

        sizer_1 = wx.BoxSizer(wx.VERTICAL)

        self.list_ctrl_1 = wx.ListCtrl(self, wx.ID_ANY, style=wx.LC_HRULES | wx.LC_REPORT | wx.LC_VRULES)
        self.list_ctrl_1.AppendColumn("A", format=wx.LIST_FORMAT_LEFT, width=-1)
        self.list_ctrl_1.AppendColumn("B", format=wx.LIST_FORMAT_LEFT, width=-1)
        self.list_ctrl_1.AppendColumn("C", format=wx.LIST_FORMAT_LEFT, width=-1)
        self.list_ctrl_1.AppendColumn("D", format=wx.LIST_FORMAT_LEFT, width=-1)
        sizer_1.Add(self.list_ctrl_1, 1, wx.EXPAND, 0)

        self.SetSizer(sizer_1)
        sizer_1.Fit(self)

        self.Layout()
        # end wxGlade

# end of class MyFrame 
Example #13
Source File: gui.py    From superpaper with MIT License 6 votes vote down vote up
def onCheckboxDiaginch(self, event):
        cb_state = self.cb_diaginch.GetValue()
        sizer = self.sizer_setting_diaginch
        self.sizer_toggle_children(sizer, cb_state)
        if cb_state == False:
            # revert to automatic detection and save
            self.display_sys.update_display_diags("auto")
            self.display_sys.save_system()
            diags = [str(dsp.diagonal_size()[1]) for dsp in self.display_sys.disp_list]
            for tc, diag in zip(self.tc_list_diaginch, diags):
                tc.ChangeValue(diag)
            display_data = self.display_sys.get_disp_list(self.show_advanced_settings)
            self.wpprev_pnl.update_display_data(
                display_data,
                self.show_advanced_settings,
                self.use_multi_image
            )

    #
    # ListCtrl methods
    # 
Example #14
Source File: ObjectListView.py    From bookhub with MIT License 6 votes vote down vote up
def SetColumns(self, columns, repopulate=True):
        """
        Set the list of columns that will be displayed.

        The elements of the list can be either ColumnDefn objects or a tuple holding the values
        to be given to the ColumnDefn constructor.

        The first column is the primary column -- this will be shown in the the non-report views.

        This clears any preexisting CheckStateColumn. The first column that is a check state
        column will be installed as the CheckStateColumn for this listview.
        """
        sortCol = self.GetSortColumn()
        wx.ListCtrl.ClearAll(self)
        self.checkStateColumn = None
        self.columns = []
        for x in columns:
            if isinstance(x, ColumnDefn):
                self.AddColumnDefn(x)
            else:
                self.AddColumnDefn(ColumnDefn(*x))
        # Try to preserve the column column
        self.SetSortColumn(sortCol)
        if repopulate:
            self.RepopulateList() 
Example #15
Source File: MonitorsCtrl.py    From EventGhost with GNU General Public License v2.0 6 votes vote down vote up
def __init__(self, parent, pos, size = wx.DefaultSize):
        ID = wx.NewId()
        style = wx.LC_REPORT | wx.LC_VRULES | wx.LC_HRULES | wx.LC_SINGLE_SEL
        wx.ListCtrl.__init__(self, parent, ID, pos, size, style)
        mons = [(i[0], i[1], i[2] - i[0], i[3] - i[1]) for i in [j[2] for j in Edm()]]
        for j, header in enumerate(eg.text.General.monitorsHeader):
            self.InsertColumn(j, header, wx.LIST_FORMAT_RIGHT)
            self.SetColumnWidth(j, wx.LIST_AUTOSIZE_USEHEADER)
        for i, mon in enumerate(mons):
            self.InsertStringItem(i, str(i + 1))
            self.SetStringItem(i, 1, str(mon[0]))
            self.SetStringItem(i, 2, str(mon[1]))
            self.SetStringItem(i, 3, str(mon[2]))
            self.SetStringItem(i, 4, str(mon[3]))
        rect = self.GetItemRect(0, wx.LIST_RECT_BOUNDS)
        self.hh = rect[1]  #header height
        self.ih = rect[3]  #item height
        size = self.GetRealSize()
        self.SetMinSize(size)
        self.SetSize(size) 
Example #16
Source File: pyResManDialog.py    From pyResMan with GNU General Public License v2.0 6 votes vote down vote up
def _listCtrlOnContextMenuClick(self, event):
        menuItemIndex = event.Id
        theListCtrl = event.GetEventObject().GetInvokingWindow()
        if not isinstance(theListCtrl, wx.ListCtrl):
            theListCtrl = theListCtrl.GetParent()
        if menuItemIndex == 0:
            theListCtrl.DeleteAllItems()
            # Load script again;
            if theListCtrl == self._listctrlScriptList:
                self._loadScript()
        elif menuItemIndex == 1:
            self._listCtrlRunSelectedItems(theListCtrl)
# 
#     def _onLogTextCtrl_MenuClick(self, event):
#         menuItemIndex = event.Id
#         if menuItemIndex == 0:
#             self._logTextCtrl.Clear() 
Example #17
Source File: ObjectListView.py    From bookhub with MIT License 6 votes vote down vote up
def OnGetItemAttr(self, itemIdx):
        """
        Return the display attributes that should be used for the given row
        """
        if not self.useAlternateBackColors and self.rowFormatter is None:
            return None

        # We have to keep a reference to the ListItemAttr or the garbage collector
        # will clear it up immeditately, before the ListCtrl has time to process it.
        self.listItemAttr = wx.ListItemAttr()
        self._FormatOneItem(self.listItemAttr, itemIdx, self.GetObjectAt(itemIdx))

        return self.listItemAttr


    #----------------------------------------------------------------------------
    # Accessing 
Example #18
Source File: ObjectListView.py    From bookhub with MIT License 6 votes vote down vote up
def RepopulateList(self):
        """
        Completely rebuild the contents of the list control
        """
        self.lastGetObjectIndex = -1
        self.Freeze()
        try:
            self._SortObjects()
            self._BuildInnerList()
            wx.ListCtrl.DeleteAllItems(self)
            self.SetItemCount(len(self.innerList))
            self.RefreshObjects()

            # Auto-resize once all the data has been added
            self.AutoSizeColumns()
        finally:
            self.Thaw() 
Example #19
Source File: ListCtrlPrinter.py    From bookhub with MIT License 5 votes vote down vote up
def IsUseSubstitution(self):
        """
        Should the text values printed by this block have substitutions performed before being printed?

        Normally, we don't want to substitute within values that comes from the ListCtrl.
        """
        return False

    #----------------------------------------------------------------------------
    # Overrides for CellBlock 
Example #20
Source File: ObjectListView.py    From bookhub with MIT License 5 votes vote down vote up
def RepopulateList(self):
        """
        Completely rebuild the contents of the list control
        """
        self._SortObjects()
        self._BuildInnerList()
        self.Freeze()
        try:
            wx.ListCtrl.DeleteAllItems(self)
            if len(self.innerList) == 0 or len(self.columns) == 0:
                self.Refresh()
                self.stEmptyListMsg.Show()
                return

            self.stEmptyListMsg.Hide()

            # Insert all the rows
            item = wx.ListItem()
            item.SetColumn(0)
            for (i, x) in enumerate(self.innerList):
                item.Clear()
                self._InsertUpdateItem(item, i, x, True)

            # Auto-resize once all the data has been added
            self.AutoSizeColumns()
        finally:
            self.Thaw() 
Example #21
Source File: ListCtrlPrinter.py    From bookhub with MIT License 5 votes vote down vote up
def run(self):
            printer = ListCtrlPrinter(self.lv, "Playing with ListCtrl Printing")
            printer.ReportFormat = ReportFormat.Normal()
            printer.ReportFormat.WatermarkFormat(over=True)
            printer.ReportFormat.IsColumnHeadingsOnEachPage = True

            #printer.ReportFormat.Page.Add(ImageDecoration(ExampleImages.getGroup32Bitmap(), wx.RIGHT, wx.BOTTOM))

            #printer.PageHeader("%(listTitle)s") # nice idea but not possible at the moment
            printer.PageHeader = "Playing with ListCtrl Printing"
            printer.PageFooter = ("Bright Ideas Software", "%(date)s", "%(currentPage)d of %(totalPages)d")
            printer.Watermark = "Sloth!"

            #printer.PageSetup()
            printer.PrintPreview(self) 
Example #22
Source File: ObjectListView.py    From bookhub with MIT License 5 votes vote down vote up
def ClearAll(self):
        """
        Remove all items and columns
        """
        wx.ListCtrl.ClearAll(self)
        self.SetObjects(list()) 
Example #23
Source File: listctrl.py    From iqiyi-parser with MIT License 5 votes vote down vote up
def __init__(self, *args):
        wx.ListCtrl.__init__(self, *args)
        self.initColumn()

        # self.menu = Menu_CopyLink()
        # self.Bind(wx.EVT_RIGHT_DOWN, self.OnContextMenu) 
Example #24
Source File: ListCtrlPrinter.py    From bookhub with MIT License 5 votes vote down vote up
def IsUseSubstitution(self):
        """
        Should the text values printed by this block have substitutions performed before being printed?

        Normally, we don't want to substitute within values that comes from the ListCtrl.
        """
        return False


#---------------------------------------------------------------------------- 
Example #25
Source File: __init__.py    From EventGhost with GNU General Public License v2.0 5 votes vote down vote up
def Configure(self, *args):
        result = [None]
        panel = eg.ConfigPanel()
        panel.dialog.buttonRow.okButton.Enable(False)
        panel.dialog.buttonRow.applyButton.Enable(False)

        def OnButton(event):
            FillList(eg.WinApi.Display.GetDisplayModes())
            panel.dialog.buttonRow.okButton.Enable(True)
            panel.dialog.buttonRow.applyButton.Enable(True)

        button = wx.Button(panel, -1, self.text.query)
        button.Bind(wx.EVT_BUTTON, OnButton)
        panel.sizer.Add(button)
        panel.sizer.Add((5, 5))
        listCtrl = wx.ListCtrl(panel, style=wx.LC_REPORT)
        fields = self.text.fields
        for col, name in enumerate(fields):
            listCtrl.InsertColumn(col, name)

        def FillList(args):
            result[0] = args
            listCtrl.DeleteAllItems()
            for i, argLine in enumerate(args):
                listCtrl.InsertStringItem(i, "")
                for col, arg in enumerate(argLine):
                    listCtrl.SetStringItem(i, col, str(arg))
        FillList(args)

        for i in range(1, len(fields)):
            listCtrl.SetColumnWidth(i, -2)
        x = 0
        for i in range(len(fields)):
            x += listCtrl.GetColumnWidth(i)
        listCtrl.SetMinSize((x + 4, -1))
        panel.sizer.Add(listCtrl, 1, wx.EXPAND)

        while panel.Affirmed():
            panel.SetResult(*result[0]) 
Example #26
Source File: EventRemapDialog.py    From EventGhost with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, parent, mapping=None):
        eg.Dialog.__init__(
            self, parent, style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER
        )
        listCtrl = wx.ListCtrl(self, -1, style=wx.LC_REPORT)
        listCtrl.InsertColumn(0, "New event name")
        listCtrl.InsertColumn(1, "Events")
        listCtrl.InsertColumn(2, "Repeat events")
        listCtrl.InsertColumn(3, "Timeout")

        newEventCtrl = self.TextCtrl()
        eventsCtrl = self.TextCtrl()
        repeatEventsCtrl = self.TextCtrl()

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(listCtrl, 1, wx.EXPAND)

        editSizer = wx.GridSizer(1, 2)
        editSizer.Add(
            self.StaticText("New event name:"),
            wx.ALIGN_CENTER_VERTICAL
        )
        editSizer.Add(newEventCtrl, 0)
        editSizer.Add(
            self.StaticText("Events:"),
            wx.ALIGN_CENTER_VERTICAL
        )
        editSizer.Add(eventsCtrl, 0)
        editSizer.Add(
            self.StaticText("Repeat events:"),
            wx.ALIGN_CENTER_VERTICAL
        )
        editSizer.Add(repeatEventsCtrl, 0)

        sizer.Add(editSizer)
        self.SetSizerAndFit(sizer) 
Example #27
Source File: WindowList.py    From EventGhost with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, parent, hwnds):
        wx.ListCtrl.__init__(self, parent, style=wx.LC_REPORT | wx.LC_SINGLE_SEL)
        listmix.ListCtrlAutoWidthMixin.__init__(self)
        imageList = wx.ImageList(16, 16)
        imageList.Add(GetInternalBitmap("cwindow"))
        self.AssignImageList(imageList, wx.IMAGE_LIST_SMALL)
        self.InsertColumn(0, "Program")
        self.InsertColumn(1, "Name")
        self.InsertColumn(2, "Class")
        self.InsertColumn(3, "Handle", wx.LIST_FORMAT_RIGHT)
        for hwnd in hwnds:
            imageIdx = 0
            icon = GetHwndIcon(hwnd)
            if icon:
                imageIdx = imageList.AddIcon(icon)
            idx = self.InsertImageStringItem(
                sys.maxint,
                GetWindowProcessName(hwnd),
                imageIdx
            )
            self.SetStringItem(idx, 1, GetWindowText(hwnd))
            self.SetStringItem(idx, 2, GetClassName(hwnd))
            self.SetStringItem(idx, 3, str(hwnd))
        for i in range(4):
            self.SetColumnWidth(i, -2)
            headerSize = self.GetColumnWidth(i)
            self.SetColumnWidth(i, -1)
            labelSize = self.GetColumnWidth(i)
            if headerSize > labelSize:
                self.SetColumnWidth(i, headerSize) 
Example #28
Source File: listctrl.py    From iqiyi-parser with MIT License 5 votes vote down vote up
def DeleteItem(self, item):
        wx.ListCtrl.DeleteItem(self, item)
        item_count = self.GetItemCount()
        odd = True if item % 2 else False

        for i in range(item_count - item):

            self.SetItemBackgroundColour(i + item, ODD_BGCOLOR if odd else EVEN_BGCOLOR)

            odd = not odd 
Example #29
Source File: listctrl.py    From iqiyi-parser with MIT License 5 votes vote down vote up
def Append(self, entry, fgcolor=None):
        wx.ListCtrl.Append(self, entry)
        item_count = self.GetItemCount()
        if not item_count % 2:
            self.SetItemBackgroundColour(item_count - 1, ODD_BGCOLOR)

        if fgcolor:
            self.SetItemTextColour(item_count-1, wx.Colour(fgcolor))
        self.ScrollLines(1) 
Example #30
Source File: ObjectListView.py    From bookhub with MIT License 5 votes vote down vote up
def OnGetItemAttr(self, itemIdx):
        """
        Return the display attributes that should be used for the given row
        """
        self.listItemAttr = wx.ListItemAttr()

        modelObject = self.innerList[itemIdx]

        if modelObject is None:
            return self.listItemAttr

        if isinstance(modelObject, ListGroup):
            # We have to keep a reference to the ListItemAttr or the garbage collector
            # will clear it up immeditately, before the ListCtrl has time to process it.
            if self.groupFont is not None:
                self.listItemAttr.SetFont(self.groupFont)
            if self.groupTextColour is not None:
                self.listItemAttr.SetTextColour(self.groupTextColour)
            if self.groupBackgroundColour is not None:
                self.listItemAttr.SetBackgroundColour(self.groupBackgroundColour)
            return self.listItemAttr

        return FastObjectListView.OnGetItemAttr(self, itemIdx)

    #----------------------------------------------------------------------------
    # Commands