Hello wxPython users,
I try to build a grid where each row is very long.
In order to show the data more easily, I want to make the rows multiline.
This concept is afaik not available.
So I try to make a pane renderer, i.e. a wxPanel with wxTextCtrl and other widgets.
The data-flow between the grid-data and the wxPanel is regulated by some special routines
and is no problem.
However, I need to Draw my wxPanel.
The method I have tried is:
pane.SetSize((w, h))
pane.Refresh()
wx.wxYield()
panedc = wx.wxClientDC(pane)
dc.Blit(rect.x, rect.y, w, h, panedc, 0, 0, wx.wxCOPY)
The problem is: I need the pane to be visible in my screen, in order to have it correctly
refresh. If I put it on top of my grid, this method works. But it looks extremely ugly, and it
interferes with the grid. If I stack it below the grid, the refresh does not do a thing.
So, where do I keep my pane ???
Pim Buurman
X>support
Mulitline rows possibility 1:
What you want is to split a single row with large numbers of cells into two rows with 1/2 the cells each. If so, just use wxPyGridTableBase and override GetNumberRows, GetNumberCols, GetValue, etceteras to return the first row [0:x] as row 1 and first row [x:] as row 2.
Multiline rows possibility 2:
What you want is a renderer for a single cell that handles very long lines of text. My suggestion would be to use the grid's auto-row-size feature and a custom grid-cell renderer which reports a larger height and wraps the text.
The renderer would examine the text, and split any long lines (i.e. insert a newline) before doing a normal text-rendering pass. You'd want to have the GetBestSize method determine the dimensions in the standard way (use the dc to find the text extents of the modified value, add some padding and return the value).
Putting your own window in front of the grid is a pain, and I wouldn't suggest it if you can avoid it. The grid is designed pretty tightly to do a certain set of things in a certain way, and messing up its expectations (such as that there are no windows in the way of triggering an edit of a cell) causes problems most of the time. Even a frame can be awkward; I'm still trying to find a way to avoid that in wxprop.
Oh, shameless plug:
http://wiki.wxpython.org/index.cgi/wxGrid_20Manual
tries to give an overview of the various pieces in the wxPython wxGrid universe. In particular, look at:
http://wiki.wxpython.org/index.cgi/wxPyGridCellRenderer
Hope this helps,
Mike
Pim Buurman wrote:
Hello wxPython users,
I try to build a grid where each row is very long.
In order to show the data more easily, I want to make the rows multiline.
This concept is afaik not available.
So I try to make a pane renderer, i.e. a wxPanel with wxTextCtrl and other widgets.
...
<description of panel-based attempt cut>
···
_______________________________________
Mike C. Fletcher
http://members.rogers.com/mcfletch/