Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
Message from discussion `ForceRefresh` after `AppendRows` does not display new items .
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Frank Millman  
View profile  
 More options Nov 18 2009, 12:58 am
From: "Frank Millman" <fr...@chagford.com>
Date: Wed, 18 Nov 2009 07:58:39 +0200
Local: Wed, Nov 18 2009 12:58 am
Subject: RE: [wxPython-users] `ForceRefresh` after `AppendRows` does not display new items .

Olemis Lang wrote:

> I am appending a row in a grid this way :

> {{{
> #!python

>     dialog = wx.TextEntryDialog(self, *args)
>     try :
>       if dialog.ShowModal() == wx.ID_OK:
>         value = dialog.GetValue()
>         if value :
>           try :
>             self.grid.GetTable().add_value(value)
>             self.notify()                                       <=====
>  ********** ForceRefresh called in here **********
>           except ValueError, exc :
>             wx.MessageBox(exc.message, caption="Invalid
> value", style=wx.OK)
>         else :
>           wx.MessageBox("Cannot be empty", caption="Invalid
> value", style=wx.OK)
>     finally :
>       dialog.Destroy()

> }}}

> and the Grid doesn't display the new row . I have confirmed
> that the model includes the recently created row and also
> tried grid.AppendRows (the model's method always returns True
> ) but everything remains just the same (IOW
> model.GetNumberRows returns e.g. 15 whereas
> grid.GetNumberRows returns 14 ).

There is an extra step you have to take, but I have never seen it in any
formal documentation. The only place I have seen it is in some of the Grid
examples in the demo.

After appending, inserting, or deleting rows (or columns) in the table, you
must notify the grid of the change, like this -

    msg = wx.grid.GridTableMessage(self,          # The table
          wx.grid.GRIDTABLE_NOTIFY_ROWS_APPENDED, # what we did to it
          1                                       # how many
          )

or

    msg = wx.grid.GridTableMessage(self,          # The table
          wx.grid.GRIDTABLE_NOTIFY_ROWS_INSERTED, # what we did to it
          5,                                      # from which row
          1                                       # how many
          )

or

    msg = wx.grid.GridTableMessage(self,          # The table
          wx.grid.GRIDTABLE_NOTIFY_ROWS_DELETED,  # what we did to it
          5,                                      # from which row
          1                                       # how many
          )

followed by

    self.GetView().ProcessTableMessage(msg)

This assumes that it is called from the Table class.

If it is called from the Grid class, change self to self.GetTable(), and
self.GetView() to self.

HTH

Frank Millman


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.