wxPython wx.Button中的GetAuthNeeded()函数
在这篇文章中,我们将学习与wxPython的wx.Button类有关的GetAuthNeeded()函数。GetAuthNeeded()函数用于在按钮上显示需要认证的符号时返回True。
它不需要参数。
语法:wx.Button.GetAuthNeeded(self)
参数。GetAuthNeeded()函数不需要参数。
返回类型: 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))
self.btn.SetAuthNeeded(True)
# PRINT IF AUTHENTICATION IS NEEDED OR NOT USING GetAuthNeeded()
if(self.btn.GetAuthNeeded()== True):
print("Authentication is needed.")
else:
print("No Authentication is needed.")
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()
控制台输出。
Authentication is needed.
输出窗口: