Various colored print lines in python - IDLE

Using IDLE to create a short basic text adventure game, the techniques I try in other editors like Repl.it or canopy, but I prefer using IDLE as I just love its simplicity and that it doesn't require an internet connection to access ...

I will not mention the methods I tried as I may have just approached them completely wrong, or perhaps IDLE simply does not have the functionality of other editors, but I just cannot make the text in-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 are questions like

name_input = input ("What's your name?") .lower () appearing in a different color, or bold / italic. Like things like

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

      

and

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

      

does not work, I suppose this feature is not naturally supported, so I ask if possible either A to make it supportable, so this method or similar work or B, another option that makes changes at least similar to what am i looking for?

It would be very helpful if someone could provide me with a way to do this, or at least an editor that is close in simplicity (design wise) to IDLE and supports the functionality I'm looking for. The python version I am currently using is 3.6.1

Thanks in advance and I apologize if my wording confuses you, just ask what confuses you and I will try to clear things up. Using Windows with a dormant shell.

+3


source to share


1 answer


I know what you are doing right now, but there is no benefit to having text colored or bold in python without a GUI. If you manage to do this, it will revert to normal text when you format the file. I spent a week on this.

It only makes sense when you achieve GUI programming. Tkinter is a good place to start.

It doesn't matter in the IDE, but in the compiler.



In tkinter it's a matter of seconds

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

      

-1


source







All Articles