Bug: No way to delete a Control in wx.Toolbar?

Hi Edward,

Edward K. Ream wrote:

There appears to be a hole in the API for wx.Toolbar. I can see no way to
delete a control added with AddControl. Is this possible? It there isn't,
Leo will have to roll its own version of wx.Toolbar.

What about:
wxToolBar::RemoveTool
wxToolBarTool * RemoveTool(int id)
Removes the given tool from the toolbar but doesn't delete it. This allows to insert/add this tool back to this (or another) toolbar later.
Note that it is unnecessary to call Realize for the change to take place, it will happen immediately.

Werner

P.S. Have you looked at some of the newer widgets, e.g. maybe AUI instead of splitter?

You pass an ID to the toolbar when you add the control to it, thats
the ID you want.

···

On 12/15/06, Edward K. Ream <edreamleo@charter.net> wrote:

> What about: wxToolBar::RemoveTool

How, exactly, are you to specify the 'tool' to be removed? That's the hole.
AddControl doesn't return an id, and trying to use the Control's id crashes.

cbID = wx.NewId()
self.theControl = wx.ComboBox(self.tb, cbID,...)

...

def OnRemoveButton(self, event): self.tb.RemoveTool(self.theControl.GetId())

Hurray! Mystery solved. Thanks so much for your help.

Edward

···

--------------------------------------------------------------------
Edward K. Ream email: edreamleo@charter.net
Leo: http://webpages.charter.net/edreamleo/front.html
--------------------------------------------------------------------

def OnRemoveButton(self, event): self.tb.RemoveTool(self.theControl.GetId())

Is there no way to Remove a tool by passing a reference to the tool, rather than an ID? as some of you may know, I'm on a quest to abolish explicit IDs....

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Christopher Barker wrote:

def OnRemoveButton(self, event): self.tb.RemoveTool(self.theControl.GetId())

Is there no way to Remove a tool by passing a reference to the tool, rather than an ID? as some of you may know, I'm on a quest to abolish explicit IDs....

Not yet, but it's easy to add in a function that calls the existing one with tool.GetId()

···

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