hyperlink in a grid cell

I've tried to follow your hints with the following code (self is a grid) but I'm not succeeding in getting a hand-shape cursor hovering on colum 2. Where am I going wrong? (maybe there is also an offset problem with the grid labels?)

Marco

        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer)
        self.timer.Start(100)
    def OnTimer(self,evt):
        ms = wx.GetMouseState()
        xy = self.ScreenToClient((ms.x, ms.y))
        r,c = self.XYToCell(xy[0],xy[1])
        print r,c
        if c==2:
            self.SetCursor(wx.StockCursor(wx.CURSOR_HAND))
        else:
            self.SetCursor(wx.StockCursor(wx.CURSOR_DEFAULT))
        evt.Skip()

---------- Initial Header -----------

···

From : "Josiah Carlson" jcarlson\@\uci.\edu

To : "\m.\prosperi@\libero.\it" \m.\prosperi@\libero.\it,"wxpython-users" wxpython-users\@lists.\wxwidgets.\org
Cc :
Date : Thu, 10 Aug 2006 15:24:30 -0700
Subject : Re: [wxPython-users] hyperlink in a grid cell

"m\.prosperi\@libero\.it" <\m.\prosperi@\libero.\it> wrote:
>
> Hi,
> I would like to put an hyperlink in a grid cell. I mean, something that
> looks like normal text (like 'my link') but when I click on this cell
> (previously selected) a URL opens up in a browser o in a pdf reader. Do
> I have to customize an editor? using a HyperLinkCtrl?
>
> thanks for hints or code snippets,

Bind wx.MOUSE_BTN_LEFT to your grid, capture its x and y coordinates,
find the cell, then use webbrowser.open(url).

- Josiah

I've tried to follow your hints with the following code (self is a
grid) but I'm not succeeding in getting a hand-shape cursor hovering on
column 2. Where am I going wrong? (maybe there is also an offset problem
with the grid labels?)

Based on your OnTimer definition, you would need at least 3 columns in
your grid. If you only had 2, then it would never change the cursor.
Aside from that, it looks like it should work.

- Josiah

···

"m\.prosperi\@libero\.it" <m.prosperi@libero.it> wrote:

        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer)
        self.timer.Start(100)
    def OnTimer(self,evt):
        ms = wx.GetMouseState()
        xy = self.ScreenToClient((ms.x, ms.y))
        r,c = self.XYToCell(xy[0],xy[1])
        print r,c
        if c==2:
            self.SetCursor(wx.StockCursor(wx.CURSOR_HAND))
        else:
            self.SetCursor(wx.StockCursor(wx.CURSOR_DEFAULT))
        evt.Skip()

---------- Initial Header -----------

>From : "Josiah Carlson" jcarlson\@\uci.\edu
To : "\m.\prosperi@\libero.\it" \m.\prosperi@\libero.\it,"wxpython-users" wxpython-users\@lists.\wxwidgets.\org
Cc :
Date : Thu, 10 Aug 2006 15:24:30 -0700
Subject : Re: [wxPython-users] hyperlink in a grid cell

>
> "m\.prosperi\@libero\.it" <\m.\prosperi@\libero.\it> wrote:
> >
> > Hi,
> > I would like to put an hyperlink in a grid cell. I mean, something that
> > looks like normal text (like 'my link') but when I click on this cell
> > (previously selected) a URL opens up in a browser o in a pdf reader. Do
> > I have to customize an editor? using a HyperLinkCtrl?
> >
> > thanks for hints or code snippets,
>
> Bind wx.MOUSE_BTN_LEFT to your grid, capture its x and y coordinates,
> find the cell, then use webbrowser.open(url).
>
> - Josiah
>
>