Robin Dunn wrote:
Steven F. Bell wrote:
Hello,
Simple enough question, that I can't seem to find the answer for.
I have a list control, and I would like to set the font size for the header, and for each list row I would like the list to expand to meet the size of the text on it. I changed the font of each list item, and it outgrew the row's height.
The header should use whatever font is set for the whole wxListCtrl. I'm not sure I follow what you are describing for the rows, please provide a sample that shows the problem.
If I set the font for the text in a row to say, 10pt. The font is larger than the row, and only a portion of the text is displayed. I am probably just not setting up the rows themselves correctly.
Here's the code that builds the list:
self.entries = wxListCtrl(self,tID,style=wxLC_REPORT|wxSUNKEN_BORDER|wxLC_EDIT_LABELS)
self.entries.SetBackgroundColour(wxColour(207,211,211))
self.entries.InsertColumn(0,"Subject")
self.entries.InsertColumn(1,"Date")
self.entries.InsertColumn(2,"Priority")
EVT_LIST_ITEM_ACTIVATED(self, tID, self.OnSingleClick)
self.Show(true)
And here is the function that populates it:
def Build_List(self):
myTest = pydb.Get_List_Entries(db,dbtable)
items = myTest.items()
kia = 5
for x in range(len(items)):
key,data = items
self.entries.InsertStringItem(x,data[0])
self.entries.SetStringItem(x,1,data[1])
val = "%d" % data[2]
self.entries.SetStringItem(x,2,val)
item = self.entries.GetItem(x)
if (data[2] > 3):
item.SetTextColour(wxRED)
elif (data[2] < 3):
item.SetTextColour(wxBLUE)
elif (data[2] == 3):
item.SetTextColour(wxColour(30,104,35))
if (kia == 5):
item.SetFont(wxFont(8, wxSWISS, wxNORMAL, wxNORMAL, False, 'Comic Sans MS'))
item.SetBackgroundColour(wxColour(242,244,244))
kia = 6
else:
item.SetFont(wxFont(8, wxSWISS, wxNORMAL, wxNORMAL, False, 'Comic Sans MS'))
item.SetBackgroundColour(wxColour(219,252,248))
kia = 5
self.entries.SetItem(item)
self.entries.SetColumnWidth(0,wxLIST_AUTOSIZE)
self.entries.SetColumnWidth(1,wxLIST_AUTOSIZE)
self.entries.SetColumnWidth(2,65)
Thank you,
Steve.
···
--
"When you do become Satan's Mistress, as you've always dreamed, don't forget us, the little people"