在本文中,我們將學習wxPython中類wx.ToolBar的GetMargins()函數。 GetMargins()函數返回左/右和上/下邊距,這些邊距也用於inter-toolspacing。 GetMargins不帶參數。
用法:
wx.ToolBar.GetMargins(self)
參數:
No Parameters required in GetMargins()
Return Type:
wx.Size
代碼示例:
import wx
class Example(wx.Frame):
global count
count = 0;
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.AddTool(13, 'twoTool', wx.Bitmap('wrong.png'), shortHelp ="Simple Tool2")
stool = self.toolbar.AddTool(14, 'twoTool', wx.Bitmap('wrong.png'), shortHelp ="Simple Tool")
self.toolbar.Realize()
self.SetSize((350, 250))
self.SetTitle('Control')
self.Centre()
# print x and y margin of toolbar
print(self.toolbar.GetMargins())
def main():
app = wx.App()
ex = Example(None)
ex.Show()
app.MainLoop()
if __name__ == '__main__':
main()
輸出:
(0, 0)
代碼示例:
import wx
class Example(wx.Frame):
global count
count = 0;
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.SetMargins(10, 10)
# Add Tools Using AddTool function
rtool = self.toolbar.AddTool(13, 'twoTool', wx.Bitmap('wrong.png'), shortHelp ="Simple Tool2")
stool = self.toolbar.AddTool(14, 'twoTool', wx.Bitmap('wrong.png'), shortHelp ="Simple Tool")
self.toolbar.Realize()
self.SetSize((350, 250))
self.SetTitle('Control')
self.Centre()
# print x and y margin of toolbar
print(self.toolbar.GetMargins())
def main():
app = wx.App()
ex = Example(None)
ex.Show()
app.MainLoop()
if __name__ == '__main__':
main()
輸出:
(10, 10)
相關用法
- wxPython FindToolForPosition()用法及代碼示例
- wxPython FindControl()用法及代碼示例
- wxPython GetClassDefaultAttributes()用法及代碼示例
- wxPython GetToolBitmapSize()用法及代碼示例
- wxPython GetToolByPos()用法及代碼示例
注:本文由純淨天空篩選整理自RahulSabharwal大神的英文原創作品 wxPython | GetMargins() function in python。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。