Rich Shepard wrote:
Where is the GetValue() method called using the grid table mechanism?
In both the demo/GridCustTable.py and listing 14.2 in the wPIA book, the
GetValue(self, row, col) method is called to provide data to the grid widget
from the underlying table. The logic is in the grid table class rather than
in the grid class.In my application, the grid cells are populated by the string, 'Empty,' if
there are no project-specific data in the database table. The method in my
application is written thusly:def GetValue(self, row, col):
if self.appData.altData != None:
return self.data
else: # no data for existing or alternative condx, but project exists
return 'Empty'However, there exist data for the first three columns in the grid that I
would like to have loaded when the project data file is opened. However,
when I try to add an embedded SQL statement in the 'else:' clause, python
complains that the 'str' has no 'execute' method.
Well, apparently whatever you have on the left side of the '.execute()' is a string object, not a database cursor object. Backtrack from there to see what is causing your confusion.
Trying to figure out why the SQL does not work in this location as it does
in many others (including two other locations in the same class), I looked
to see where GetValue() was being called. I cannot find the call in the
table or grid classes. So, why is it invoked and placing the string, 'Empty,'
in the grid?
It's called from the C++ code. In a nutshell there was a paint event and the Grid class is iterating through the cells that intersect the update region and asking each cell's renderer to paint itself, and the renderers are fetching the data from the table so they know what to draw.
···
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!