bionwater.blogg.se

Table indirection
Table indirection








  1. #Table indirection how to#
  2. #Table indirection code#

#Table indirection code#

Note: although the signature for the function specifies that the value must be a string, your Python editor code will call your Python table code directly, so arbitrary Python objects can be supported. Void SetValue(int row, int col, const wxString& value) - Called by the wxPyGridCellEditor classes (from their EndEdit method) to store updated values. I would suggest creating another method GetValueAsObject(self, row, col) for use by Python code instead of this method. WxString GetValue(int row, int col) - Called to retrieve a text value for the default editor/render classes, the grid will call this method. See the wxGrid section "Data Types, Renderers and Editors" for more details. The data-type specifier is a simple string, and should match the strings passed to wxGrid::* RegisterDataType. WxString GetTypeName(int row, int col) - If the cell has a value ( IsEmpt圜ell returns false), the grid will ask the table what type of data is stored in the cell. Navigation keys will skip the cell, programmatic selection using the wxGrid::MoveCursor*Block commands will also skip the cell. No renderer or editor will be assigned, the table will not be asked for the corresponding value. Your table class should override each of these methods.īool IsEmpt圜ell(int row, int col) - Returning a true value will result in the cell being "blank". These methods are called to return information about the contents of particular cells within the grid.

#Table indirection how to#

I would suggest not implementing these methods, and instead call the appropriate methods on the grid to reflect changes in your table (this is based on the idea that for the most part there is little code which knows how to interact with the grid class's methods, whereas your table's storage will likely be resized by functions in your program which did not relate to the GUI at all (particularly in database-based applications)).īool InsertRows(size_t pos = 0, size_t numRows = 1) -īool DeleteRows(size_t pos = 0, size_t numRows = 1) -īool InsertCols(size_t pos = 0, size_t numCols = 1) -īool DeleteCols(size_t pos = 0, size_t numCols = 1) -įour more primary customization points. If you do not implement the methods the calls will be ignored, and changes to the grid will not affect your table. These methods are called by the wxGrid class when the corresponding methods are called on the grid. Int GetNumberCols() - Return the number of columns to display within the grid Int GetNumberRows() - Return the number of rows to display within the grid Although the grid will not automatically resize to reflect changes in the results returned by these methods, you will likely want to always return accurate values to allow for automatic resizing functions such as shown in the wxGrid "Changing Size/Shape of Grid/Table" section. These methods are called during grid initialization to return the number of columns and rows to display within the grid. Is this a limitation that has been removed? I'm repeatedly setting SetTable(severalDifferentTables) on a wx.grid.Grid, followed by a ForceRefresh(), and it works great for me. You should consider storing a Python weak reference to the grid object in your table object (you will constantly need to access the grid object from your table class, incidentally). Also, depending on your version of wxPython, you may not be able to use the built-in GetView() method, as it will not return your Python wxGrid instance. If you need to change tables, you'll need to create a new wxGrid object. Important note: you cannot call SetTable more than once for a given grid. You associate your wxPyGridTableBase object with your wxGrid object by calling wxGrid::SetTable(myTable) during initialization of the grid. Caching values from remote and/or slow data sources may be a requirement to maintain interactivity within the grid's display routines.

table indirection

This particular mode of interaction should be kept in mind when designing your table class.

table indirection

Instead, the grid calls out the table for data values whenever a particular cell needs to be displayed and/or edited. When a grid instance is using a table object, the grid does not need to keep an internal record of each cell's value. The major benefit of the indirection provided by the table class is the ability to edit huge data sets with the grid.

table indirection

The table also provides information regarding the data type, empty and editable status of any given cell. Override methods in this class to determine how the grid will access your data. The wxPyGridTableBase class is the interface between the wxGrid and your application-specific data sources.

  • Grid-cell Attribute Management (+Read-Only Cells).









  • Table indirection