Skip to content
Related Articles

Related Articles

wxPython – SetMargins() with wx.Size parameters
  • Last Updated : 04 Jun, 2020

In this article we are going to learn about SetMargins() function associated with wx.ToolBar class of wxPython. Similarly with previous article SetMargins() function set the margins for the toolbar. But the only difference is rather taking two different parameters x and y it takes sing wx.Size parameter.


wx.ToolBar.SetMargind(self, size)


ParameterInput TypeDescription
sizewx.SizeMargin Size.

Return Type: wx.ToolBarToolBase

Code Example:

import wx
class Example(wx.Frame):
    def __init__(self, *args, **kwargs):
        super(Example, self).__init__(*args, **kwargs)
    def InitUI(self):
        self.locale = wx.Locale(wx.LANGUAGE_ENGLISH)
        self.toolbar = self.CreateToolBar()
        # set margins with size parameter
        self.toolbar.SetMargins(size =(30, 25))
        td = self.toolbar.AddTool(1, 'right', wx.Bitmap('right.png'))
        # print margins
        self.SetSize((350, 250))
        self.SetTitle('Undo redo')
    def OnQuit(self, e):
def main():
    app = wx.App()
    ex = Example(None)
if __name__ == '__main__':


(30, 25)

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course

My Personal Notes arrow_drop_up
Recommended Articles
Page :