what is the meanning of triple?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

what is the meanning of triple?

luofeiyu
here is the code:
from Tkinter import *
from tkColorChooser import askcolor
     
def setBgColor():
    (triple, hexstr) = askcolor()
    if hexstr:
        print hexstr
        push.config(bg=hexstr)
     
root = Tk()
push = Button(root, text='Set Background Color', command=setBgColor)
push.config(height=3, font=('times', 20, 'bold'))
push.pack(expand=YES, fill=BOTH)
root.mainloop()

in  the  (triple, hexstr) = askcolor(), i want to know the meaning of triple??

_______________________________________________
Tkinter-discuss mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/tkinter-discuss
Reply | Threaded
Open this post in threaded view
|

Re: what is the meanning of triple?

Michael Lange
Thus spoketh "守株待兔" <[hidden email]>
unto us on Sun, 21 Aug 2011 13:57:21 +0800:

> (triple, hexstr) = askcolor()


.-.. .. ...- .   .-.. --- -. --.   .- -. -..   .--. .-. --- ... .--. . .-.

We Klingons believe as you do -- the sick should die.  Only the strong
should live.
                -- Kras, "Friday's Child", stardate 3497.2
_______________________________________________
Tkinter-discuss mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/tkinter-discuss
Reply | Threaded
Open this post in threaded view
|

Re: what is the meanning of triple?

Michael Lange
Hi,

oops, I accidentally hit the "Send" button :(


> Thus spoketh "守株待兔" <[hidden email]>
> unto us on Sun, 21 Aug 2011 13:57:21 +0800:
>
> > (triple, hexstr) = askcolor()

As you have probably noticed the return value of askcolor() is something
like:

>>> askcolor()
((214, 215, 214), '#d6d7d6')

where the second part is the original color string as returned by
tk_chooseColor , the first part, the 3-tuple, was apparently brought to us
by Frederik Lundh, who wrote the tkColorChooser module. The magic lines
from tkColorChooser.py are:

        # to simplify application code, the color chooser returns
        # an RGB tuple together with the Tk color string
        r, g, b = widget.winfo_rgb(result)
        return (r/256, g/256, b/256), str(result)

so you see, the triple is simply a tuple of (red, green, blue) color
values, ranging from 0 - 255 .

I hope this helps

Michael


.-.. .. ...- .   .-.. --- -. --.   .- -. -..   .--. .-. --- ... .--. . .-.

Only a fool fights in a burning house.
                -- Kank the Klingon, "Day of the Dove", stardate unknown
_______________________________________________
Tkinter-discuss mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/tkinter-discuss
Reply | Threaded
Open this post in threaded view
|

Re: what is the meanning of triple?

Cameron Laird-2
In reply to this post by luofeiyu
On Sun, Aug 21, 2011 at 01:57:21PM +0800, 守株待兔 wrote:
                        .
                        .
                        .

> here is the code:
> from Tkinter import *
> from tkColorChooser import askcolor
>      
> def setBgColor():
>     (triple, hexstr) = askcolor()
>     if hexstr:
>         print hexstr
>         push.config(bg=hexstr)
>      
> root = Tk()
> push = Button(root, text='Set Background Color', command=setBgColor)
> push.config(height=3, font=('times', 20, 'bold'))
> push.pack(expand=YES, fill=BOTH)
> root.mainloop()
>
>  in  the  (triple, hexstr) = askcolor(), i want to know the meaning of triple??
                        .
                        .
                        .
Your question surprises me a bit; it makes me think
that you would benefit from more practice with Python
basics, and that you're "working too hard".

At one level, the answer is, "'triple' is a color
triple, that is, a 3-tuple of integers from the range
0-255."

Here's another way to approach the answer:  launch an
interactive shell, that is, type "python" at the shell
prompt in Linux, MacOS, ..., or click on ActiveState
Python for Windows, or ...  This is an important step.
Your progress in Python (let alone Tkinter) will be
much, MUCH faster once you have comfort and familiarity
with the interactive shell.

At Python's prompt, enter two lines:
  >>> import tkColorChooser
  >>> tkColorChooser.askcolor()
Soon a new window, one with a "color wheel", will pop
up.  Click on a color.  Select "OK".  Back at the Python
prompt, you'll see something like

  ((90, 255, 140), '#5aff8c')

The "(90, 255, 140)" part is triple.

I don't know what you intend by "the meaning of triple",
but what I've written above surely gets you closer to it.
I strongly urge you, again, to practice Python basics.
_______________________________________________
Tkinter-discuss mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/tkinter-discuss
Reply | Threaded
Open this post in threaded view
|

Re: what is the meanning of triple?

Cameron Laird-2
On Sun, Aug 21, 2011 at 07:22:52PM +0000, Cameron Laird wrote:

> .
> .
> .
> > here is the code:
> > from Tkinter import *
> > from tkColorChooser import askcolor
> >      
> > def setBgColor():
> >     (triple, hexstr) = askcolor()
> >     if hexstr:
> >         print hexstr
> >         push.config(bg=hexstr)
> >      
> > root = Tk()
> > push = Button(root, text='Set Background Color', command=setBgColor)
> > push.config(height=3, font=('times', 20, 'bold'))
> > push.pack(expand=YES, fill=BOTH)
> > root.mainloop()
> >
> >  in  the  (triple, hexstr) = askcolor(), i want to know the meaning of triple??
> .
> .
> .
> Your question surprises me a bit; it makes me think
> that you would benefit from more practice with Python
> basics, and that you're "working too hard".
>
> At one level, the answer is, "'triple' is a color
> triple, that is, a 3-tuple of integers from the range
> 0-255."
>
> Here's another way to approach the answer:  launch an
> interactive shell, that is, type "python" at the shell
> prompt in Linux, MacOS, ..., or click on ActiveState
> Python for Windows, or ...  This is an important step.
> Your progress in Python (let alone Tkinter) will be
> much, MUCH faster once you have comfort and familiarity
> with the interactive shell.
>
> At Python's prompt, enter two lines:
>   >>> import tkColorChooser
>   >>> tkColorChooser.askcolor()
> Soon a new window, one with a "color wheel", will pop
> up.  Click on a color.  Select "OK".  Back at the Python
> prompt, you'll see something like
>
>   ((90, 255, 140), '#5aff8c')
>
> The "(90, 255, 140)" part is triple.
>
> I don't know what you intend by "the meaning of triple",
> but what I've written above surely gets you closer to it.
> I strongly urge you, again, to practice Python basics.
                        .
                        .
                        .
It occurs to me that you might not realize how to "reduce" programs,
so that you can write, and run,

   import tkColorChooser
   print tkColorChooser.askcolor()

as a "batch" program, for yourself.  Perhaps you also don't know to
look up <URL:
http://pythonware.com/library/tkinter/introduction/x1164-data-entry.htm#AEN1356 >
or <URL:
http://www.daniweb.com/software-development/python/threads/20774/page6 >
or ...
_______________________________________________
Tkinter-discuss mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/tkinter-discuss
Reply | Threaded
Open this post in threaded view
|

Re: what is the meanning of triple?

Kevin Buchs-2
In reply to this post by luofeiyu
It is the tuple of three integers representing the RGB (red,green,blue) intensities making up the chosen color. 255 is maximum, usually, with 32-bit color. The hexstring is another way to write the same set of three values.

- Kevin

2011/8/21 守株待兔 <[hidden email]>
in  the  (triple, hexstr) = askcolor(), i want to know the meaning of triple?? 

_______________________________________________
Tkinter-discuss mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/tkinter-discuss