📜  wxPython - 为单选按钮设置工具提示

📅  最后修改于: 2022-05-13 01:55:26.019000             🧑  作者: Mango

wxPython - 为单选按钮设置工具提示

在本文中,我们将了解这一点,我们如何将工具提示添加到单选按钮。我们将使用与 wx.RadioButton 关联的 SetToolTip()函数。
SetToolTip()函数将用作工具提示的字符串作为参数。

代码示例:

Python3
import wx
 
APP_EXIT = 1
 
 
class Example(wx.Frame):
 
    def __init__(self, *args, **kwargs):
        super(Example, self).__init__(*args, **kwargs)
 
        self.InitUI()
 
    def InitUI(self):
 
        # parent panel for radio buttons
        self.pnl = wx.Panel(self)
 
        # create radio buttons
        self.rb1 = wx.RadioButton(self.pnl, label ='Btn1', pos =(30, 10), size =(100, 20))
        self.rb2 = wx.RadioButton(self.pnl, label ='Btn2', pos =(30, 30), size =(100, 20))
        self.rb3 = wx.RadioButton(self.pnl, label ='Btn3', pos =(30, 50), size =(100, 20))
 
        # set tooltip for radio button
        self.rb1.SetToolTip("Radio Button")
 
 
 
def main():
    app = wx.App()
    ex = Example(None)
    ex.Show()
    app.MainLoop()
 
 
if __name__ == '__main__':
    main()


输出窗口: