954,546 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Colour blind

Hello every1,

I've been googling about but can't seem to find a solution to the following problem:

print "Hello world"


How does one colourize the "Hello world" in the results. It can be any colour as long as it's not the standard blue. Also I need to know what is the range of the colours availabe in Tkinter and how does one code for the desired result?

Looking forward to your replies:).

fredzik
Junior Poster in Training
55 posts since Feb 2007
Reputation Points: 10
Solved Threads: 5
 

If you use Tkinter there are over a million different colors to pick from.

# select a color from the color dialog and color the root window
# there are also a few named colors Tkinter can use directly:
# "white", "black", "red", "green", "blue", "cyan", "yellow", "magenta"
 
from Tkinter import *
import tkColorChooser
 
root = Tk()
 
colorTuple = tkColorChooser.askcolor()
# contains RBG tuple and hex-value as rrggbb
print colorTuple     # for red = ((255, 0, 0), '#ff0000')
print colorTuple[1]  # #ff0000
 
# Tkinter uses hex_value or element 1 of the tuple
root.configure(bg=colorTuple[1])
 
root.mainloop()


For "Hello World" Tkinter example in color see: http://www.daniweb.com/techtalkforums/post304759-96.html

vegaseat
DaniWeb's Hypocrite
Moderator
5,989 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,417
 

G'day again,

Great work on the Tkinter colour problem this'll definitely help because it has both the colour numbers and the Hex values!:icon_cheesygrin:

Even better work on the "Hello, world!" example! I've got about 100 lines I have to colour in for different clues on a game I'm working on and this is THE way to go. Good one:icon_cheesygrin: :icon_cheesygrin: :icon_cheesygrin:.

How much money do I owe you? (only kidding).

fredzik

fredzik
Junior Poster in Training
55 posts since Feb 2007
Reputation Points: 10
Solved Threads: 5
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You