Is it possible to change the title of a wxListCtrl title after the wxListCtrl has been created and fully populated? I want to dynamically change the column title when the presentation language is changed.
Thanks in advance!
Pierre
Is it possible to change the title of a wxListCtrl title after the wxListCtrl has been created and fully populated? I want to dynamically change the column title when the presentation language is changed.
Thanks in advance!
Pierre
Pierre Rouleau wrote:
Is it possible to change the title of a wxListCtrl title after the wxListCtrl has been created and fully populated? I want to dynamically change the column title when the presentation language is changed.
I think you can do it something like this:
item = list.GetColumn(col)
item.SetText(newtext)
list.SetColumn(col, item)
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
Robin Dunn wrote:
Pierre Rouleau wrote:
Is it possible to change the title of a wxListCtrl title after the wxListCtrl has been created and fully populated? I want to dynamically change the column title when the presentation language is changed.
I think you can do it something like this:
item = list.GetColumn(col)
item.SetText(newtext)
list.SetColumn(col, item)
Thanks Robin, it works.
In my code, the number of columns is also changed dynamically, depending on the program's context. I'v found that i have to do this:
def setColumnTitle(self, colIdx, newText) :
"""Set the text of the column title.
colIdx : column index : [0..nColumn[
newText: string containing the new text
"""
item = self.list.GetColumn(colIdx)
if item is not None:
item.SetText(newText)
self.list.SetColumn(colIdx, item)
Pierre Rouleau wrote:
Robin Dunn wrote:
Pierre Rouleau wrote:
Is it possible to change the title of a wxListCtrl title after the wxListCtrl has been created and fully populated? I want to dynamically change the column title when the presentation language is changed.
I think you can do it something like this:
item = list.GetColumn(col)
item.SetText(newtext)
list.SetColumn(col, item)Thanks Robin, it works.
In my code, the number of columns is also changed dynamically, depending on the program's context. I'v found that i have to do this:
def setColumnTitle(self, colIdx, newText) :
"""Set the text of the column title.colIdx : column index : [0..nColumn[
newText: string containing the new text
"""item = self.list.GetColumn(colIdx)
if item is not None:
item.SetText(newText)
self.list.SetColumn(colIdx, item)
To anyone interested, I have noticed that you have to set the image list of the wx.ListCtrl if you want to be able to change the column title. You have to set the image list even when you do not want to see any (none in the label column and none to show the sorting order for non-sortable lists). You have to create an empty iamge list and apply it with:
# create the image list (all icons are 16x16 pixels)
self.imageList = wx.ImageList(16, 16)
# set the image list (even if no images were added to the image list)
self.list.SetImageList(self.imageList, wx.IMAGE_LIST_SMALL)
In one of my classes I was not doing it. The initialisation worked fine and the column title was showing up ok. But as soon as the code was calling setColumnTitle(), all titles were erased from the window.
I don't really know why, but if you set the image list as above, the problem dissapears.
Is this expected behavior?
Thanks
Pierre
Pierre Rouleau wrote:
Is this expected behavior?
It's a Microsoft thing. The native tree control also has certain "issues" if there is no image list.
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
Robin Dunn wrote:
Pierre Rouleau wrote:
Is this expected behavior?
It's a Microsoft thing. The native tree control also has certain "issues" if there is no image list.
1) Is this the same for other platforms?
2) Where would be the best place to find a list of such "issues" or "assumptions"?