Saturday, November 16, 2024
Google search engine
HomeLanguageswxPython – InsertStretchableSpace() function in wx.ToolBar

wxPython – InsertStretchableSpace() function in wx.ToolBar

In this article we are going to learn about InsertStretchableSpace() function associated with wx.ToolBar class of wxPython. InsertStretchableSpace() inserts a stretchable space at the given position. Note that change will take place after Realize() is called. It takes only pos as parameter.

Syntax:

wx.ToolBar.InsertStretchableSpace(self, pos)

Parameters :

Parameter Input Type Description
pos int Position of tool to be added starting from 0.

Return Type:

wx.ToolBarToolBase
Code Example 1:




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, '', wx.Bitmap('sep.png'))
        te = self.toolbar.AddTool(2, '', wx.Bitmap('wrong.png'))
        tf = self.toolbar.AddTool(3, '', wx.Bitmap('right.png'))
  
        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):
        # insert stretchable space b / w separate 
        # and tick tool at position 1
        self.toolbar.InsertStretchableSpace(pos = 1)
        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 :
before clicking separate tool:

after clicking separate tool:

Code Example 1:




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, '', wx.Bitmap('sep.png'))
        te = self.toolbar.AddTool(2, '', wx.Bitmap('wrong.png'))
        tf = self.toolbar.AddTool(3, '', wx.Bitmap('right.png'))
  
        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):
        # insert stretchable space b / w tick and cross tool at position 2
        self.toolbar.InsertStretchableSpace(pos = 2)
        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 :
before clicking separate tool:

after clicking separate tool:

Last Updated :
01 Jun, 2020
Like Article
Save Article

<!–

–>

Similar Reads
Related Tutorials
Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments