In this article we are going to learn about GetMarginWidth() function associated with the wx.MenuItem class of wxPython. Gets the width of the menu item checkmark bitmap. GetMarginWidth() function takes no parameters.
Syntax:
wx.MenuItem.GetMarginWidth(self)Parameters:
No parameters are required in GetMarginWidth().Return Type:
int
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 .menubar = wx.MenuBar() self .fileMenu = wx.Menu() self .item = wx.MenuItem( self .fileMenu, 1 , '&Check\tCtrl + c' , helpString = "Check Help" ) self .fileMenu.Append( self .item) self .menubar.Append( self .fileMenu, '&File' ) self .SetMenuBar( self .menubar) # print margin width margin = self .item.GetMarginWidth() print (margin) self .SetSize(( 350 , 250 )) self .SetTitle( 'Icons and shortcuts' ) self .Centre() def main(): app = wx.App() ex = Example( None ) ex.Show() app.MainLoop() if __name__ = = '__main__' : main() |
Output:
default margin width
3
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 .menubar = wx.MenuBar() self .fileMenu = wx.Menu() self .item = wx.MenuItem( self .fileMenu, 1 , '&Check\tCtrl + c' , helpString = "Check Help" ) self .item.SetMarginWidth( 12 ) self .fileMenu.Append( self .item) self .menubar.Append( self .fileMenu, '&File' ) self .SetMenuBar( self .menubar) # print margin width margin = self .item.GetMarginWidth() print (margin) self .SetSize(( 350 , 250 )) self .SetTitle( 'Icons and shortcuts' ) self .Centre() def main(): app = wx.App() ex = Example( None ) ex.Show() app.MainLoop() if __name__ = = '__main__' : main() |
Output:
12