wxGrid within a wxGrid

Hi All,

I am probably trying to do the impossible here but nonetheless I would like to give it a try. I really think that it will open up some very interesting user interface possiblities if I can get it to work properly.

What I want to do is be able to put a wxGrid within the cell of another wxGrid as its edit control.

I have tried to derive a new class from both wxGrid and wxControl(for the edit control part). Then I have my editor class derived from wxPyGridCellEditor which tries to create one of these objects and set it as the control using SetControl().

class GridControl(wxGrid, wxControl):
    def __init__(self, parent, id):
        wxGrid.__init__(self, parent, id)
        wxControl.__init__(self, parent, id)

        self.CreateGrid(10, 10)
        self.SetRowLabelSize(0)
        self.SetColLabelSize(0)
        self.SetMargins(0,0)
        self.AutoSizeColumns()
...
class GridEditor(wxPyGridCellEditor):
    def __init__(self):
        wxPyGridCellEditor.__init__(self)

    def Create(self, parent, id, evtHandler):
        self._tc = GridControl(parent, id)
        self.SetControl(self._tc)
...

I know this is probably not the correct approach. Indeed it doesn't work as the CreateGrid call complains that self is not a wxGrid.

How would I go about doing something like this? Has someone out there already been down this road?

I have tried to create a wxControl derived class and then make the grid, or any other window, a child of that but I seem to be having problems getting the messages to work properly. For example I can get it to draw but you can't interact with it. Are there any tutorials or examples out there for making a control with (possibly several) sub windows or sub controls?

I am just beginning to learn both python and wxWindows so forgive me if these seems like silly questions.

Thank you,

Darin

···

_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail

wxproperty does grid-on-grid extensively, but it does the work with floating windows on top of the base grid (otherwise you need _really_ large cells in your grid). I'd guess that your second approach is the best one. I don't know of a tutorial for it, but poking about in wxoo and wxproperty will get you at least one or two examples of functional Controls with sub-controls embedded in them (I do them all the time).

HTH,
Mike

Darin Willits wrote:

Hi All,

I am probably trying to do the impossible here but nonetheless I would like to give it a try. I really think that it will open up some very interesting user interface possiblities if I can get it to work properly.

What I want to do is be able to put a wxGrid within the cell of another wxGrid as its edit control.

...

How would I go about doing something like this? Has someone out there already been down this road?

I have tried to create a wxControl derived class and then make the grid, or any other window, a child of that but I seem to be having problems getting the messages to work properly. For example I can get it to draw but you can't interact with it. Are there any tutorials or examples out there for making a control with (possibly several) sub windows or sub controls?

...

···

_______________________________________
  Mike C. Fletcher
  Designer, VR Plumber, Coder
  http://members.rogers.com/mcfletch/