wxPython - SetToolSeparation() function in wx.ToolBar

wxPython - SetToolSeparation() function in wx.ToolBar

In wx.ToolBar, the method SetToolSeparation() is used to set the separation (in pixels) between tools when they are added to the toolbar. This separation value provides a visual gap between individual tools, making the toolbar more visually appealing and tools easier to distinguish.

Here's a basic example showing how you can use SetToolSeparation() in a wxPython application:

import wx class MyFrame(wx.Frame): def __init__(self, parent, id=wx.ID_ANY, title="", pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE): super(MyFrame, self).__init__(parent, id, title, pos, size, style) # Create a toolbar self.toolbar = self.CreateToolBar() # Set tool separation self.toolbar.SetToolSeparation(20) # Separation of 20 pixels # Add tools to the toolbar tool_id1 = 101 tool_id2 = 102 self.toolbar.AddTool(tool_id1, 'Tool1', wx.NullBitmap, shortHelp='Tool1') self.toolbar.AddTool(tool_id2, 'Tool2', wx.NullBitmap, shortHelp='Tool2') self.toolbar.Realize() app = wx.App(False) frame = MyFrame(None, title="wx.ToolBar SetToolSeparation Example", size=(400, 300)) frame.Show() app.MainLoop() 

In the above code, the separation between tools Tool1 and Tool2 is set to 20 pixels. This will create a 20-pixel gap between the tools in the toolbar. You can adjust this value to your liking.


More Tags

angular-material-6 d3dimage label gitignore nsregularexpression feign oracle10g svm pygal userform

More Programming Guides

Other Guides

More Programming Examples