I have a working toolbar but I'm not sure if it's technically correct; I like to do things correctly. I have attached a short section of code.
Also, I note that some GUI options are only available through Microsoft's Windows; I'm a Linux user. I wanted to add ticks to a slider but that seems to be not available to Linux users. However, EVT_SCROLL_CHANGED is listed as only being available in Windows but I found that it works under Linux.
I have experimented with wx.BoxSizer but didn't get very far. Is this the preferred method to add controls to a toolbar?
I have a working toolbar but I’m not sure if it’s technically correct; I
like to do things correctly. I have attached a short section of code.
Normally AddTool would be used to add toobar buttons, including radio or toggle items. That will ensure that they will be native and look and feel just like toolbars in other applications on the platform. AddControl can be used when you want to have non-button things on the bar, but should be used sparingly.
Also, I note that some GUI options are only available through
Microsoft’s Windows; I’m a Linux user. I wanted to add ticks to a slider
but that seems to be not available to Linux users. However,
EVT_SCROLL_CHANGED is listed as only being available in Windows but I
found that it works under Linux.
I have experimented with wx.BoxSizer but didn’t get very far. Is this
the preferred method to add controls to a toolbar?
Toolbars already manage the layout of the tool items and controls, so there is no need to use a sizer with them. In addition, if you use the frame’s SetToolBar method then the frame will manage the layout of the toolbar itself, so no need to put it in a sizer either.
···
On Monday, June 3, 2019 at 10:48:31 PM UTC-7, Phil wrote:
I have found that AddTool and AddControl aren't interchangeable, AddTool seems to require that the tool be an int type.
I'm afraid that I need some hand-holding, the following doesn't satisfy the requirements:;
self.tbutton = wx.ToggleButton(tb, -1, "Stop")
tb.AddTool(self.tbutton)
···
On 6/6/19 12:15 pm, Robin Dunn wrote:
Normally AddTool would be used to add toobar buttons, including radio or toggle items. That will ensure that they will be native and look and feel just like toolbars in other applications on the platform. AddControl can be used when you want to have non-button things on the bar, but should be used sparingly.
The integer is just an ID to associate with the tool for accessing it later, etc. Just like menu items you can just pass wx.ID_ANY to let wx generate one for you, and then use the returned item for later access to the item. For example:
On Wednesday, June 5, 2019 at 7:38:18 PM UTC-7, Phil wrote:
On 6/6/19 12:15 pm, Robin Dunn wrote:
Normally AddTool would be used to add toobar buttons, including radio
or toggle items. That will ensure that they will be native and look
and feel just like toolbars in other applications on the platform.
AddControl can be used when you want to have non-button things on the
bar, but should be used sparingly.
Thank you for your reply Robin,
I have found that AddTool and AddControl aren’t interchangeable, AddTool
seems to require that the tool be an int type.
I’m afraid that I need some hand-holding, the following doesn’t satisfy
the requirements:;
Thank you Robin for your explanation and the example.
···
On 7/6/19 1:28 am, Robin Dunn wrote:
The integer is just an ID to associate with the tool for accessing it later, etc. Just like menu items you can just pass wx.ID_ANY to let wx generate one for you, and then use the returned item for later access to the item. For example:
tool = tb.AddTool(wx_ID_ANY, "Checkable", images.Tog1.GetBitmap(),
shortHelp="Toggle this", kind=wx.ITEM_CHECK)
self.Bind(wx.EVT_TOOL, self.OnToggleToolClick, tool)
The integer is just an ID to associate with the tool for accessing it later, etc. Just like menu items you can just pass wx.ID_ANY to let wx generate one for you, and then use the returned item for later access to the item. For example:
tool = tb.AddTool(wx_ID_ANY, "Checkable", images.Tog1.GetBitmap(),shortHelp="Toggle this", kind=wx.ITEM_CHECK)
One last question on this subject, how do I check if the toggle button is pressed or not? I have tried GetValue() but that doesn't seem to be the correct method in this instance and event.IsChecked. IsChecked lets me know that the button is pressed but there doesn't seem to be anything like IsNotChecked.
One last question on this subject, how do I check if the toggle button
is pressed or not? I have tried GetValue() but that doesn’t seem to be
the correct method in this instance and event.IsChecked. IsChecked lets
me know that the button is pressed but there doesn’t seem to be anything
like IsNotChecked.