Open In App

wxPython – SetToolSeparation() function in wx.ToolBar

Improve
Improve
Like Article
Like
Save
Share
Report

In this article we are going to learn about SetToolSeparation() function associated with the wx.ToolBar class of wxPython.SetToolSeparation() sets the default separator size. The default value is 5. SetToolSeparation() function only takes separation() as parameters.

Syntax:

wx.ToolBar.SetToolSeparation(self, separation)

Parameters:

Parameter Input Type Description
separation int The separator size.

Code Example:




import wx
  
class Example(wx.Frame):
  
    def __init__(self, *args, **kwargs):
        super(Example, self).__init__(*args, **kwargs)
        self.InitUI()
  
    def InitUI(self):
        self.locale = wx.Locale(wx.LANGUAGE_ENGLISH)
        self.toolbar = self.CreateToolBar()
  
        td = self.toolbar.AddTool(1, 'right', wx.Bitmap('right.png'))
        te = self.toolbar.AddTool(2, 'wrong', wx.Bitmap('wrong.png'))
  
        # set separation of toolbar to 20
        self.toolbar.SetToolSeparation(separation = 20)
  
        self.toolbar.Realize()
        self.Bind(wx.EVT_TOOL, self.OnOne, td)
  
        self.SetSize((350, 250))
        self.SetTitle('Undo redo')
        self.Centre()
  
    def OnOne(self, e):
        print(self.toolbar.GetToolSeparation())
        # Realize() called to finalize new added tools
        self.toolbar.Realize()
  
    def OnQuit(self, e):
        self.Close()
  
  
def main():
  
    app = wx.App()
    ex = Example(None)
    ex.Show()
    app.MainLoop()
  
  
if __name__ == '__main__':
    main()


Output:

20


Last Updated : 04 Jun, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads