Text and browse button controls in single grid cell - how?

Hi,

I would like to create a grid into which the user enters path locations (as part of a configuration form). Ideally, there will be a text Box and a Browse button in each cell. Tantalisingly, http://wiki.wxpython.org/wxPyGridCellEditor mentions the following:

    Show needs to be overwritten if you wish to display more than than
    one control. For example, with a text control and a button:

            def Show(self, show, attr):
                    self.textBox.Show(show)
                    self.browseButton.Show(show)

... but there is no example code for SetControl (inside Create) using more than one control.

For reference, I have found plenty of documentation on ways of building custom cell editors:

http://wiki.wxpython.org/CreatingCustomControls
http://wiki.wxpython.org/wxPyGridCellEditor
http://wiki.wxpython.org/wxGridCellChoiceEditor
http://wiki.wxpython.org/wxGridCellChoiceEditor2
and, of course, Chapter 14 of wxPython in Action, which is getting very well thumbed :wink:

See also:
http://archives.devshed.com/forums/python-122/grid-containing-radios-2112839.html

... but nothing addressing my particular issue. Is what I suggest possible? Or do I need to have the button in its own column, controlling the action in its leftward column? Or does it involve making a single, composite, control?

All the best, Grant

Grant Paton-Simpson wrote:

Hi,

I would like to create a grid into which the user enters path locations (as part of a configuration form). Ideally, there will be a text Box and a Browse button in each cell. Tantalisingly, wxPyGridCellEditor - wxPyWiki mentions the following:

   Show needs to be overwritten if you wish to display more than than
   one control. For example, with a text control and a button:

           def Show(self, show, attr):
                   self.textBox.Show(show)
                   self.browseButton.Show(show)

... but nothing addressing my particular issue. Is what I suggest possible? Or do I need to have the button in its own column, controlling the action in its leftward column? Or does it involve making a single, composite, control?

The grid cell editors only know how to deal with a single widget so while you can probably do it by totally managing the 2nd one yourself, you'll probably be better off to make a composite control.

···

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