【问题标题】:Change the colour of a StaticText, wxPython改变静态文本的颜色,wxPython
【发布时间】:2010-12-19 14:31:06
【问题描述】:

我需要将StaticText设为红色,我应该使用什么?

【问题讨论】:

    标签: wxpython static-text


    【解决方案1】:

    这里是

    import wx
    
    app=wx.PySimpleApp()
    frame=wx.Frame(None)
    text=wx.StaticText(frame, label="Colored text")
    text.SetForegroundColour((255,0,0)) # set text color
    text.SetBackgroundColour((0,0,255)) # set text back color
    frame.Show(True)
    app.MainLoop()
    

    【讨论】:

      【解决方案2】:

      根据您需要设置的颜色,查看SetForegroundColour()SetBackgroundColour() 方法。

      【讨论】:

        【解决方案3】:

        这应该可行:

        text.SetForegroundColour(wx.Colour(255,255,255))
        

        如果您在面板或框架的类中使用它,那么:

        self.text.SetForegroundColour(wx.Colour(255,255,255))
        

        wx.Colour 采用可用于不同颜色的 RGB 值。

        【讨论】:

          猜你喜欢
          • 2019-04-06
          • 2012-10-07
          • 1970-01-01
          • 2021-02-18
          • 2012-06-07
          • 2019-09-10
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多