wxPython – wx.Button 中的 SetAuthNeeded()函数
在本文中,我们将学习与 wxPython 的 wx.Button 类关联的 SetAuthNeeded()函数。 SetAuthNeeded()函数用于设置是否应在按钮上显示需要验证的符号。
它只需要布尔参数,即是否需要。
Syntax: wx.Button.SetAuthNeeded(self, needed=True)
Parameters:
Parameter | Input Type | Description |
---|---|---|
needed | bool | True for needed and False for not needed. |
Return Type: bool
代码示例:
import wx
class Example(wx.Frame):
def __init__(self, *args, **kwargs):
super(Example, self).__init__(*args, **kwargs)
self.InitUI()
def InitUI(self):
self.pnl = wx.Panel(self)
self.btn = wx.Button(self.pnl, label ='Button', pos =(20, 20))
# SET NEEDED AS TRUE
self.btn.SetAuthNeeded(True)
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()
输出窗口: