Quantcast

column header doesn't change

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

column header doesn't change

Anstoss
 Hi,

I have following code to change column header of a wxlistctrl object on the fly.

def OnEditLabel(event, self=self, para="test"):
            mycol = self.GetColumn(self.currentItem)
            mycol_old = self.event.GetColumn()
            mycol.SetColumn(mycol_old)
            dlg = wx.TextEntryDialog(self, MSG_ENTER_NODE_NAME, INSERT_NODE_DIALOG, mycol.GetText(), wx.OK | wx.CANCEL)
            if dlg.ShowModal() == wx.ID_OK:
                res = dlg.GetValue()
                mycol.SetText(res)
                self.SetColumn(self.currentItem, mycol)

The method is invoked when user right clicks on a column header, a small message window will pop up with current header value. after user changes the value in the window and click ok button, I am expecting the column is showing the changed header. however, it shows blank. if I click on the header and show the message window again, it shows the changed the value. seems the header is not refreshed correctly. is this a bug?

thanks,
Anstoss

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: column header doesn't change

Robin Dunn
Anstoss wrote:

>  Hi,
>
> I have following code to change column header of a wxlistctrl object on
> the fly.
>
> def OnEditLabel(event, self=self, para="test"):
>             mycol = self.GetColumn(self.currentItem)
>             mycol_old = self.event.GetColumn()
>             mycol.SetColumn(mycol_old)
>             dlg = wx.TextEntryDialog(self, MSG_ENTER_NODE_NAME,
> INSERT_NODE_DIALOG, mycol.GetText(), wx.OK | wx.CANCEL)
>             if dlg.ShowModal() == wx.ID_OK:
>                 res = dlg.GetValue()
>                 mycol.SetText(res)
>                 self.SetColumn(self.currentItem, mycol)
>
> The method is invoked when user right clicks on a column header, a small
> message window will pop up with current header value. after user changes
> the value in the window and click ok button, I am expecting the column
> is showing the changed header. however, it shows blank. if I click on
> the header and show the message window again, it shows the changed the
> value. seems the header is not refreshed correctly. is this a bug?

Platform and version?  The following works for me in the ListCtrl sample
in the demo, (run it and then press F5 to open a PyShell window):

  >>> col = frame.demoPage.list.GetColumn(1)
  >>> print col.GetText()
  Title
  >>> col.SetText("NEW TITLE")
  >>> frame.demoPage.list.SetColumn(1, col)
  True
  >>>

--
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: column header doesn't change

Anstoss
In reply to this post by Anstoss
Robin,

I ran it on windows 2000. I tried the same as you did and it works for me. but if I use the demo listctrl_edit.py, it doesn't work. I tried it in py shell and the problem happened. after I set the new column title, the header became blank.

thanks,
Antoss


Yahoo! DSL Something to write home about. Just $16.99/mo. or less
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: column header doesn't change

Anstoss
In reply to this post by Anstoss
Robin,

I thought I found the cause of the problem. if I commented line:

self.list.SetImageList(self.il, wx.IMAGE_LIST_SMALL)

in the demo file, the setcolumn can make the header blank. I can reproduce this issue repeatedly on windows 2000. is this a bug? why setcolumn has anything to do with setimagelist?

thanks,
Anstoss


Yahoo! for Good - Make a difference this year.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: column header doesn't change

Robin Dunn
Anstoss wrote:
> Robin,
>
> I thought I found the cause of the problem. if I commented line:
>
> self.list.SetImageList(self.il, wx.IMAGE_LIST_SMALL)
>
> in the demo file, the setcolumn can make the header blank. I can
> reproduce this issue repeatedly on windows 2000. is this a bug? why
> setcolumn has anything to do with setimagelist?

The item's mask is probably set to specify that the image is valid, and
so the listctrl is trying to set the image to an invalid index.  Try
this instead:

  >>> lc = frame.demoPage.list
  >>> col = lc.GetColumn(1)
  >>> col.GetText()
  'Column 2'
  >>> col.SetMask(wx.LIST_MASK_TEXT)
  >>> col.SetText("New Text")
  >>> lc.SetColumn(1, col)
  True
  >>>


--
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!



Loading...