Getting the selected cell in a grid

When you select a cell in a grid – how can you find
out what cell is selected?

I have a grid with a paste event. I would like the text
pasted to be pasted from the row that’s selected.

If I select an entire row, GetSelectedRows work. The same
for GetSelectedCols.

If I select several cells, GetSelectionBlockTopLeft() and
BottomRight() works.

GetSelectedCells() always return [], and if I only select
one cell, GetSelectionBlock… also returns [].

How can I get the selected cell?

-Simen

Hi Simen,

Simen Haugen wrote:

When you select a cell in a grid – how can you find out what cell is selected?

I have a grid with a paste event. I would like the text pasted to be pasted from the row that’s selected.

If I select an entire row, GetSelectedRows work. The same for GetSelectedCols.

If I select several cells, GetSelectionBlockTopLeft() and BottomRight() works.

GetSelectedCells() always return , and if I only select one cell, GetSelectionBlock… also returns .

How can I get the selected cell?

What about:

self.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.OnSelectCell)

def OnSelectCell(self, event):
self.curRow = event.GetRow()
self.curCol = event.GetCol()

Werner

···

-Simen

This is one of the things that drove me crazy about wxPython - you'd
think it would be straightforward, but it's not. However, if you can,
you should take a look at the grid class from the Dabo guys
(http://dabodev.com). Their grid has several simple properties that
you can access: CurrentRow, CurrentColumn and Selection. One of those
should be what you need, depending on whether you have the grid set to
allow for single-cell selection or cell ranges.

···

On 6/29/06, Simen Haugen <Simen@nordicstats.com> wrote:

When you select a cell in a grid – how can you find out what cell is
selected?

--

# p.d.

The book, wxPython In Action, is an excellent source of information, well worth the cost. wxPython can indeed drive you crazy, esp. since the documentation is scattered in a number of places and is not always up to date. The book helped me tremendously in getting my head around things.
Hank

Peter Decker wrote:

···

On 6/29/06, Simen Haugen <Simen@nordicstats.com> wrote:

When you select a cell in a grid – how can you find out what cell is
selected?

This is one of the things that drove me crazy about wxPython - you'd
think it would be straightforward, but it's not. However, if you can,
you should take a look at the grid class from the Dabo guys
(http://dabodev.com). Their grid has several simple properties that
you can access: CurrentRow, CurrentColumn and Selection. One of those
should be what you need, depending on whether you have the grid set to
allow for single-cell selection or cell ranges.

Simen Haugen wrote:

When you select a cell in a grid – how can you find out what cell is selected?

I have a grid with a paste event. I would like the text pasted to be pasted from the row that’s selected.

If I select an entire row, GetSelectedRows work. The same for GetSelectedCols.

If I select several cells, GetSelectionBlockTopLeft() and BottomRight() works.

GetSelectedCells() always return , and if I only select one cell, GetSelectionBlock… also returns .

How can I get the selected cell?

The Grid class supports various kinds of selections, row, col, blocks, and single cells. Unfortunately there is no single method that will give you all of the selections at once, you need to check for all selection types using each of the various APIs.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

I have the book, and it is wonderful. Kudos to Noel and Robin!

Had that book been out a few years ago, I probably wouldn't have
pulled out as much of my hair as I had getting wxPython to work the
way I wanted. The thing I like about using the Dabo ui module is that
I get all of the power of wxPython with none of the C++ smell.

···

On 6/29/06, Hank Knox <hank@music.mcgill.ca> wrote:

The book, wxPython In Action, is an excellent source of information,
well worth the cost. wxPython can indeed drive you crazy, esp. since the
documentation is scattered in a number of places and is not always up to
date. The book helped me tremendously in getting my head around things.

--

# p.d.

Thanks. Works just as I wanted. Don't know why I didn't think about
that.

-Simen

···

-----Original Message-----
From: Werner F. Bruhin [mailto:werner.bruhin@free.fr]
Sent: 29. juni 2006 17:45
To: wxPython-users@lists.wxwidgets.org
Subject: Re: [wxPython-users] Getting the selected cell in a grid

Hi Simen,

Simen Haugen wrote:

When you select a cell in a grid - how can you find out what cell is
selected?

I have a grid with a paste event. I would like the text pasted to be
pasted from the row that's selected.

If I select an entire row, GetSelectedRows work. The same for
GetSelectedCols.

If I select several cells, GetSelectionBlockTopLeft() and
BottomRight() works.

GetSelectedCells() always return , and if I only select one cell,
GetSelectionBlock... also returns .

How can I get the selected cell?

What about:

self.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.OnSelectCell)

def OnSelectCell(self, event):
self.curRow = event.GetRow()
self.curCol = event.GetCol()

Werner

-Simen

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

I just recently started using the dabo framework, but not on this
project. Dabo is really great, but until now I've only used it on
database applications. I'm planning on porting other applications to
Dabo since it rocks hard, but until I can do that it's plain wxPython.

-Simen

···

-----Original Message-----
From: Peter Decker [mailto:pydecker@gmail.com]
Sent: 29. juni 2006 17:59
To: wxPython-users@lists.wxwidgets.org
Subject: Re: [wxPython-users] Getting the selected cell in a grid

On 6/29/06, Simen Haugen <Simen@nordicstats.com> wrote:

When you select a cell in a grid - how can you find out what cell is
selected?

This is one of the things that drove me crazy about wxPython - you'd
think it would be straightforward, but it's not. However, if you can,
you should take a look at the grid class from the Dabo guys
(http://dabodev.com). Their grid has several simple properties that
you can access: CurrentRow, CurrentColumn and Selection. One of those
should be what you need, depending on whether you have the grid set to
allow for single-cell selection or cell ranges.
--

# p.d.

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

I've actually bought the book, but I haven't read it yet. I started, but
it was a bit too "Let me explain you the obvious just one more time". I
guess I'll have to check it out again. I didn't find the book useful as
a reference at all. I've found the wxWidgets book (free online) a much
better reference and learning tool.

But I agree... The documentation for wxPython could be better. Still
it's enough information for most needs online, and I've used mostly the
documentation for wxWidgets and found that to work just as good.
wxPython (and wxWidgets of course) is a great library all together.

-Simen

···

-----Original Message-----
From: Hank Knox [mailto:hank@music.mcgill.ca]
Sent: 29. juni 2006 18:04
To: wxPython-users@lists.wxwidgets.org
Subject: Re: [wxPython-users] Getting the selected cell in a grid

The book, wxPython In Action, is an excellent source of information,
well worth the cost. wxPython can indeed drive you crazy, esp. since the

documentation is scattered in a number of places and is not always up to

date. The book helped me tremendously in getting my head around things.
Hank

Peter Decker wrote:

On 6/29/06, Simen Haugen <Simen@nordicstats.com> wrote:

When you select a cell in a grid - how can you find out what cell is
selected?

This is one of the things that drove me crazy about wxPython - you'd
think it would be straightforward, but it's not. However, if you can,
you should take a look at the grid class from the Dabo guys
(http://dabodev.com). Their grid has several simple properties that
you can access: CurrentRow, CurrentColumn and Selection. One of those
should be what you need, depending on whether you have the grid set to
allow for single-cell selection or cell ranges.

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

I've actually bought the book, but I haven't read it yet. I
started, but it was a bit too "Let me explain you the obvious
just one more time".

I didn't find it that obvious. I mean, it is supposed to be more useful for beginners (as this type of books should always be), but whatever wxPython guru you are, there is always something you could have done better/in a nicer way. When I search for something like simplicity with power, I often refer to the book.

Just my 1.5 cents :smiley:

Andrea.

···

_________________________________________
Andrea Gavana (gavana@kpo.kz)
Reservoir Engineer
KPDL
4, Millbank
SW1P 3JA London

Direct Tel: +44 (0) 20 717 08936
Mobile Tel: +44 (0) 77 487 70534
Fax: +44 (0) 20 717 08900
Web: http://xoomer.virgilio.it/infinity77
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯