def OnDrawItem(self, dc, rect, item, flags):
if item == wx.NOT_FOUND:
# painting the control, but there is no valid item selected yet
return
font = wx.Font(8, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, False, 'Segoe UI')
dc.SetFont(font)
if flags == 3:
margin = 3
else:
margin = 1
r = wx.Rect(*rect) # make a copy
r.Deflate(margin, margin)
tam = self.OnMeasureItem(item)-2
dc.SetPen(wx.Pen("grey", style=wx.TRANSPARENT))
color_name = self.GetString(item)
color = self.colors.get(color_name)
if not color:
color = wx.NamedColour(color_name)
dc.SetBrush(wx.Brush(color))
dc.DrawRectangle(r.x, r.y, tam, tam)
dc.DrawText(self.GetString(item), r.x + tam + 2, r.y)
评论列表
文章目录