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


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

在本文中,我們將學習與wxPython的wx.StatusBar類關聯的Create()函數。類似於StatusBar()構造函數,如果需要使用不帶任何參數的StatusBar()構造函數初始化狀態欄變量,則可以使用Create向狀態欄添加屬性。
創建將狀態欄的屬性作為參數。

用法: wx.StatusBar.Create(self, parent, id=ID_ANY, style=STB_DEFAULT_STYLE, name=StatusBarNameStr)

參數:

參數 輸入類型 描述
parent wx.Frame 父框架到atach狀態欄。
id int 用於狀態欄的標識符。
style long 狀態欄的樣式。
name string 名稱與狀態欄相關聯。

代碼示例:

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) 
        # INITIALIZE USING EMPTY CONSTRUCTOR 
        self.statusbar = wx.StatusBar() 
        # CREATE STATUS BAR USING CREATE FUNCTION 
        self.statusbar.Create(self, id = 1, style = wx.STB_DEFAULT_STYLE,  
                                                      name = "Status Bar") 
        self.statusbar.SetStatusText("Hello there this is a Status Bar") 
        self.SetStatusBar(self.statusbar) 
        self.SetSize((350, 250)) 
        self.SetTitle('New Frame Title') 
        self.Centre() 
  
def main():
    app = wx.App() 
    ex = Example(None) 
    ex.Show() 
    app.MainLoop() 
  
  
if __name__ == '__main__':
    main()

輸出窗口:




相關用法


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