[wxpython-users] wx.Grid - TopRow

Raffaello Barella barbarossa.platz at gmail.com
Fri Apr 4 10:14:10 PDT 2008


Thanks, Bob.

 The "col=3D" line is a leftover of a former idea.

The problem with your version of the assert is that  in an empty grid even
row 0 does not exist, so the function should not be invoked. I suggest
instead
assert row < self.GetNumberRows() and row >=3D 0

Ciao

2008/4/4, Bob Klahn <bobstones at comcast.net>:
>
> At 11:34 AM 4/4/2008, Raffaello wrote:
>
> > Something different from MakeCellVisible(), Tim, that "brings the
> > specified cell into the visible grid cell area with minimal scrolling".=
 I
> > want to put it at the TOP of the cell area.
> > But you gave me an idea, so I wrote this function for my derived
> > wx.grid:
> >
> >    def SetTopRow(self, row):
> >        assert row < self.GetNumberRows()
> >        col =3D self.GetGridCursorCol()
> >        PixelsPerUnit =3D self.GetScrollPixelsPerUnit()
> >        CellRect =3D self.CellToRect(row, 0)
> >        x =3D CellRect[0] / PixelsPerUnit[0]
> >        y =3D (CellRect[1]  - CellRect[3]) / PixelsPerUnit[1]
> >        self.Scroll(x, y)
> >        #  wx.grid derives also from wx.ScrolledWindow
> >
> > Tested, it works.
> > So long.
> >
>
> Thanks, Raffaello, this works for me too.
>
> I'm using "<=3D" rather than "<" in the assert line, as I also want to
> display the grid when it's empty.
>
> By the way, you don't need the "col=3D" line; you're not using it.
>
> Bob
>
> _______________________________________________
> wxpython-users mailing list
> wxpython-users at lists.wxwidgets.org
> http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/200804=
04/a7222ebb/attachment.htm


More information about the wxpython-users mailing list