I'm writing a really simple csv file reader/editor, using, of course,
wxGrid.
I'm finding that Grid.AutoSize is not working. It seems that is uses the
GridCellRenderer BestSize to figure out how to size things. My
GridTableBase handles only strings, and I've defined:
def GetTypeName(self, row, col):
"""Return the name of the data type of the value in the cell"""
return wx.grid.GRID_VALUE_STRING
So it should be using the built-in string renderer. However, I'm getting
all teh cells shrunk to skinny when I call AutoSize.
any ideas?
-Chris
I've enclosed the app -- not quite as small as it should be, but...
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
On Mar 2, 7:19 pm, Christopher Barker <Chris.Bar...@noaa.gov> wrote:
> HI folks,
>
> I'm writing a really simple csv file reader/editor, using, of course,
> wxGrid.
>
> I'm finding that Grid.AutoSize is not working. It seems that is uses the
> GridCellRenderer BestSize to figure out how to size things. My
> GridTableBase handles only strings, and I've defined:
>
> def GetTypeName(self, row, col):
> """Return the name of the data type of the value in the cell"""
> return wx.grid.GRID_VALUE_STRING
>
> So it should be using the built-in string renderer. However, I'm getting
> all teh cells shrunk to skinny when I call AutoSize.
>
> any ideas?
>
> -Chris
>
> I've enclosed the app -- not quite as small as it should be, but...
>
> --
> Christopher Barker, Ph.D.
> Oceanographer
>
>
I'd probably try AutoSizeColumns, maybe with the setAsMin=True keyword
argument passed in. Reading Robin's book, it sounds like AutoSize()
itself should work (pg 439), so I'm wondering if it's getting called
before the values are set in the cells. Maybe try calling it with
wx.CallAfter()?
-------------------
Mike Driscoll
> I'd probably try AutoSizeColumns, maybe with the setAsMin=True keyword
> argument passed in. Reading Robin's book, it sounds like AutoSize()
> itself should work (pg 439), so I'm wondering if it's getting called
> before the values are set in the cells. Maybe try calling it with
> wx.CallAfter()?
I don't think any of that is it. In fact, if you double click on the bar
between the column headers, you get the same thing -- the column resizes
to fit the header. That is presumably calling AutoSizeColumn(), and the
contents have certainly been rendered.
give the sample I posted a try if you can (note: I've only tested on OS-X)
I'll keep poking at it..
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
Mike Driscoll wrote:
I'm writing a really simple csv file reader/editor, using, of course,
wxGrid.
I'm finding that Grid.AutoSize is not working. It seems that is uses the
GridCellRenderer BestSize to figure out how to size things. My
GridTableBase handles only strings, and I've defined:
def GetTypeName(self, row, col):
"""Return the name of the data type of the value in the cell"""
return wx.grid.GRID_VALUE_STRING
So it should be using the built-in string renderer. However, I'm getting
all teh cells shrunk to skinny when I call AutoSize.
I don't think any of that is it. In fact, if you double click on the bar between the column headers, you get the same thing -- the column resizes to fit the header. That is presumably calling AutoSizeColumn(), and the contents have certainly been rendered.I'd probably try AutoSizeColumns, maybe with the setAsMin=True keyword
argument passed in. Reading Robin's book, it sounds like AutoSize()
itself should work (pg 439), so I'm wondering if it's getting called
before the values are set in the cells. Maybe try calling it with
wx.CallAfter()?
give the sample I posted a try if you can (note: I've only tested on OS-X)
I'll keep poking at it..
-Chris
--Christopher Barker, Ph.D.
Oceanographer
That was there for when the user loads a new file -- though I'm thinking
I should probably just create a new grid when that happens.
> This seemed to work better than the way
> you were doing it. See my attached screenshots.
> I'm on Windows XP with
> Python 2.5 and wxPython 2.8.10.1
well, for me, it looks the same either way when loaded. But when I
double click on the column header dividers, it doesn't auto-size right.
What happens for you when you do that?
Thanks,
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
Mike Driscoll wrote:That was there for when the user loads a new file -- though I'm thinking I should probably just create a new grid when that happens.
Well, I poked at it and tried moving the AutoSize() call itself to right after you instantiate it:
self.grid = CSVGrid(self)
self.grid.AutoSize()
I didn't call ForceRefresh().
well, for me, it looks the same either way when loaded. But when I double click on the column header dividers, it doesn't auto-size right. What happens for you when you do that?
This seemed to work better than the way you were doing it. See my attached screenshots.> I'm on Windows XP with
Python 2.5 and wxPython 2.8.10.1
Thanks,
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
I added a call to AutoSize to another event handler since I don't have a
cvs file handy, and it seems to be working fine for me. I noticed that
when you load the new file you are not doing anything to adjust the grid
to the new dimensions of the table, so if your new csv file has a
different number of rows/cols then perhaps that is the source of the
problem with AutoSize. Basically you need to send table messages to the
grid to tell it what the new dimensions are. There is some info about
this in the wiki: http://wiki.wxpython.org/UpdatingGridData
--
Robin Dunn
Software Craftsman
http://wxPython.org
> I added a call to AutoSize to another event handler since I don't have a
> cvs file handy, and it seems to be working fine for me.
OK, I added a button that calls AutoSize, and it does indeed work.
However, when I double click on the divider between two columns -- for
me, it shrinks the column down too small. That's not what I expect, but
maybe it's doing what it is supposed to do.
> I noticed that
> when you load the new file you are not doing anything to adjust the grid
> to the new dimensions of the table,
yes -- I hadn't got to that yet. I'm actually thinking that I might just
make a new grid when I load a new file -- that would set me up for
multiple documents at once, anyway.
> so if your new csv file has a
> different number of rows/cols then perhaps that is the source of the
> problem with AutoSize.
hmm -- I'll check that out.
> Basically you need to send table messages to the
> grid to tell it what the new dimensions are. There is some info about
> this in the wiki: http://wiki.wxpython.org/UpdatingGridData
Thanks, I'll take a look at that.
I've enclosed the
-Chris
> However, when I double click on the divider between two columns -- for
> me, it shrinks the column down too small. That's not what I expect, but
> maybe it's doing what it is supposed to do.
It's sizing it to fit the column header.