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)
评论列表
文章目录