[wxPython] wxGrid Custom Renderer Issue

I can't seem to get the the custom grid renderers to work. Even the one included in the wxPython 2.3.1 demo doesn't seem to do anything. Specifically the Draw method is never called. Here is a condensed version of the issue that I am having (I cut the relevant sections out of the demo application)

Is this a failure of my installation or a known feature? I am running on Windows 2000 and tested with Python 2.1, Python 2.2 using both the hybrid and non hybrid versions.

Thanks for any assistance.

from wxPython.wx import *
from wxPython.grid import *
import string, random

class MyCustomRenderer(wxPyGridCellRenderer):
    def __init__(self):
        wxPyGridCellRenderer.__init__(self)

    def Draw(self, grid, attr, dc, rect, row, col, isSelected):
        print "MyCustomRenderer.Draw called!"
        dc.SetBackgroundMode(wxSOLID)
        dc.SetBrush(wxBrush(wxBLACK, wxSOLID))
        dc.SetPen(wxTRANSPARENT_PEN)
        dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height)

        dc.SetBackgroundMode(wxTRANSPARENT)
        dc.SetFont(attr.GetFont())

        text = grid.GetCellValue(row, col)
        colors = [wxRED, wxWHITE, wxCYAN]
        x = rect.x + 1
        y = rect.y + 1
        for ch in text:
            dc.SetTextForeground(random.choice(colors))
            dc.DrawText(ch, x, y)
            w, h = dc.GetTextExtent(ch)
            x = x + w
            if x > rect.right - 5:
                break

    def GetBestSize(self, grid, attr, dc, row, col):
        print "getting size"
        text = grid.GetCellValue(row, col)
        dc.SetFont(attr.GetFont())
        w, h = dc.GetTextExtent(text)
        return wxSize(w, h)

    def Clone(self):
        return MyCustomRenderer()

class EditorsAndRenderersGrid(wxGrid):
    def __init__(self, parent, log):
        wxGrid.__init__(self, parent, -1)
        self.log = log

        self.CreateGrid(2, 2)

        label = 'MyCustomRenderer'
        value = 'This is my renderer'

        renderer = MyCustomRenderer()
              self.SetCellValue(0, 0, label)
        self.SetCellValue(0, 1, value)
        self.SetCellRenderer(0, 1, renderer)
        self.SetCellRenderer(0, 0, renderer)
        # There is a bug in wxGTK for this method...
        self.AutoSizeColumns(true)
        self.AutoSizeRows(true)

class TestFrame(wxFrame):
    def __init__(self, parent, log):
        wxFrame.__init__(self, parent, -1, "Editors and Renderers Demo", size=(640,480))
        grid = EditorsAndRenderersGrid(self, log)

if __name__ == '__main__':
    import sys
    app = wxPySimpleApp()
    frame = TestFrame(None, sys.stdout)
    frame.Show(true)
    app.MainLoop()

···

--
Brian Kelley bkelley@wi.mit.edu
Whitehead Institute for Biomedical Research 617 258-6191

I can't seem to get the the custom grid renderers to work. Even the one
included in the wxPython 2.3.1 demo doesn't seem to do anything.
Specifically the Draw method is never called. Here is a condensed
version of the issue that I am having (I cut the relevant sections out
of the demo application)

This was a known problem that has already been fixed. You can check the
2.3.3 preview to be sure.

···

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

Aha ... does this mean the 2.3.2.1 Grid demo is broken in the "Showing
Editors and Renderers" [GridStdEdRend.py] module? That might account for
current head scratchings [I wouldn't mention it, but I can't afford to lose
the hair]. I'll preview 2.3.3.

regards
Steve

···

--
Steve Holden: http://www.holdenweb.com/ ; Python Web Programming:
http://pydish.holdenweb.com/pwp/

----- Original Message -----
From: "Robin Dunn" <robin@alldunn.com>
To: <wxpython-users@lists.wxwindows.org>
Sent: Friday, April 26, 2002 6:36 PM
Subject: Re: [wxPython] wxGrid Custom Renderer Issue

[Brian Kelley]
> I can't seem to get the the custom grid renderers to work. Even the one
> included in the wxPython 2.3.1 demo doesn't seem to do anything.
> Specifically the Draw method is never called. Here is a condensed
> version of the issue that I am having (I cut the relevant sections out
> of the demo application)

This was a known problem that has already been fixed. You can check the
2.3.3 preview to be sure.

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

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users

Aha ... does this mean the 2.3.2.1 Grid demo is broken in the "Showing
Editors and Renderers" [GridStdEdRend.py] module?

Yes.

···

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

Steve Holden wrote:

Aha ... does this mean the 2.3.2.1 Grid demo is broken in the "Showing
Editors and Renderers" [GridStdEdRend.py] module? That might account for
current head scratchings [I wouldn't mention it, but I can't afford to lose
the hair]. I'll preview 2.3.3.

2.3.3 is working like a champ for me. Thanks to all.

···

--
Brian Kelley bkelley@wi.mit.edu
Whitehead Institute for Biomedical Research 617 258-6191

Brian:

You don't happen to have built a Windows binary installer for 2.3.3 do you?
I'd appreciate the chance to download it if you have.

regards
Steve

···

--
Steve Holden: http://www.holdenweb.com/ ; Python Web Programming:
http://pydish.holdenweb.com/pwp/

----- Original Message -----
From: "Brian Kelley" <bkelley@wi.mit.edu>
To: <wxpython-users@lists.wxwindows.org>
Sent: Wednesday, May 01, 2002 4:10 PM
Subject: Re: [wxPython] wxGrid Custom Renderer Issue

Steve Holden wrote:

>Aha ... does this mean the 2.3.2.1 Grid demo is broken in the "Showing
>Editors and Renderers" [GridStdEdRend.py] module? That might account for
>current head scratchings [I wouldn't mention it, but I can't afford to

lose

>the hair]. I'll preview 2.3.3.
>
2.3.3 is working like a champ for me. Thanks to all.

--
Brian Kelley bkelley@wi.mit.edu
Whitehead Institute for Biomedical Research 617 258-6191

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users

[Steve Holden]

You don't happen to have built a Windows binary installer for
2.3.3 do you?
I'd appreciate the chance to download it if you have.

You can find them here, Steve:

Look for wxPython-2.3.3pre2-Py22-hybrid.exe.

···

---
Patrick K. O'Brien
Orbtech

[Steve Holden]
>
> You don't happen to have built a Windows binary installer for
> 2.3.3 do you?
> I'd appreciate the chance to download it if you have.

You can find them here, Steve:

Look for wxPython-2.3.3pre2-Py22-hybrid.exe.

Yup, should have looked in SourceForge. Thanks, downloading now!

regards
Steve

···

----- Original Message -----
From: "Patrick K. O'Brien" <pobrien@orbtech.com>
To: <wxpython-users@lists.wxwindows.org>
Sent: Wednesday, May 01, 2002 4:32 PM
Subject: RE: [wxPython] wxGrid Custom Renderer Issue

--
Steve Holden: http://www.holdenweb.com/ ; Python Web Programming:
http://pydish.holdenweb.com/pwp/