wxPython wx.ToolBar中的SetTooPacking()函数

wxPython wx.ToolBar中的SetTooPacking()函数

在这篇文章中,我们将学习与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()

输出:

wxPython wx.ToolBar中的SetTooPacking()函数

代码示例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()

输出:

wxPython wx.ToolBar中的SetTooPacking()函数

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程

wxPython 教程