No generictable for wx.grid.Grid

In the grid API, the "table" is what describes the data - it's
essentially the model in MVC. As such, it's responsible for describing
the data as well as providing it. The wx.grid.GridTableBase API has
methods that you must implement to provide the number of columns, the
column labels, and so on.

···

On 8/29/07, Rich Shepard <rshepard@appl-ecosys.com> wrote:

On Wed, 29 Aug 2007, Rich Shepard wrote:

> File "/data1/eikos/dataPage.py", line 16, in ?
> import generictable
> ImportError: No module named generictable

   Got this fixed. The application loads, but the tab with the grid is empty.
How do I define empty data while setting up the UI, and when there are no
data loaded in any tabs? That is, if I separate the model, view, and data, but
there are no data to display, how can I show an empty grid with the defined
column labels?

Thanks,

Rich

Chris,

   The tab with the grid is almost working now, there's a display disparity
that really puzzles me, and I don't know where to look for the source as no
error or warning messages are generated by python.

   At the top of the module I define column labels:

colLabels = ('Components', 'Subcomponents', 'Variable', 'Current 1',
              'Current 2', 'Current 3', 'Current 4', 'Current 5',
              'Current 6', 'Current 7', 'Current 8', 'Current 9',
              'Current 10', 'Current 11', 'Current 12', 'No Action',
              'Alt 2', 'Alt 3', 'Alt 4', 'Alt 5', 'Alt 6', 'Alt 7',
              'Alt 8', 'Alt 9', 'Alt 10', 'Alt 11', 'Alt 12', 'Alt 13',
              'Alt 14', 'Alt 15')

and in the GenericTable class is the function:

   def GetColLabelValue(self, col):
     if self.colLabels:
       return self.colLabels[col]

   When I invoke the application and click on the appropriate tab, the grid
displays, but the first 5-1/2 labels are not visible; it starts with "
ent 3". However, if I scroll horizontally to the right, then back to the
left, the column labels become visible. It's as if there was some window
hiding the labels, but the column dividers are still visible although the
column label boxes are empty.

   Have you any idea where I start looking for the source of this anomaly?

Thanks,

Rich

···

On Wed, 29 Aug 2007, Chris Mellon wrote:

In the grid API, the "table" is what describes the data - it's essentially
the model in MVC. As such, it's responsible for describing the data as
well as providing it. The wx.grid.GridTableBase API has methods that you
must implement to provide the number of columns, the column labels, and so
on.

--
Richard B. Shepard, Ph.D. | The Environmental Permitting
Applied Ecosystem Services, Inc. | Accelerator(TM)
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863

You had an error in GetRowLabelValue: you were returning an int, not a
string. Returning anything except a string from this method causes
painting to abort. Since the error only happened when a row label was
requested, resizing horizontally (which doesn't re-check for the row
labels) would paint the column headers, but growing vertically or
scrolling (which does) would cause them to vanish. Quite bizarre
behavior if you don't know whats happening ;).

I'm not 100% why it causes an error at all. Hang on, technical detail
coming up :wink:

GetRowLabelVaue is implemented in C++ by a method which calls the
Python method, calls Py2wxString to convert the result to a wxString,
and returns that. Py2wxString attempts to convert to a unicode object
and returns wxEmptyString if that fails. It does not print or clear
the Python error. However, returning wxEmptyString should be perfectly
safe and I've tested it in C++ code and it doesn't interfere with
painting at all. The only thing I can think is that it's related to
PyErr being set somehow.

So, in conclusion: Make sure that you return strings from your
GetRowLabelValue (and similar) methods.

Robin: Any thoughts on a better way to handle errors here? Maybe in
the various callback macros in grid.i?

···

On 8/29/07, Rich Shepard <rshepard@appl-ecosys.com> wrote:

On Wed, 29 Aug 2007, Chris Mellon wrote:

> Create a minimal sample that shows the problem and post it here.

   Attached: samplePage.py

Rich