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


wxPython GetToolPacking()用法及代码示例


在本文中,我们将学习与wxPython的wx.ToolBar类关联的GetToolPacking()函数。 GetToolPacking()函数仅返回用于打包工具的值。如果工具栏是水平的,则打包用于垂直方向的间距;如果工具栏是垂直的,则打包用于水平方向的间距。它不占用任何参数。

用法:
wx.ToolBar.GetToolPacking(self, packing)

参数:

GetToolPacking() function takes no parameters.

Return Type:

int

代码示例:



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) 
        pnl = wx.Panel(self) 
        self.toolbar = self.CreateToolBar() 
        # Add Tools Using AddTool function 
        rtool = self.toolbar.AddLabelTool(id = 13, label = "Tool one", bitmap = wx.Bitmap('right.png'), shortHelp ="short help 1", longHelp = "Long help associated with simple tool 1") 
        stool = self.toolbar.AddLabelTool(id = 14, label = "Tool two", bitmap = wx.Bitmap('wrong.png'), shortHelp ="short help 2", longHelp = "Long help associated with simple tool 2") 
  
        self.toolbar.Realize() 
        self.SetSize((350, 250)) 
        self.SetTitle('Control') 
        self.Centre() 
        bl = self.toolbar.GetToolPacking() 
  
        # print tools packing value 
        print(bl) 
  
  
def main():
    app = wx.App() 
    ex = Example(None) 
    ex.Show() 
    app.MainLoop() 
  
  
if __name__ == '__main__':
    main()

输出:

7

代码示例2:

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) 
        pnl = wx.Panel(self) 
        self.toolbar = self.CreateToolBar() 
        self.toolbar.SetToolPacking(12) 
        # Add Tools Using AddTool function 
        rtool = self.toolbar.AddLabelTool(id = 13, label = "Tool one", bitmap = wx.Bitmap('right.png'), shortHelp ="short help 1", longHelp = "Long help associated with simple tool 1") 
        stool = self.toolbar.AddLabelTool(id = 14, label = "Tool two", bitmap = wx.Bitmap('wrong.png'), shortHelp ="short help 2", longHelp = "Long help associated with simple tool 2") 
  
        self.toolbar.Realize() 
        self.SetSize((350, 250)) 
        self.SetTitle('Control') 
        self.Centre() 
        bl = self.toolbar.GetToolPacking() 
  
        # print tools packing value 
        print(bl) 
  
  
def main():
    app = wx.App() 
    ex = Example(None) 
    ex.Show() 
    app.MainLoop() 
  
  
if __name__ == '__main__':
    main()

输出:

12




相关用法


注:本文由纯净天空筛选整理自RahulSabharwal大神的英文原创作品 wxPython | GetToolPacking() function in python。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。