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


wxPython wx.ToolBar SetTooPacking()用法及代码示例


在本文中,我们将学习与d与wxPython的wx.ToolBar类关联的函数SetToolPacking()。 SetToolPacking()函数设置用于间距工具的值。默认值为1。仅将装箱作为参数。

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

参数:

参数 输入类型 描述
packing int 包装的价值。

代码示例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, 'right', wx.Bitmap('right.png')) 
        te = self.toolbar.AddTool(2, 'wrong', wx.Bitmap('wrong.png')) 
  
        # set packing of toolbar to 30 
        self.toolbar.SetToolPacking(packing = 30) 
  
        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):
        # Realize() called to finalize new added tools 
        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()

输出:

代码示例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) 
        self.toolbar = self.CreateToolBar() 
  
        td = self.toolbar.AddTool(1, 'right', wx.Bitmap('right.png')) 
        te = self.toolbar.AddTool(2, 'wrong', wx.Bitmap('wrong.png')) 
  
        # set packing of toolbar to 80 
        self.toolbar.SetToolPacking(packing = 80) 
  
        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):
        # Realize() called to finalize new added tools 
        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()

输出:




相关用法


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