Re: Wx.Grid and popup over cells

2008-10-14 Thread Massi
On 14 Ott, 16:13, Mike Driscoll <[EMAIL PROTECTED]> wrote:
> On Oct 14, 5:21 am, Massi <[EMAIL PROTECTED]> wrote:
>
> > Hi everyone,
>
> > I'm writing a python script which uses a grid (PyGridTableBase) whose
> > cells can contain very large values (not only numbers, but also
> > strings). I've also written a custom renderer which dinamically shows
> > only the first n characters (according to the width of the cell)
> > replacing the last ones with dots. Now I would like to know if it is
> > possible to have a popup which shows the whole contents of a certain
> > cell when the mouse stops over the cell itself. Any ideas?
> > Thanks in advance.
>
> > Massi
>
> First off, let me recommend the wxPython mailing list for questions of
> this sort. You'll probably get more relevant help quicker if you go
> that route.
>
> Anyway, I've done tooltips on cells in a grid before and you'll need
> the same concept to use a pop-up dialog too. To begin, you'll want to
> bind to the mouse event, EVT_MOTION, like this:
>
> self.myGrid.GetGridWindow().Bind(wx.EVT_MOTION, self.onMouseOver)
>
> Next, you'll need to do something like the following in your mouse
> over function:
>
> 
>
> def onMouseOver(self, event):
> '''
> Method to calculate where the mouse is pointing and
> then set the tooltip dynamically.
> '''
>
> # Use CalcUnscrolledPosition() to get the mouse position
> within the
> # entire grid including what's offscreen
> x, y =
> self.totals_sheet.CalcUnscrolledPosition(event.GetX(),event.GetY())
>
> coords = self.totals_sheet.XYToCell(x, y)
> # you only need these if you need the value in the cell
> row = coords[0]
> col = coords[1]
> event.GetEventObject().SetToolTipString("My amazing tooltip")
>
> 
>
> Hopefully that will get you going. If not, just ask more questions
> (here or at the wxPython list).
>
> ---
> Mike Driscoll
>
> Blog:  http://blog.pythonlibrary.org
> Python Extension Building Network:http://www.pythonlibrary.org

That's exactly what I needed, thank you!
--
http://mail.python.org/mailman/listinfo/python-list


Re: Wx.Grid and popup over cells

2008-10-14 Thread Mike Driscoll
On Oct 14, 5:21 am, Massi <[EMAIL PROTECTED]> wrote:
> Hi everyone,
>
> I'm writing a python script which uses a grid (PyGridTableBase) whose
> cells can contain very large values (not only numbers, but also
> strings). I've also written a custom renderer which dinamically shows
> only the first n characters (according to the width of the cell)
> replacing the last ones with dots. Now I would like to know if it is
> possible to have a popup which shows the whole contents of a certain
> cell when the mouse stops over the cell itself. Any ideas?
> Thanks in advance.
>
> Massi

First off, let me recommend the wxPython mailing list for questions of
this sort. You'll probably get more relevant help quicker if you go
that route.

Anyway, I've done tooltips on cells in a grid before and you'll need
the same concept to use a pop-up dialog too. To begin, you'll want to
bind to the mouse event, EVT_MOTION, like this:

self.myGrid.GetGridWindow().Bind(wx.EVT_MOTION, self.onMouseOver)

Next, you'll need to do something like the following in your mouse
over function:



def onMouseOver(self, event):
'''
Method to calculate where the mouse is pointing and
then set the tooltip dynamically.
'''

# Use CalcUnscrolledPosition() to get the mouse position
within the
# entire grid including what's offscreen
x, y =
self.totals_sheet.CalcUnscrolledPosition(event.GetX(),event.GetY())

coords = self.totals_sheet.XYToCell(x, y)
# you only need these if you need the value in the cell
row = coords[0]
col = coords[1]
event.GetEventObject().SetToolTipString("My amazing tooltip")



Hopefully that will get you going. If not, just ask more questions
(here or at the wxPython list).

---
Mike Driscoll

Blog:   http://blog.pythonlibrary.org
Python Extension Building Network: http://www.pythonlibrary.org
--
http://mail.python.org/mailman/listinfo/python-list


Wx.Grid and popup over cells

2008-10-14 Thread Massi
Hi everyone,

I'm writing a python script which uses a grid (PyGridTableBase) whose
cells can contain very large values (not only numbers, but also
strings). I've also written a custom renderer which dinamically shows
only the first n characters (according to the width of the cell)
replacing the last ones with dots. Now I would like to know if it is
possible to have a popup which shows the whole contents of a certain
cell when the mouse stops over the cell itself. Any ideas?
Thanks in advance.

Massi
--
http://mail.python.org/mailman/listinfo/python-list