Opened 12 years ago

Closed 12 years ago

#11628 closed enhancement (duplicate)

Enumerate Toolbar Tools

Reported by: jaraco Owned by:
Priority: low Milestone:
Component: base Version:
Keywords: Cc:
Blocked By: Blocking:
Patch: no


It appears that given a wx.Toolbar, there is no straightforward way to enumerate all of the tools in that toolbar unless the IDs are known.

Here is a simple example that will get the tools for a toolbar by iterating over the buttons by width.

def getToolsForToolbar(tb):
	tool_size = tb.GetToolSize()
	width, height = tool_size
	pos = 0
	while True:
		tool = tb.FindToolForPosition(pos, 0)
		if tool: yield tool
		else: break
		pos += width

This example fails in several cases:

  • spacers are present
  • tools are irregularly sized (may not be possible)
  • the toolbar has multiple rows
  • the toolbar isVertical

Ideally, wxPython would have a function to get all tool IDs for a toolbar (or otherwise iterate over the tools).

Change History (1)

comment:1 Changed 12 years ago by vadz

  • Resolution set to duplicate
  • Status changed from new to closed

AFAICS this is the same as #11120.

Note: See TracTickets for help on using tickets.