wxGrid

G

Gensek

I have a grid. I want to sort it when a column label is clicked. I know
about the EVT_GRID_LABEL_LEFT_DCLICK event, but that is not enough. I
do not merely need to know that a label was clicked. I need to know
which label was clicked. I do not know how to do that. I suspect you
might know. I request that you tell me.

I also wish to know some other things: how to find out the location of
a mouse pointer in a wxWindow (or at least the frame), and how to
change the color of a single specified pixel in a bitmap.

I use Python 2.3, wxPython 2.4.2.
 
M

Michalis Kabrianis

Gensek said:
I have a grid. I want to sort it when a column label is clicked. I know
about the EVT_GRID_LABEL_LEFT_DCLICK event, but that is not enough. I
do not merely need to know that a label was clicked. I need to know
which label was clicked. I do not know how to do that. I suspect you
might know. I request that you tell me.

I also wish to know some other things: how to find out the location of
a mouse pointer in a wxWindow (or at least the frame), and how to
change the color of a single specified pixel in a bitmap.

I use Python 2.3, wxPython 2.4.2.

Hi,
In C++, you can use event.GetColumn() to get that info.
Look at wxGridEvent.
If I were you, I would try to see if these functions are also available
on wxPython

Michalis
 
P

Paul McNett

Gensek said:
I have a grid. I want to sort it when a column label is clicked. I know
about the EVT_GRID_LABEL_LEFT_DCLICK event, but that is not enough. I
do not merely need to know that a label was clicked. I need to know
which label was clicked. I do not know how to do that. I suspect you
might know. I request that you tell me.

Please see:

http://wiki.wxpython.org/index.cgi/DrawingOnGridColumnLabel

It tells you how to draw a sort indicator on the clicked header, which
involves first figuring out which header was clicked. As you've found,
the entire header region is one wxWindow, not one per column, which does
make it a bit more difficult to sort out which column header was
clicked. This sample does not go on to show you how to actually do the
sorting, however.

I also wish to know some other things: how to find out the location of
a mouse pointer in a wxWindow (or at least the frame),

Bind a function to the wx.EVT_MOTION event, and then call GetPosition()
of the event instance, which returns a (x,y) tuple of the mouse position
at the time the event was generated. x and y are relative to the window
that emitted the event.

and how to
change the color of a single specified pixel in a bitmap.

I don't know how to do this, but I'd take a look at the docs for
wxBitmap for starters.

I use Python 2.3, wxPython 2.4.2.

You should upgrade to wxPython 2.5.3 (2.5.4 is around the corner
though). If you have a bunch of code already written for 2.4, you'll
want to upgrade carefully and refer to the migration guide at
http://wxpython.org first. Otherwise, if you are just starting with
wxPython, trust me you definitely want to upgrade ASAP - a lot of bugs
have been fixed and new features added since 2.4.2, and wxPython experts
will be better able to help you if you use a recent version...

Also, you may find more and better help by joining the wxpython-users
list - you can find a link at http://wxpython.org.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,221
Messages
2,571,133
Members
47,748
Latest member
LyleMondra

Latest Threads

Top