Bottom Page

Thread Rating:
  • 4 Vote(s) - 2.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Get value of wx grid cell
#1
I created added 5 wx grids in a list and populated data. And also created an event as below. when clicking a cell, it will print the number of row and column of the selected cell on that grid (don't know which grid). How do I get the value of the cell? Thanks.

def OnCellSelected(self, event):
print(event.GetRow(), event.GetCol())
Quote
#2
hello - use wx.Grid.GetCellValue(self, row, col)
returns value as string

index to all API docs (by category) here: https://wxpython.org/Phoenix/docs/html/main.html

Index of wx docs here: https://wxpython.org/Phoenix/docs/html/genindex-W.html

grid documentation here: https://wxpython.org/Phoenix/docs/html/w....grid.Grid
=====================
GetCellValue(self, *args, **kw)

   Returns the string contained in the cell at the specified location.

   For simple applications where a grid object automatically uses a default grid table of string values you use this function together with SetCellValue to access cell values. For more complex applications where you have derived your own grid table class that contains various data types (e.g. numeric, boolean or user-defined custom types) then you only use this function for those cells that contain string values.

   See wx.grid.GridTableBase.CanGetValueAs and the Grid Overview for more information.

   overload Overloaded Implementations:

   ------------------- method one ----------------
   GetCellValue (self, row, col)
   Parameters:

       row (int) –
       col (int) –

   Return type:

   string


   ------------------- method two ----------------
   GetCellValue (self, coords)
   Parameters: coords (wx.grid.GridCellCoords) –
   Return type: string
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  [WxPython] Grid. How to close the cell editor? ioprst 1 147 Dec-03-2019, 09:28 AM
Last Post: ioprst
  [WxPython] Why does an error occur after editing a grid cell? ioprst 2 159 Nov-12-2019, 12:31 PM
Last Post: Larz60+

Forum Jump:


Users browsing this thread: 1 Guest(s)