How to update window after wxGrid is updated?

Brian Kelley bkelley at wi.mit.edu
Tue May 11 14:15:05 EDT 2004


Tim Williams wrote:
> Hi.
> 
> I'm starting to learn wxPython and for an exercise I'm writing a
> simple CSV file viewer. I just read in the CSV file and create a
> wx.Grid with the data.  I'm using Python 2.3.2 with wxPython 2.4.2.4.
> 
> Everything runs fine under linux, but when I try the same code on a
> Win XP machine, I have a window, but the frame the grid is in isn't
> seen until I do a minimize/maximize on the window. Besides that, it
> seems to run fine.  I tried to do a self.Refresh(True,
> self.grid.GetRect()), but that didn't help.

Annoying isn't it?  There are probably many solutions to this problem, 
but the one that I use is:

 >           self.grid.AutoSizeColumns(True)
 >           #self.Refresh(True, self.grid.GetRect())
             self.twiddle()

     def twiddle(self):
         x,y = self.GetSize()
         self.SetSize((x, y+1))
         self.SetSize((x,y))

This forces a repaint of the window and will also add scroll bars if 
necessary.  You are welcome to join us on the wxpython user list as well 
for more in-depth answers.

You have an unrelated bug in your code as well:

for i in len(row):

should be
for i in range(len(row)):


Brian



More information about the Python-list mailing list