當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


wxPython wx.StatusBar SetStatusStyles()用法及代碼示例

在本文中,e將學習與wxPython的wx.StatusBar類關聯的SetStatusStyles()函數。 SetStatusStyles()函數設置狀態欄中字段的樣式,這些樣式可使字段顯示為平坦或凸起的,而不是標準的凹陷3D邊框。

它需要一個n個整數數組,每個字段的樣式作為參數。

用法: wx.StatusBar.SetStatusStyles(Self, styles)

參數:

參數 輸入類型 描述
styles 整數列表 包含n個整數的數組,每個字段具有樣式。

有四種可能的樣式:



1. SB_NORMAL(默認):該字段顯示為默認的本機邊框。

2. SB_FLAT:該字段周圍沒有繪製邊框,因此看起來很平坦。

3. SB_RAISED:在場地周圍繪製凸起的3D邊框。

4. SB_SUNKEN:在場周圍繪製了凹陷的3D邊框(此樣式是wxWidgets 2.9.5以後的新樣式)。

代碼示例:

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.statusbar = wx.StatusBar() 
        self.statusbar.Create(self, id = 1, name = "Status Bar") 
        self.SetStatusBar(self.statusbar) 
        self.SetSize((350, 250)) 
  
        # SET TOTAL NUMBER OF FIELDS AND RESPECTIVE WIDTHS 
        self.statusbar.SetFieldsCount(3, [100, 80, 60]) 
  
        # SET TEXT FOR ALL FIELDS 
        self.statusbar.SetStatusText("Field One", 0) 
        self.statusbar.SetStatusText("Field Two", 1) 
        self.statusbar.SetStatusText("Field Three", 2) 
        self.statusbar.SetBackgroundColour((200, 188, 73, 243)) 
  
        # SET STYLES FOR ALL STATUS FIELDS 
        self.statusbar.SetStatusStyles([wx.SB_FLAT, wx.SB_SUNKEN, wx.SB_RAISED]) 
        self.SetTitle('New Frame Title') 
        self.Centre() 
        print(self.statusbar.GetMinHeight()) 
  
  
def main():
    app = wx.App() 
    ex = Example(None) 
    ex.Show() 
    app.MainLoop() 
  
  
if __name__ == '__main__':
    main()

輸出窗口:




相關用法


注:本文由純淨天空篩選整理自RahulSabharwal大神的英文原創作品 wxPython – SetStatusStyles() function in wx.StatusBar。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。