wxPython – wx.ToolBar 中的 SetToolBitmapSize()函数
在本文中,我们将学习与 wxPythpon 的 wx.ToolBar 类关联的 SetToolBitMapSize()函数。设置每个工具位图的默认大小。默认位图大小为 16 x 15 像素。它只接受大小作为参数。
Syntax:
Parameters:
Parameter | Input Type | Description |
---|---|---|
size | wx.Size | The size of the bitmaps in the toolbar.. |
代码示例 1:
wx.ToolBar.SetToolBitmapSize(self, size)
输出:
点击之前:
点击后:
代码示例 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('user.png'))
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):
# set bitmap size in toolbar
self.toolbar.SetToolBitmapSize(size =(32, 32))
# 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()
输出:
点击之前:
点击后: