how to find toolbar item window by name?

Howdy,

I'm having trouble constructing a toolbar that responds to the mouse event, wx.EVT_MOTION.
I need to bind wx.EVT_MOTION to a toolbar button window for drag and drop.

If I use wx.ToolBar.AddTool/AddSimpleTool, I can add a help string, but I don't seem to be
able to label the window, so that I can use wx.FindWindowByName later to do the binding.
I'd prefer not to use ID's if I could because I have dragging artificial ID's around.
I'm using an MVC architecture, so the binding happens in a different place than the toolbar creation.

So rephrased simply, how can I construct a toolbar that responds to mouse events?

TIA,
Danny

Danny Shevitz wrote:

Howdy,

I'm having trouble constructing a toolbar that responds to the mouse event, wx.EVT_MOTION.
I need to bind wx.EVT_MOTION to a toolbar button window for drag and drop.

If I use wx.ToolBar.AddTool/AddSimpleTool, I can add a help string, but I don't seem to be
able to label the window, so that I can use wx.FindWindowByName later to do the binding.

Depending on platform and tool type a toolbar tool may or may not be an actual child widget, so FinWindowByName wouldn't work even if you could give the tools a name.

So rephrased simply, how can I construct a toolbar that responds to mouse events?

Bind your handlers to the toolbar, and then use FindToolForPosition to know which tool the mouse is over.

···

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

thanks, that did it.

In my construction, I use

tool = AddSimpleTool(...)
tool.SetLabel('name')

Then I can later access the text I need from the GetLabel method, even though the tool construction doesn't have
a label parameter.

D

···

At 11:51 AM 2/12/2007 -0800, you wrote:

Danny Shevitz wrote:

Howdy,
I'm having trouble constructing a toolbar that responds to the mouse event, wx.EVT_MOTION.
I need to bind wx.EVT_MOTION to a toolbar button window for drag and drop.
If I use wx.ToolBar.AddTool/AddSimpleTool, I can add a help string, but I don't seem to be
able to label the window, so that I can use wx.FindWindowByName later to do the binding.

Depending on platform and tool type a toolbar tool may or may not be an actual child widget, so FinWindowByName wouldn't work even if you could give the tools a name.

So rephrased simply, how can I construct a toolbar that responds to mouse events?

Bind your handlers to the toolbar, and then use FindToolForPosition to know which tool the mouse is over.

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

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