Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6669147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:07:00+00:00 2026-05-26T03:07:00+00:00

I have a multiline wx.TextCtrl() object which I set it’s forground and Background colors

  • 0

I have a multiline

wx.TextCtrl()

object which I set it’s forground and Background colors for writing strings.I need to write different lines with different colors ,

wx.TextCtrl.setForgroundcolor()

changes all previous lines colors as well.Is there a way around this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T03:07:00+00:00Added an answer on May 26, 2026 at 3:07 am

    There are several methods in wx.Python to get colored text.

    • wx.TextCtrl with wx.TE_RICH, wx.TE_RICH2 styles
    • wx.stc.StyledTextCtrl
    • wx.richtext.RichTextCtrl
    • wx.HtmlWindow (inserting color tags in your text)
    • wx.ListCrtl

    You can get examples of all of them in the wxPython demo

    For example, you can change fore and background colors in any part of a wx.TextCrtl:

    rt = wx.TextCtrl(self, -1,"My Text....",size=(200, 100),style=wx.TE_MULTILINE|wx.TE_RICH2)
    rt.SetInsertionPoint(0)
    rt.SetStyle(2, 5, wx.TextAttr("red", "blue"))
    

    wx.richtext is also easy to use to write lines with different colors:

    rtc = wx.richtext.RichTextCtrl(self, style=wx.VSCROLL|wx.HSCROLL|wx.NO_BORDER)
    rtc.BeginTextColour((255, 0, 0))
    rtc.WriteText("this color is red")
    rtc.EndTextColour()
    rtc.Newline()
    

    As indicated in other answer the use of a wx.ListCrtl can be a very straighforward method if you work with lines of text (instead of multiline text).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a multiline string which is delimited by a set of different delimiters:
I have a wxpython app designed using XRC which has a multiline textctrl inside
Is there a way to have multiline strings in VB.NET like Python a =
I have a multiline textbox that by default, is set to ReadOnly. I would
I have TextBox (multiline) and Label in an UpdatePanel which I refresh with javascript
Hai Guys, I have a multiline textbox and I have set MaxLength=160 ,also i
Does Go have anything similar to Python's multiline strings: line 1 line 2 line
I have a multiline textbox in which i will be entering many email addresses.
I have a multiline textbox which shouldn't accept alphabets, numbers, newline(enter key) and backspace.
I have a multiline TextBox for which any of the following inputs are valid:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.