grid with checkbox and other "non-Text" control

Hello,

I would like to use a grid that can display checkboxes, maybe buttons
and combox in each cell of a particular column.

Can I use a wxGrid widget or have I to use wxFlexGridSizer and
reimplementing things such as changing the size of a column using the
mouse?

Thanks for your advises.

···

--
Everaert Roland <roland_everaert@yahoo.fr>

In fact wxgrid does what I want, I just need to read the docs :wink:

But even reading the docs, there thinks that I don't understand. I have
used the demo GridCustTable.py and change it to add columns label after
the call of SetTable() and not in the __init__ method of the
CustomDataTable() but the way I do it doesn't works and I don't see
where is the problem.

Attached is the GridCustTable.py renamed and modified.

I use python 2.3.3 and wxpython 2.4.2.4

Here is the code that handle the grid:

class TestFrame(wxFrame):
    def __init__(self, parent):
        wxFrame.__init__(self, parent, -1, "Custom Table, data driven
Grid Demo", size=(640,480))
        p = wxPanel(self, -1, style=0)
        agrid = ToDoGrid(p, -1)

        # I set labels here
        agrid.SetGridLabelsandTypes()

        bs = wxBoxSizer(wxVERTICAL)
        bs.Add(agrid, 1, wxGROW|wxALL, 5)
        p.SetSizer(bs)

TDGridTools.py (7.2 KB)

···

Le ven 02/04/2004 à 20:13, Robin Dunn a écrit :

Everaert Roland wrote:
> Hello,
>
> I would like to use a grid that can display checkboxes, maybe buttons
> and combox in each cell of a particular column.
>
> Can I use a wxGrid widget or have I to use wxFlexGridSizer and
> reimplementing things such as changing the size of a column using the
> mouse?

The wx.Grid can only display one control (grid cell editor) at a time,
so if you want all the controls to be active then you'll need to do
something like the latter option.

#---------------------------------------------------------------------------

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

Hope this mail is not to big.

Thanks for any advise.

--
Everaert Roland <roland_everaert@yahoo.fr>

Everaert Roland wrote:
...

I have finally found what I was seeking for.

The aim of this application is to be able to display a different grid
(column number and type) following the file loaded by the application on
request of the user.

I have found that to display with the minimum of code a grid with a
different "format" I have to remove the current grid from the container
(a sizer) and create a new grid with the Table instance I want to use.
My question is : is there another way to display a different grid
format?

When I say format, I mean number of column, type of data, etc.

My (now very old) wxGrid manual on the wxPython Wiki has a recipe for this:
    http://wiki.wxpython.org/index.cgi/wxGrid (see Changing Size/Shape of Grid/Table)
with the manual base here:
    http://wiki.wxpython.org/index.cgi/wxGrid_20Manual
you'd normally handle data-type changes by having your Table (as distinct from the grid) determine the data-type at run-time.

HTH,
Mike

···

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

Everaert Roland wrote:
...

>I have finally found what I was seeking for.
>
>The aim of this application is to be able to display a different grid
>(column number and type) following the file loaded by the application on
>request of the user.
>
>I have found that to display with the minimum of code a grid with a
>different "format" I have to remove the current grid from the container
>(a sizer) and create a new grid with the Table instance I want to use.
>My question is : is there another way to display a different grid
>format?
>
>When I say format, I mean number of column, type of data, etc.
>
>
My (now very old) wxGrid manual on the wxPython Wiki has a recipe for this:
    http://wiki.wxpython.org/index.cgi/wxGrid (see Changing Size/Shape
of Grid/Table)
with the manual base here:
    http://wiki.wxpython.org/index.cgi/wxGrid_20Manual
you'd normally handle data-type changes by having your Table (as
distinct from the grid) determine the data-type at run-time.

Thanks for the link, on wxgrid in the wiki, I have completely forgot it
:frowning:

Another question about grid and events.

When I trap the EVT_GRID_SELECT_CELL event, it is impossible to edit the
content of the cells, how can I do to force, the grid or whatever to
allow me to edit a cell in this case?

#Init of the frame
.
.
.
        # Grid Event
        EVT_GRID_SELECT_CELL(self.TDGrid, self.OnGridItemSelected)
.
.
.
    def OnGridItemSelected(self, event):
        """Method Called when selecting a row in the grid"""
        if event.GetRow() != self.currentItem:
            self.currentItem = event.GetRow()
           
self.tc_TaskComment.SetValue(self.TDGrid.GethiddenDataRow(self.currentItem))

Thanks for any help.

···

Le lun 05/04/2004 à 19:14, Mike C. Fletcher a écrit :

HTH,
Mike

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

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

--
Everaert Roland <roland_everaert@yahoo.fr>