wxGrid with a custom widget. How to?

Hi friends,

Let me explain you my task. Imagine following: there is a grid table with several colums and rows. Each colums have a label, row also have labels, but it should looked somehow different. First, row labels doesn't have a text label nor numerical, just empty label. When I move mouse cursor over this label, the cross sign should appear on a label or something like it. Second, when I click on this label event should be raised, so I can handle its behavior, for example if I click on a row label this row should be deleted. My question is how to acomplish this task? Should I create custom widget based on a wxGrid class or there is any other solution? Maybe somebody acomplish something like that and willing to share? If I must create custom widget can you give me advices on how to make this?

Is my explanation clear? My english is not so good.

Thanks in advance.

Basil Shubin wrote:

Hi friends,

Let me explain you my task. Imagine following: there is a grid table with several colums and rows. Each colums have a label, row also have labels, but it should looked somehow different. First, row labels doesn't have a text label nor numerical, just empty label.

If you are implementing your own table class then it can override the GetRowLabelValue method to control what text is displayed for each label. Otherwise you can just call theGrid.SetRowLabelValue for each row in the grid.

When I move mouse cursor over this label, the cross sign should appear on a label or something like it.

You can get access to the window that is used for the row labels with theGrid.GetGridRowLabelWindow() and you can then call methods of that window (such as SetCursor) as needed.

Second, when I click on this label event should be raised, so I can handle its behavior, for example if I click on a row label this row should be deleted.

The grid sends a EVT_GRID_LABEL_LEFT_CLICK or EVT_GRID_LABEL_RIGHT_CLICK event when the labels are clicked on. You can use methods of the event object passed to the handler to determine which row or col was clicked.

ยทยทยท

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