在本文中,我們將學習與wxPython的wx.Button類關聯的SetBitmapPosition()函數。 SetBitmapPosition()函數用於設置要設置的位圖方向。
方向:
1. 左移
2. 右
3. 底部
3. 頂部
用法: wx.Button.SetBitmapPosition(self, dir)
參數:
參數 | 輸入類型 | 描述 |
---|---|---|
dir | Direction | 位圖應定位的方向,即wx.LEFT,wx.RIGHT,wx.TOP或wx.BOTTOM之一。 |
代碼示例:
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)
# create parent panel for button
self.pnl = wx.Panel(self)
# create bitmap
bmp = wx.Bitmap('pointer.png')
# create button at point (20, 20)
self.st = wx.Button(self.pnl, id = 1, label ="Button", pos =(20, 20),
size =(300, 40), name ="button")
# set bitmap for button
self.st.SetBitmap(bmp)
# change position of bitmap to right
self.st.SetBitmapPosition(wx.RIGHT)
self.SetSize((350, 250))
self.SetTitle('wx.Button')
self.Centre()
def main():
app = wx.App()
ex = Example(None)
ex.Show()
app.MainLoop()
if __name__ == '__main__':
main()
輸出窗口:
相關用法
- wxPython wx.MenuBar SetLabel()用法及代碼示例
- wxPython wx.MenuBar GetHelpString()用法及代碼示例
- wxPython wx.MenuBar SetHelpString()用法及代碼示例
- wxPython wx.MenuBar FindMenuItem()用法及代碼示例
- wxPython wx.MenuBar GetMenuLabelText()用法及代碼示例
- wxPython wx.MenuBar GetMenuLabel()用法及代碼示例
- wxPython wx.MenuBar GetMeuCount()用法及代碼示例
- wxPython wx.MenuBar GetLabel()用法及代碼示例
注:本文由純淨天空篩選整理自RahulSabharwal大神的英文原創作品 wxPython – SetBitmapPosition() function in wx.Button。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。