当前位置: 首页>>代码示例>>用法及示例精选>>正文


wxPython GetMargins()用法及代码示例

在本文中,我们将学习wxPython中类wx.ToolBar的GetMargins()函数。 GetMargins()函数返回左/右和上/下边距,这些边距也用于inter-toolspacing。 GetMargins不带参数。

用法:
wx.ToolBar.GetMargins(self)

参数:

No Parameters required in GetMargins()

Return Type:

wx.Size

代码示例:



import wx 
  
  
class Example(wx.Frame):
    global count 
    count = 0; 
  
    def __init__(self, *args, **kwargs):
        super(Example, self).__init__(*args, **kwargs) 
  
        self.InitUI() 
  
    def InitUI(self):
        self.locale = wx.Locale(wx.LANGUAGE_ENGLISH) 
        pnl = wx.Panel(self) 
        self.toolbar = self.CreateToolBar() 
        # Add Tools Using AddTool function 
        rtool = self.toolbar.AddTool(13, 'twoTool', wx.Bitmap('wrong.png'), shortHelp ="Simple Tool2") 
        stool = self.toolbar.AddTool(14, 'twoTool', wx.Bitmap('wrong.png'), shortHelp ="Simple Tool") 
  
        self.toolbar.Realize() 
        self.SetSize((350, 250)) 
        self.SetTitle('Control') 
        self.Centre() 
  
        # print x and y margin of toolbar 
        print(self.toolbar.GetMargins()) 
  
def main():
    app = wx.App() 
    ex = Example(None) 
    ex.Show() 
    app.MainLoop() 
  
  
if __name__ == '__main__':
    main()

输出:

(0, 0)

代码示例:

import wx 
  
  
class Example(wx.Frame):
    global count 
    count = 0; 
  
    def __init__(self, *args, **kwargs):
        super(Example, self).__init__(*args, **kwargs) 
  
        self.InitUI() 
  
    def InitUI(self):
        self.locale = wx.Locale(wx.LANGUAGE_ENGLISH) 
        pnl = wx.Panel(self) 
        self.toolbar = self.CreateToolBar() 
        self.toolbar.SetMargins(10, 10) 
        # Add Tools Using AddTool function 
        rtool = self.toolbar.AddTool(13, 'twoTool', wx.Bitmap('wrong.png'), shortHelp ="Simple Tool2") 
        stool = self.toolbar.AddTool(14, 'twoTool', wx.Bitmap('wrong.png'), shortHelp ="Simple Tool") 
  
        self.toolbar.Realize() 
        self.SetSize((350, 250)) 
        self.SetTitle('Control') 
        self.Centre() 
  
        # print x and y margin of toolbar 
        print(self.toolbar.GetMargins()) 
  
def main():
    app = wx.App() 
    ex = Example(None) 
    ex.Show() 
    app.MainLoop() 
  
  
if __name__ == '__main__':
    main()

输出:

(10, 10)




相关用法

注:本文由纯净天空筛选整理自RahulSabharwal大神的英文原创作品 wxPython | GetMargins() function in python。非经特殊声明,原始代码版权归原作者所有,本译文的传播和使用请遵循“署名-相同方式共享 4.0 国际 (CC BY-SA 4.0)”协议。