wxPython – wx.StatusBar 中的 StatusBar() 构造函数
状态栏:状态栏是一个窄窗口,可以放置在框架底部以提供少量状态信息。
在本文中,我们将学习与 wxPython 的 wx.StatusBar 类关联的 StatusBar() 构造函数。 StatusBar() 构造函数将状态栏的不同属性作为其参数,如样式、名称等。
Syntax: wx.StatusBar.StatusBar(parent, id=ID_ANY, style=STB_DEFAULT_STYLE, name=StatusBarNameStr)
Parameters: Parameter Input Type Description parent wx.Frame Parent Frame to attach statusbar to. id int Identifier to be used for statusbar. style long Style of the status bar. name string Name associated with statusbar.
代码示例:
Python3
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 STATUS BAR USING STATUSBAR CONSTRUCTOR
self.statusbar = wx.StatusBar(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()
输出: