📜  wxPython - 在 wxPython 中禁用静态文本

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

wxPython - 在 wxPython 中禁用静态文本

Python提供wxpython 允许我们创建功能强大的图形用户界面。它是Python的跨平台GUI工具包,Phoenix版Phoenix是改进的下一代wxPython,主要关注速度、可维护性和可扩展性。

在本文中,我们将了解如何禁用静态文本。我们可以使用Disable()方法禁用静态文本 wxPythonwx.StaticTex t 类相关联。 Disable()方法只是禁用静态文本,我们无法选择文本。

Disable()函数不接受任何参数。

例子:

Python3
# importing wx library
import wx
 
# create an Example class
class Example(wx.Frame):
    # constructor
    def __init__(self, *args, **kwargs):
        super(Example, self).__init__(*args, **kwargs)
         
        # method calling
        self.InitUI()
 
    # method for user interface creation
    def InitUI(self):
        self.locale = wx.Locale(wx.LANGUAGE_ENGLISH)
 
        # create parent panel for button
        self.pnl = wx.Panel(self)
 
        # create statictext at point (20,20)
        self.st = wx.StaticText(self.pnl,
                                id = 1,
                                label = "Button")
 
        # disable statictext
        self.st.Disable()
 
        self.SetSize((350, 250))
        self.SetTitle('wx.Button')
        self.Centre()
 
# main function
def main():
  # create an App object
  app = wx.App()
   
  # create an Example object
  ex = Example(None)
  ex.Show()
   
  # running an app
  app.MainLoop()
 
# Driver code
if __name__ == '__main__':
  # main function call
  main()


输出: