wxGrid owner-drawn complex objects

What if I would render a panel filled with other wx controls (ie
TextControls, BitmapButtons and so on) inside the cells in a wxGrid?
All the samples about GridCellRenderer / PyGridCellRenderer I saw
draws directly in a canvas using brushes/pens/etc, but the "panels" I
have to do are not that simple. How I can do that? Can I? Actually I
even don't know if wxGrid is the right choice :stuck_out_tongue:

No, wxGrid was not designed to allow cell editor widgets to always be visible. The idea is to allow the same editor to be used in multiple cells without needing to duplicate the widgets. For those cells that are not actively being edited then the cell rederer just draws the content. This design is intended to help reduce the resource requirements of the wxGrid.

If you describe your use case a little more then we can probably suggest a different approach to take that may work better.

ยทยทยท

On 4/12/10 9:23 AM, giorgio gelardi wrote:

What if I would render a panel filled with other wx controls (ie
TextControls, BitmapButtons and so on) inside the cells in a wxGrid?
All the samples about GridCellRenderer / PyGridCellRenderer I saw
draws directly in a canvas using brushes/pens/etc, but the "panels" I
have to do are not that simple. How I can do that? Can I? Actually I
even don't know if wxGrid is the right choice :stuck_out_tongue:

--
Robin Dunn
Software Craftsman

thanks for the answer, here's a sample: http://is.gd/bqynn
btw each element in my list can use few more controls (a button, a
checkbox or so), and while they are all the same base class I know
they could be (slightly) different, so I need to use 3 or more
renderer classes in the same list.
in flex cs3 I usually sort this stuff with itemrenderers.

ยทยทยท

On Apr 12, 9:28 pm, Robin Dunn <ro...@alldunn.com> wrote:

On 4/12/10 9:23 AM, giorgio gelardi wrote:

> What if I would render a panel filled with other wx controls (ie
> TextControls, BitmapButtons and so on) inside the cells in a wxGrid?
> All the samples about GridCellRenderer / PyGridCellRenderer I saw
> draws directly in a canvas using brushes/pens/etc, but the "panels" I
> have to do are not that simple. How I can do that? Can I? Actually I
> even don't know if wxGrid is the right choice :stuck_out_tongue:

No, wxGrid was not designed to allow cell editor widgets to always be
visible. The idea is to allow the same editor to be used in multiple
cells without needing to duplicate the widgets. For those cells that
are not actively being edited then the cell rederer just draws the
content. This design is intended to help reduce the resource
requirements of the wxGrid.

If you describe your use case a little more then we can probably suggest
a different approach to take that may work better.

--
Robin Dunn
Software Craftsmanhttp://wxPython.org

Hi,

thanks for the answer, here's a sample: http://is.gd/bqynn
btw each element in my list can use few more controls (a button, a
checkbox or so), and while they are all the same base class I know
they could be (slightly) different, so I need to use 3 or more
renderer classes in the same list.
in flex cs3 I usually sort this stuff with itemrenderers.

I believe you can do this kind of drawing in at least 2 ways without
using a beast like wxGrid:

1) Use wx.VListBox and draw the items yourself;
2) Use UltimateListCtrl in wx.lib.agw (SVN) and draw the items
yourself using custom renderers.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

==> Never *EVER* use RemovalGroup for your house removal. You'll
regret it forever.
The Doomed City: Removal Group: the nightmare <==

ยทยทยท

On 13 April 2010 08:10, giorgio gelardi wrote:

well, I had a look at UltimateReportDemo.py, but I have too much stuff
to render in each cell, so I want a more flexible drawing method than
pens/brushes. Can I use some html component (ie HtmlWindow) as
UltimateListCtrl item renderer?

ยทยทยท

On Apr 13, 9:28 am, Andrea Gavana <andrea.gav...@gmail.com> wrote:

Hi,

On 13 April 2010 08:10, giorgio gelardi wrote:

> thanks for the answer, here's a sample:http://is.gd/bqynn
> btw each element in my list can use few more controls (a button, a
> checkbox or so), and while they are all the same base class I know
> they could be (slightly) different, so I need to use 3 or more
> renderer classes in the same list.
> in flex cs3 I usually sort this stuff with itemrenderers.

I believe you can do this kind of drawing in at least 2 ways without
using a beast like wxGrid:

1) Use wx.VListBox and draw the items yourself;
2) Use UltimateListCtrl in wx.lib.agw (SVN) and draw the items
yourself using custom renderers.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."http://xoomer.alice.it/infinity77/

==> Never *EVER* use RemovalGroup for your house removal. You'll
regret it forever.http://thedoomedcity.blogspot.com/2010/03/removal-group-nightmare.html&lt;==

Hi,

(Please don't top-post)

well, I had a look at UltimateReportDemo.py, but I have too much stuff
to render in each cell, so I want a more flexible drawing method than
pens/brushes. Can I use some html component (ie HtmlWindow) as
UltimateListCtrl item renderer?

No, an item renderer in ULC should be a class which implements method
to *draw* the item: it can draw whatever you want, but you still need
to draw stuff on a wx.DC using pens and brushes. Another alternative
is to still use ULC but "attach" an HtmlWindow to every ULC items,
i.e.:

item = ulc.GetItem(8)
self.html = wx.html.HtmlWindow(ulc, -1)
item.SetWindow(self.html)
ulc.SetItem(item)

The UltimateReportDemo has some examples on how to attach whatever non
top-level window to an item. However, by doing so, you will probably
lose the ability to properly "highlight" a ULC item and its associated
window when the item is selected, as the drawing of the selected item
can not draw on top of your html window (see, for example, what
happens when you select the item with the multiline wx.TextCtrl in
UltimateReportDemo: the wx.TextCtrl background/foreground is not
modified and ULC can't draw on top of it).

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

==> Never *EVER* use RemovalGroup for your house removal. You'll
regret it forever.
The Doomed City: Removal Group: the nightmare <==

ยทยทยท

On 13 April 2010 09:27, giorgio gelardi wrote:

[...]

The UltimateReportDemo has some examples on how to attach whatever non
top-level window to an item. However, by doing so, you will probably
lose the ability to properly "highlight" a ULC item and its associated
window when the item is selected, as the drawing of the selected item
can not draw on top of your html window (see, for example, what
happens when you select the item with the multiline wx.TextCtrl in
UltimateReportDemo: the wx.TextCtrl background/foreground is not
modified and ULC can't draw on top of it).

perhaps htmlwindow events can be used to change listctrl selection.
anyway it's a good starting point, thank you.

giorgio

ยทยทยท

On Apr 13, 10:40 am, Andrea Gavana <andrea.gav...@gmail.com> wrote: