def PopulateList(self): self.list.Freeze() info = ULC.UltimateListItem() info.Mask = wx.LIST_MASK_TEXT | wx.LIST_MASK_FORMAT info.Align = 0 info.Text = "" self.list.InsertColumnInfo(0, info) info = ULC.UltimateListItem() info.Align = wx.LIST_FORMAT_LEFT info.Mask = wx.LIST_MASK_TEXT | wx.LIST_MASK_FORMAT info.Image = [] info.Text = "Some useful info here" self.list.InsertColumnInfo(1, info) for i in range(2): index = self.list.InsertImageStringItem(sys.maxsize, "", [i]) self.list.SetStringItem(index, 1, "") klass = MacRenderer(self) self.list.SetItemCustomRenderer(index, 1, klass) self.list.SetColumnWidth(0, 34) self.list.SetColumnWidth(1, 300) self.list.Thaw() self.list.Update()
def __init__(self, parent, *args, **kwargs): self.parent = parent display_width = wx.DisplaySize()[0] width, height = diwavars.FRAME_SIZE pos_x = ((display_width - width) / 2) + width pos_y = height / 2 wx.Frame.__init__(self, parent, -1, pos=(pos_x, pos_y), style=wx.FRAME_FLOAT_ON_PARENT | wx.FRAME_NO_TASKBAR, *args, **kwargs) self.SetBackgroundColour(wx.Colour(255, 255, 255)) self.event_menu_titles = ['Important', 'Decision', 'Action Point', 'Discussion', 'Future Agenda'] image_list = wx.ImageList(32, 32, True) for event_title in self.event_menu_titles: event_title = event_title.lower().replace(" ", "_") image_list.Add(self.GetProgramIcon(event_title)) msize = len(self.event_menu_titles) * 38 self.evtlist = ULC.UltimateListCtrl(self, -1, agwStyle=wx.LC_REPORT | wx.LC_NO_HEADER | ULC.ULC_NO_HIGHLIGHT, size=(210, msize)) info = ULC.UltimateListItem() info.SetMask(wx.LIST_MASK_TEXT | wx.LIST_MASK_IMAGE | wx.LIST_MASK_FORMAT | ULC.ULC_MASK_CHECK) info.SetImage([]) info.SetFooterFormat(0) info.SetFooterKind(0) info.SetText('Icon') self.evtlist.InsertColumnInfo(0, info) self.evtlist.AssignImageList(image_list, wx.IMAGE_LIST_SMALL) for idx, item in enumerate(self.event_menu_titles): self.evtlist.InsertImageStringItem(idx, item, idx, it_kind=0) self.custom1_id = -1 self.evtlist.SetColumnWidth(0, 200) self.custom_icon = wx.StaticBitmap(self, -1, self.GetProgramIcon('custom3')) self.custom_event = wx.TextCtrl(self, -1, size=(177, -1)) self.on_text = False self.custom_sizer = wx.BoxSizer(wx.HORIZONTAL) self.custom_sizer.Add(self.custom_icon, 0) self.custom_sizer.Add(self.custom_event, 0, wx.EXPAND) self.sizer = wx.BoxSizer(wx.VERTICAL) self.sizer.Add(self.evtlist, 0) self.sizer.Add(self.custom_sizer, 0) self.SetSizer(self.sizer) self.selection_made = 0 self.sizer.Fit(self)
def PopulateList(self): self.list.Freeze() font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT) boldfont = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT) boldfont.SetWeight(wx.FONTWEIGHT_BOLD) boldfont.SetPointSize(12) boldfont.SetUnderlined(True) info = ULC.UltimateListItem() info._mask = wx.LIST_MASK_TEXT | wx.LIST_MASK_IMAGE | wx.LIST_MASK_FORMAT | ULC.ULC_MASK_CHECK info._image = [1, 2] info._format = 0 info._kind = 1 info._text = "Artist\nName" self.list.InsertColumnInfo(0, info) info = ULC.UltimateListItem() info._format = wx.LIST_FORMAT_RIGHT info._mask = wx.LIST_MASK_TEXT | wx.LIST_MASK_IMAGE | wx.LIST_MASK_FORMAT | ULC.ULC_MASK_FONT info._image = [] info._text = "Title" info._font = boldfont self.list.InsertColumnInfo(1, info) info = ULC.UltimateListItem() info._mask = wx.LIST_MASK_TEXT | wx.LIST_MASK_IMAGE | wx.LIST_MASK_FORMAT info._format = 0 info._text = "Genre" info._font = font info._image = [3] self.list.InsertColumnInfo(2, info) info = ULC.UltimateListItem() info._mask = wx.LIST_MASK_TEXT | wx.LIST_MASK_FORMAT | ULC.ULC_MASK_FONTCOLOUR info._format = 0 info._text = "Custom Renderer" info._colour = wx.RED # Add our custom renderer for the header of column 3, we can also use # SetHeaderCustomRenderer to set the renderer for all the columns. klass = UltimateHeaderRenderer(self) info.SetCustomRenderer(klass) self.list.InsertColumnInfo(3, info) # The custom renderer can also be set for all columns on the header and/or footer # self.list.SetHeaderCustomRenderer(klass) # We must first have a footer in order to set its custom renderer: # style = self.list.GetAGWWindowStyleFlag() | ULC.ULC_FOOTER # if self.list.GetAGWWindowStyleFlag() != style: # self.list.SetAGWWindowStyleFlag(style) # self.list.SetFooterCustomRenderer(klass) items = musicdata.items() renderers = {} for key, data in items: if key == 3: index = self.list.InsertImageStringItem(sys.maxsize, data[0], [3, 4, 7], it_kind=1) elif key == 4: dt = "\n".join(data[0].split()) index = self.list.InsertImageStringItem(sys.maxsize, dt, [self.idx1, 8, 7]) else: index = self.list.InsertImageStringItem(sys.maxsize, data[0], self.idx1) if key == 6: self.list.SetStringItem(index, 1, data[1], it_kind=1) elif key == 7: self.list.SetStringItem(index, 1, data[1], [6, 5, 4]) elif key == 8: dt = "\n".join(data[1].split()) self.list.SetStringItem(index, 1, dt) else: self.list.SetStringItem(index, 1, data[1]) it_kind = 0 if random.randint(0, 2) == 2: # set some radiobutton-like item on the 3rd column it_kind = 2 self.list.SetStringItem(index, 2, data[2], it_kind=it_kind) self.list.SetStringItem(index, 3, data[3]) randomRenderer = random.randint(0, 2) if randomRenderer == 2: # set some custom renderers... klass = UltimateRenderer_1(self) renderers[index] = klass self.list.SetItemCustomRenderer(index, 3, klass) elif randomRenderer == 1: klass = UltimateRenderer_2(self) self.list.SetItemCustomRenderer(index, 3, klass) else: klass = UltimateRenderer_3() self.list.SetItemCustomRenderer(index, 3, klass) self.list.SetItemData(index, key) self.renderers = renderers # show how to select an item self.list.Select(5, True) # show how to change the colour of a couple items item = self.list.GetItem(1) item.SetTextColour(wx.BLUE) pyData = datetime.date(2009, 1, 1) item.SetPyData(pyData) self.list.SetItem(item) item = self.list.GetItem(4) item.SetTextColour(wx.RED) pyData = datetime.date(2011, 3, 2) item.SetPyData(pyData) self.list.SetItem(item) # Disable one item item = self.list.GetItem(9) item.Enable(False) self.list.SetItem(item) # Set 2 hypertext items for ids in [2, 5]: item = self.list.GetItem(ids, 2) item.SetHyperText(True) self.list.SetItem(item) # Set 2 items with widgets item = self.list.GetItem(8, 1) self.gauge = wx.Gauge(self.list, -1, 50, style=wx.GA_HORIZONTAL|wx.GA_SMOOTH) self.gauge.SetValue(20) item.SetWindow(self.gauge) self.list.SetItem(item) item = self.list.GetItem(11, 0) textctrl = wx.TextCtrl(self.list, -1, "I Am A Simple\nMultiline wx.TexCtrl", style=wx.TE_MULTILINE) item.SetWindow(textctrl) self.list.SetItem(item) # Put an item with overflow self.list.SetItemOverFlow(10, 0, True) self.currentItem = 0 fontMask = ULC.ULC_MASK_FONTCOLOUR|ULC.ULC_MASK_FONT fullMask = fontMask|ULC.ULC_MASK_BACKCOLOUR customRow, customCol, colours = [0, 3], [2, 1], [wx.RED, wx.Colour("Yellow")] for row, col, colour in zip(customRow, customCol, colours): item = self.list.GetItem(row, col) item.SetMask(fullMask) item.SetTextColour(wx.GREEN) font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT) font.SetWeight(wx.FONTWEIGHT_BOLD) item.SetFont(font) item.SetBackgroundColour(colour) self.list.SetItem(item) standardFont = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT) italicFont = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT) italicFont.SetStyle(wx.FONTSTYLE_ITALIC) boldFont = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT) boldFont.SetWeight(wx.FONTWEIGHT_BOLD) lenCDB = len(self.colourList) for indx in range(11, 20): for col in range(self.list.GetColumnCount()): result = random.randint(0, 2) colourIndex = random.randint(0, lenCDB-1) if result == 0: fnt = standardFont elif result == 1: fnt = boldFont else: fnt = italicFont item = self.list.GetItem(indx, col) item.SetMask(fontMask) item.SetFont(fnt) item.SetTextColour(wx.TheColourDatabase.FindColour(self.colourList[colourIndex])) self.list.SetItem(item) self.list.SetColumnWidth(0, wx.LIST_AUTOSIZE) self.list.SetColumnWidth(1, wx.LIST_AUTOSIZE) self.list.SetColumnWidth(2, 100) self.list.SetColumnWidth(3, 130) ## self.list.SetColumnShown(1, False) self.list.Thaw() self.list.Update() self.timer.Start(300)