Twisted Fate
Twisted Fate

Reputation: 145

Different coloured print strings in python - IDLE

I'm using IDLE to just create a short, basic text adventure game. the methods I try work in other editors such as Repl.it or canopy, but I prefer the use of IDLE as I just like the simplicity of it, and that it doesn't require an Internet connection to access.

I won't mention the methods I tried, as I may have just been approaching them in the entirely wrong way, or maybe IDLE just simply doesn't have the functionality of other editors, but I just want to make the text in the game clearer to distinguish. For example, below is a short segment:

import time

print ("Welcome Traveller!") 
time.sleep(1)
def name_identify():
    print () 
    name_input = input ("What is your name? ").lower() 
    name_input = name_input.title() 
    time.sleep(0.75)
    def name_confirm(): 
        print ()
        print ("So %s is your name then?" % name_input)

Where the questions such as

name_input = input ("What is your name? ").lower()

appear in a different colour, or bold/italic even. As things similar to

print ("\x1B[3mHello World\x1B[23m")

and

print ("\033[1;31m""Hello world") 

don't work, I assume this function is not naturally supported, so I ask, if it is possible to either A, make it supported, so this method, or similar work, or B, another option which does make changes at least similar to what I seek?

It would be very helpful if anyone could provide me with a way to do this, or at the very least an editor which is close in simplicity (design wise) to IDLE and does support the functions I seek. The version of python I am currently using is 3.6.1.

Thanks in advance, and I apologise if my wording confuses you, just ask about what confused you and I will attempt to clarify. Using Windows with the Idle Shell.

Due to the limitations of some python environments, I just used Tkinter to create an interactive procedurally generated script which you can scroll along as if it were the shell, with the added bonus of adding pictures for more depth.

Upvotes: 4

Views: 2252

Answers (1)

Burhan Asif
Burhan Asif

Reputation: 238

I know what you are going through right now, but there is no benefit to make text colored or bold in python without GUI. If somehow you manage to do it it will turn back to normal text when you make the file to exe format. I have wasted a week on this.

It only makes sense when you are reach GUI programming. Tkinter would be a good place to start.

Its does not matter on the IDE but on the compiler.

In tkinter its a matter of seconds

  lab_practice = label(text = "practice",fg = "red#the foreground color",bg = "yellow",font = ("Arial",40))

Upvotes: 2

Related Questions