how to use a grid as a spreadsheet

Yes. There are a few problems here.

1. The parent of your grid was the parent that was the whole panel class,
but that position on screen was overlapping with a second panel (which
you named 'panel'). By giving the grid parent=panel, it now is "really"
there not just a "ghost image" of the grid, and so you can interact
with it. (In general, when things don't work, it is always good to make
sure the widgets have the correct parents).

2. There is no need for this line at the bottom:
self.Frame = wx.Frame(None)
That is just created another frame that you do nothing with, and so if you
close the frame it is still lurking in memory--not good.

3. I had to change all the accented words to get it to run for me, but that
was just the way I had the encoding set up.

4. For the radiobuttons, you need to have a reference to your grid, but
grid was defined in another function, so the radiobutton event handler
function (OnRb2) doesn't know about grid. I made grid to be called
self.grid, so that all functions in the class can access it. To test it
out, put a number in the 0,0 box in your grid and click the second
radiobutton.

The revised version is attached.

HTH,
Che

calculator.py (2.7 KB)

···

On Tue, Nov 3, 2009 at 7:22 AM, Ignacio De Vicente Puyol <ignacio.puyol@gmail.com> wrote:

Hi,

I'm making a project in wxpython. It's a calculus program. It's divided into
different tabs doing each of one different calculus.

Well, the problem is than I can't get the info introduced in one of the
columns so in other one of them I could represent a calculus. What's more,
I've introduced some radiobuttons, so clicking on each of them makes
different calculus with the data extracted from the column. I've tried to do
everything, and I'm stuck, I don't know what I have to do.

Any ideas of what I should do?

Select? Or Get the value of? Have a look at wx.Grid's methods.
There is one called .GetSelectedCols(). See here:

http://docs.wxwidgets.org/2.6/wx_wxgrid.html#wxgridgetselectedcols

···

On Thu, Nov 5, 2009 at 12:53 PM, igneer <ignacio.puyol@gmail.com> wrote:

Ok, I understood how to do it, and I changed the function as follows:

def OnRb2(self, event):
value1 = float(self.grid.GetCellValue(0, 0))
value2 = float(self.grid.GetCellValue(0, 1))

newvalue = str(value1/value2)

self.grid.SetCellValue(0, 2, newvalue)

It runs well, but I don't know how to do it to select a whole column
instead of one single cell.