Make sure you give the tool item a unique tool id.
Note: it can be any positive number (negative numbers would make the id be random). I think 100 looks like a good id if this tool item is the left-most (i.e. the first one) on your toolbar. But if it’s the second, give the number 200… That way your code will be more readable and you’ll immediately know which tool item are you dealing with. It’s all about being organized.
toolbar.FindById(id=100).SetLabel(‘foobar’)
toolbar.Realize()
And when you want to find the tool item by its id, give the parameter id the same number that you gave to the parameter toolId of the AddTool() method.
An alternative would be to keep a reference, e.g.:
self.tb_someitem = self.toolbar.AddSimpleTool(wx.ID_ANY,
wx.Image(‘user.png’, wx.BITMAP_TYPE_PNG).ConvertToBitmap(),
‘New’, ‘Create New Document’)
self.tb_someitem.SetLabel(‘some new label’)
Werner
···
On 10/09/2012 11:20, Boštjan Mejak
wrote:
toolbar.AddTool(toolId=100,
…)
Make
sure you give the tool item a unique tool id.
Note:
it can be any positive number (negative numbers would make the
id be random). I think 100 looks like a good id if this tool
item is the left-most (i.e. the first one) on your toolbar.
But if it’s the second, give the number 200… That way your
code will be more readable and you’ll immediately know which
tool item are you dealing with. It’s all about being
organized.
toolbar.FindById(id=100).SetLabel(‘foobar’)
toolbar.Realize()
And when you
want to find the tool item by its id, give the parameter id
the same number that you gave to the parameter toolId of the
AddTool() method.
Thank you guys! I’ve tried both methods, but they still didn’t work. I guess it’s a linux version problem, because everything’s fine on my windows machine.
Anyway, thanks for help!
···
On Monday, September 10, 2012 4:44:12 AM UTC-5, werner wrote:
On 10/09/2012 11:20, Boštjan Mejak > wrote:
toolbar.AddTool(toolId=100,
…)
Make
sure you give the tool item a unique tool id.
Note:
it can be any positive number (negative numbers would make the
id be random). I think 100 looks like a good id if this tool
item is the left-most (i.e. the first one) on your toolbar.
But if it’s the second, give the number 200… That way your
code will be more readable and you’ll immediately know which
tool item are you dealing with. It’s all about being
organized.
toolbar.FindById(id=100).SetLabel(‘foobar’)
toolbar.Realize()
And when you
want to find the tool item by its id, give the parameter id
the same number that you gave to the parameter toolId of the
AddTool() method.
An alternative would be to keep a reference, e.g.: