在本文中,我們將學習與wxPython的wx.ToolBar類關聯的SetMargins()函數。 SetMargins()函數設置用作工具欄邊距的值。它使用兩個整數x和y作為左右邊界的參數。
用法:
wx.ToolBar.SetMargins(self, x, y)
參數:
參數 | 輸入類型 | 描述 |
---|---|---|
x | int | 左邊界,右邊界和inter-tool分隔值。 |
y | int | 上邊距,下邊距和inter-tool分隔值。 |
返回類型:
wx.ToolBarToolBase
代碼示例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()
self.toolbar.SetMargins(20, 10)
td = self.toolbar.AddTool(1, 'right', wx.Bitmap('right.png'))
self.toolbar.Realize()
print(self.toolbar.GetMargins())
self.SetSize((350, 250))
self.SetTitle('Undo redo')
self.Centre()
def OnQuit(self, e):
self.Close()
def main():
app = wx.App()
ex = Example(None)
ex.Show()
app.MainLoop()
if __name__ == '__main__':
main()
輸出:
(20, 10)
相關用法
- wxPython wx.StaticText GetLabel()用法及代碼示例
- wxPython wx.StaticText SetForegroundColour()用法及代碼示例
- wxPython wx.StaticText IsEllipsized()用法及代碼示例
- wxPython wx.ToolBar GetToolState()用法及代碼示例
- wxPython GetToolBitmapSize()用法及代碼示例
- wxPython wx.StaticText SetBackgroundColour()用法及代碼示例
- wxPython GetToolPos()用法及代碼示例
- wxPython FindToolForPosition()用法及代碼示例
- wxPython GetClassDefaultAttributes()用法及代碼示例
注:本文由純淨天空篩選整理自RahulSabharwal大神的英文原創作品 wxPython – SetMargins() function in wx.ToolBar。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。