[Tkinter-discuss] How to use color in the canvas?

chenguang Zhang alix.zhang at gmail.com
Sun Mar 30 15:48:54 CEST 2008


Today I came across a problem when using tkinter for GUI programming.

Question 1.How to use the canvas.item_configure() method, for example, if I
want to change a line's color from red to blue, how to arrange the
parameters?

Question 2.Tkinter has a tkColorChooser and its return value is something
like ((0, 255, 255), '#00ffff'), and I'm wondering how to use it. Normally
the color used in function (like mycanvas.create_line(ax,ay,bx,by,fill=color))
is in words such as 'red' or 'gray', how could I make the program recognize
the numbers?

Question 3. Suppose there are several separate lines in my canvas, all are
created in one single function like 'createThings()'. What should I do so
that when I choose a color from the tkColorChoose, all of them change their
colors, like all change from red to ((0, 255, 255), '#00ffff')?
It seems I can place a color parameter in the function createThings() and
any functions inside it(create_line, create_oval and so on) take this
parameter as the color to fill, but how to change the color parameter then?
How can it be accessed and modified by other function(something like
ChangeColor)?You don't need to answer this step be step, just some tips for
the essentials would be enough.

Any help would be appreciated!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20080330/b1370277/attachment.htm 


More information about the Tkinter-discuss mailing list