Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use RGB color with Tk

Status
Not open for further replies.

NateBro

Programmer
Sep 1, 2004
233
US
I have a canvas with squares, but i need to use RGB colors, but i'm not sure exactly how, i looked at google, but didn't find anything with the standerd distribution of PERL.

thanks for your time!
~Nate_Bro
 
Hi

A good perl example that I found a long time ago in the web. It might be helpful

Code:
[gray]#!/usr/bin/perl[/gray]
[gray][i]# Easter_Egg v:0.2[/i][/gray]
[gray][i]# A color hexadecimal editor for Perl/Tk[/i][/gray]
[gray][i]# Copyright (c) 2002 Didier Ladner <didier@perltk.org>.[/i][/gray]
[gray][i]# This program is free software.  You may distribute or modify it[/i][/gray]
[gray][i]# under the terms of the Artistic license that is distributed with the[/i][/gray]
[gray][i]# Perl Kit.[/i][/gray]

[url=http://perldoc.perl.org/functions/use.html][black][b]use[/b][/black][/url] [green]Tk[/green][red];[/red]
[black][b]use[/b][/black] [green]Tk::Frame[/green][red];[/red]
[black][b]use[/b][/black] [green]Tk::Label[/green][red];[/red]
[black][b]use[/b][/black] [green]Tk::Entry[/green][red];[/red]
[black][b]use[/b][/black] [green]Tk::Scale[/green][red];[/red]
[black][b]use[/b][/black] [green]Tk::Photo[/green][red];[/red]

[blue]$egg[/blue] = [maroon]&im[/maroon][red]([/red][fuchsia]1[/fuchsia][red])[/red][red];[/red]

[blue]$mw[/blue] = MainWindow -> [maroon]new[/maroon][red];[/red]
[blue]$mw[/blue] -> [maroon]wm[/maroon][red]([/red][red]'[/red][purple]geometry[/purple][red]'[/red], [red]'[/red][purple]402x301+100+90[/purple][red]'[/red][red])[/red][red];[/red]
[blue]$mw[/blue] -> [maroon]title[/maroon][red]([/red][red]'[/red][purple] Hexadecimal Easter Egg[/purple][red]'[/red][red])[/red][red];[/red]
[blue]$icon[/blue] = [blue]$mw[/blue]->[maroon]Photo[/maroon][red]([/red][red]'[/red][purple]image[/purple][red]'[/red], -[purple]data[/purple]=>[blue]$egg[/blue], [url=http://perldoc.perl.org/functions/format.html][black][b]format[/b][/black][/url]=>[red]'[/red][purple]gif[/purple][red]'[/red][red])[/red][red];[/red]
[blue]$mw[/blue]->[maroon]idletasks[/maroon][red];[/red]
[blue]$mw[/blue]->[maroon]iconimage[/maroon][red]([/red][blue]$icon[/blue][red])[/red][red];[/red]

[blue]$varsr[/blue] = [fuchsia]0[/fuchsia][red];[/red]
[blue]$varsg[/blue] = [fuchsia]0[/fuchsia][red];[/red]
[blue]$varsb[/blue] = [fuchsia]0[/fuchsia][red];[/red]

[blue]$f_frame[/blue] = [blue]$mw[/blue] -> [maroon]Frame[/maroon][red]([/red]-[purple]relief[/purple] => groove, -[purple]width[/purple] => [fuchsia]132[/fuchsia], -[purple]height[/purple] => [fuchsia]70[/fuchsia],
			 -[purple]borderwidth[/purple] => [fuchsia]3[/fuchsia][red])[/red]-> [maroon]place[/maroon][red]([/red][url=http://perldoc.perl.org/functions/-X.html][black][b]-x[/b][/black][/url] => [fuchsia]1[/fuchsia], -[red]y =[/red][purple]> 0);[/purple]
[purple]$s_frame [/purple][red]=[/red][purple] $mw -> Frame(-relief [/purple][red]=[/red]> groove, -[purple]width[/purple] => [fuchsia]132[/fuchsia], -[purple]height[/purple] => [fuchsia]70[/fuchsia],
			 -[purple]borderwidth[/purple] => [fuchsia]3[/fuchsia][red])[/red]-> [maroon]place[/maroon][red]([/red][black][b]-x[/b][/black] => [fuchsia]135[/fuchsia], -[red]y =[/red][purple]> 0);[/purple]
[purple]$t_frame [/purple][red]=[/red][purple] $mw -> Frame(-relief [/purple][red]=[/red]> groove, -[purple]width[/purple] => [fuchsia]132[/fuchsia], -[purple]height[/purple] => [fuchsia]70[/fuchsia],
			 -[purple]borderwidth[/purple] => [fuchsia]3[/fuchsia][red])[/red]-> [maroon]place[/maroon][red]([/red][black][b]-x[/b][/black] => [fuchsia]269[/fuchsia], -[red]y =[/red][purple]> 0);[/purple]

[purple]$lab_red [/purple][red]=[/red][purple] $f_frame -> Label(-text [/purple][red]=[/red]> [red]'[/red][purple]Red[/purple][red]'[/red], -[purple]foreground[/purple] => [red]'[/red][purple]#C72309[/purple][red]'[/red], 
				-[purple]font[/purple] => [red]'[/red][purple]Helvetica 9 bold[/purple][red]'[/red][red])[/red]-> [maroon]place[/maroon][red]([/red][black][b]-x[/b][/black] => [fuchsia]1[/fuchsia], -[red]y =[/red][purple]> 18);[/purple]
[purple]$lab_green [/purple][red]=[/red][purple] $s_frame -> Label(-text [/purple][red]=[/red]> [red]'[/red][purple]Green[/purple][red]'[/red], -[purple]foreground[/purple] => [red]'[/red][purple]#00AD4C[/purple][red]'[/red],
				 -[purple]font[/purple] => [red]'[/red][purple]Helvetica 9 bold[/purple][red]'[/red][red])[/red]-> [maroon]place[/maroon][red]([/red][black][b]-x[/b][/black] => [fuchsia]1[/fuchsia], -[red]y =[/red][purple]> 18);[/purple]
[purple]$lab_blue [/purple][red]=[/red][purple] $t_frame -> Label(-text [/purple][red]=[/red]> [red]'[/red][purple]Blue[/purple][red]'[/red], -[purple]foreground[/purple] => [red]'[/red][purple]blue[/purple][red]'[/red],
				 -[purple]font[/purple] => [red]'[/red][purple]Helvetica 9 bold[/purple][red]'[/red][red])[/red]-> [maroon]place[/maroon][red]([/red][black][b]-x[/b][/black] => [fuchsia]1[/fuchsia], -[red]y =[/red][purple]> 18);[/purple]

[purple]$lr_hex [/purple][red]=[/red][purple] $f_frame -> Label(-text [/purple][red]=[/red]> [red]'[/red][purple]Hexa[/purple][red]'[/red], -[purple]foreground[/purple] => [red]'[/red][purple]black[/purple][red]'[/red], 
				-[purple]font[/purple] => [red]'[/red][purple]Time 7[/purple][red]'[/red][red])[/red]-> [maroon]place[/maroon][red]([/red][black][b]-x[/b][/black] => [fuchsia]50[/fuchsia], -[red]y =[/red][purple]> 1);[/purple]
[purple]$lr_dec [/purple][red]=[/red][purple] $f_frame -> Entry(-justify [/purple][red]=[/red]> [red]'[/red][purple]left[/purple][red]'[/red], -[purple]foreground[/purple] => [red]'[/red][purple]black[/purple][red]'[/red], -[purple]width[/purple] => [fuchsia]10[/fuchsia], 
				-[purple]font[/purple] => [red]'[/red][purple]Helvetica 7[/purple][red]'[/red][red])[/red]-> [maroon]place[/maroon][red]([/red][black][b]-x[/b][/black] => [fuchsia]50[/fuchsia], -[red]y =[/red][purple]> 21);[/purple]
[purple]$lr_dec -> insert('1.0', "0 to 255");[/purple]
[purple]$lr_rgb [/purple][red]=[/red][purple] $f_frame -> Label(-text [/purple][red]=[/red]> [red]'[/red][purple]rgb %[/purple][red]'[/red], -[purple]foreground[/purple] => [red]'[/red][purple]black[/purple][red]'[/red], 
				-[purple]font[/purple] => [red]'[/red][purple]Helvetica 7[/purple][red]'[/red][red])[/red]-> [maroon]place[/maroon][red]([/red][black][b]-x[/b][/black] => [fuchsia]50[/fuchsia], -[red]y =[/red][purple]> 41);[/purple]

[purple]$lg_hex [/purple][red]=[/red][purple] $s_frame -> Label(-text [/purple][red]=[/red]> [red]'[/red][purple]Hexa[/purple][red]'[/red], -[purple]foreground[/purple] => [red]'[/red][purple]black[/purple][red]'[/red], 
				-[purple]font[/purple] => [red]'[/red][purple]Time 7[/purple][red]'[/red][red])[/red]-> [maroon]place[/maroon][red]([/red][black][b]-x[/b][/black] => [fuchsia]50[/fuchsia], -[red]y =[/red][purple]> 1);[/purple]
[purple]$lg_dec [/purple][red]=[/red][purple] $s_frame -> Entry(-justify [/purple][red]=[/red]> [red]'[/red][purple]left[/purple][red]'[/red], -[purple]foreground[/purple] => [red]'[/red][purple]black[/purple][red]'[/red], -[purple]width[/purple] => [fuchsia]10[/fuchsia], 
				-[purple]font[/purple] => [red]'[/red][purple]Helvetica 7[/purple][red]'[/red][red])[/red]-> [maroon]place[/maroon][red]([/red][black][b]-x[/b][/black] => [fuchsia]50[/fuchsia], -[red]y =[/red][purple]> 21);[/purple]
[purple]$lg_dec -> insert('1.0', "0 to 255"); [/purple]
[purple]$lg_rgb [/purple][red]=[/red][purple] $s_frame -> Label(-text [/purple][red]=[/red]> [red]'[/red][purple]rgb %[/purple][red]'[/red], -[purple]foreground[/purple] => [red]'[/red][purple]black[/purple][red]'[/red], 
				-[purple]font[/purple] => [red]'[/red][purple]Helvetica 7[/purple][red]'[/red][red])[/red]-> [maroon]place[/maroon][red]([/red][black][b]-x[/b][/black] => [fuchsia]50[/fuchsia], -[red]y =[/red][purple]> 41);[/purple]

[purple]$lb_hex [/purple][red]=[/red][purple] $t_frame -> Label(-text [/purple][red]=[/red]> [red]'[/red][purple]Hexa[/purple][red]'[/red], -[purple]foreground[/purple] => [red]'[/red][purple]black[/purple][red]'[/red], 
				-[purple]font[/purple] => [red]'[/red][purple]Time 7[/purple][red]'[/red][red])[/red]-> [maroon]place[/maroon][red]([/red][black][b]-x[/b][/black] => [fuchsia]50[/fuchsia], -[red]y =[/red][purple]> 1);[/purple]
[purple]$lb_dec [/purple][red]=[/red][purple] $t_frame -> Entry(-justify [/purple][red]=[/red]> [red]'[/red][purple]left[/purple][red]'[/red], -[purple]foreground[/purple] => [red]'[/red][purple]black[/purple][red]'[/red], -[purple]width[/purple] => [fuchsia]10[/fuchsia], 
				-[purple]font[/purple] => [red]'[/red][purple]Helvetica 7[/purple][red]'[/red][red])[/red]-> [maroon]place[/maroon][red]([/red][black][b]-x[/b][/black] => [fuchsia]50[/fuchsia], -[red]y =[/red][purple]> 21);[/purple]
[purple]$lb_dec -> insert('1.0', "0 to 255");[/purple]
[purple]$lb_rgb [/purple][red]=[/red][purple] $t_frame -> Label(-text [/purple][red]=[/red]> [red]'[/red][purple]rgb %[/purple][red]'[/red], -[purple]foreground[/purple] => [red]'[/red][purple]black[/purple][red]'[/red], 
				-[purple]font[/purple] => [red]'[/red][purple]Helvetica 7[/purple][red]'[/red][red])[/red]-> [maroon]place[/maroon][red]([/red][black][b]-x[/b][/black] => [fuchsia]50[/fuchsia], -[red]y =[/red][purple]> 41);[/purple]

[purple]$r_scale [/purple][red]=[/red][purple] $mw -> Scale(-activebackground [/purple][red]=[/red]> [red]'[/red][purple]red[/purple][red]'[/red], -[purple]orient[/purple] => [red]'[/red][purple]horizontal[/purple][red]'[/red], -[purple]showvalue[/purple] => [fuchsia]0[/fuchsia],
			-[purple]to[/purple] => [fuchsia]255[/fuchsia], -[purple]width[/purple] => [fuchsia]2[/fuchsia], -[url=http://perldoc.perl.org/functions/length.html][black][b]length[/b][/black][/url] => [fuchsia]395[/fuchsia], -[purple]cursor[/purple] => [red]'[/red][purple]hand2[/purple][red]'[/red], -[purple]takefocus[/purple] => [fuchsia]0[/fuchsia],
			-[purple]variable[/purple] => \[blue]$vrs[/blue], -[purple]command[/purple] => [red][[/red] \[maroon]&r[/maroon] [red]][/red][red])[/red]-> [maroon]place[/maroon][red]([/red][black][b]-x[/b][/black] => [fuchsia]0[/fuchsia], -[red]y =[/red][purple]> 72);[/purple]
[purple]$g_scale [/purple][red]=[/red][purple] $mw -> Scale(-activebackground [/purple][red]=[/red]> [red]'[/red][purple]green[/purple][red]'[/red], -[purple]orient[/purple] => [red]'[/red][purple]horizontal[/purple][red]'[/red], -[purple]showvalue[/purple] => [fuchsia]0[/fuchsia],
			-[purple]to[/purple] => [fuchsia]255[/fuchsia], -[purple]width[/purple] => [fuchsia]2[/fuchsia], -[black][b]length[/b][/black] => [fuchsia]395[/fuchsia], -[purple]cursor[/purple] => [red]'[/red][purple]hand2[/purple][red]'[/red], -[purple]takefocus[/purple] => [fuchsia]0[/fuchsia],
			-[purple]variable[/purple] => \[blue]$vgs[/blue], -[purple]command[/purple] => [red][[/red] \[maroon]&g[/maroon] [red]][/red][red])[/red]-> [maroon]place[/maroon][red]([/red][black][b]-x[/b][/black] => [fuchsia]0[/fuchsia], -[red]y =[/red][purple]> 80);[/purple]
[purple]$b_scale [/purple][red]=[/red][purple] $mw -> Scale(-activebackground [/purple][red]=[/red]> [red]'[/red][purple]blue[/purple][red]'[/red], -[purple]orient[/purple] => [red]'[/red][purple]horizontal[/purple][red]'[/red], -[purple]showvalue[/purple] => [fuchsia]0[/fuchsia],
			-[purple]to[/purple] => [fuchsia]255[/fuchsia], -[purple]width[/purple] => [fuchsia]2[/fuchsia], -[black][b]length[/b][/black] => [fuchsia]395[/fuchsia], -[purple]cursor[/purple] => [red]'[/red][purple]hand2[/purple][red]'[/red], -[purple]takefocus[/purple] => [fuchsia]0[/fuchsia],
			-[purple]variable[/purple] => \[blue]$vbs[/blue], -[purple]command[/purple] => [red][[/red] \[maroon]&b[/maroon] [red]][/red][red])[/red]-> [maroon]place[/maroon][red]([/red][black][b]-x[/b][/black] => [fuchsia]0[/fuchsia], -[red]y =[/red][purple]> 88);[/purple]

[purple]$look_it [/purple][red]=[/red][purple] $mw -> Label(-font [/purple][red]=[/red]> [red]'[/red][purple]Arial 20 bold[/purple][red]'[/red], -[purple]width[/purple] => [fuchsia]26[/fuchsia], -[purple]height[/purple] => [fuchsia]6[/fuchsia][red])[/red]-> [maroon]place[/maroon][red]([/red][black][b]-x[/b][/black] => [fuchsia]2[/fuchsia], -[red]y =[/red][purple]> 100);[/purple]

[purple]$mw -> minsize($mw -> width, $mw -> height);[/purple]
[purple]$mw -> maxsize($mw -> width, $mw -> height);[/purple]

[purple]#-----------------------------Routines[/purple]

[purple]$mw -> repeat(500, sub{[/purple]
[purple]$dec_ent_f [/purple][red]=[/red][purple] $lr_dec ->get();[/purple]
[purple]$dec_ent_s [/purple][red]=[/red] [blue]$lg_dec[/blue] ->[maroon]get[/maroon][red]([/red][red])[/red][red];[/red]
[blue]$dec_ent_t[/blue] = [blue]$lb_dec[/blue] ->[maroon]get[/maroon][red]([/red][red])[/red][red];[/red]

	[olive][b]unless[/b][/olive][red]([/red][blue]$dec_ent_f[/blue] eq [red]'[/red][purple]0 to 255[/purple][red]'[/red] || [blue]$dec_ent_f[/blue] eq [red]"[/red][purple][/purple][red]"[/red] || [blue]$dec_ent_f[/blue] eq [red]"[/red][purple]0[/purple][red]"[/red][red])[/red][red]{[/red]
	[blue]$dec_ent_f[/blue] =~ [red]s/[/red][purple][purple][b]\D[/b][/purple][/purple][red]/[/red][purple][/purple][red]/[/red][red]g[/red][red];[/red]
	[blue]$dec_ent_f[/blue] =~ [red]s/[/red][purple]^0{0,}[/purple][red]/[/red][purple][/purple][red]/[/red][red];[/red]
		[olive][b]if[/b][/olive][red]([/red][blue]$dec_ent_f[/blue] > [fuchsia]255[/fuchsia][red])[/red][red]{[/red]
		[blue]$dec_ent_f[/blue] = [blue]$dec_ent_f[/blue] [blue]%[/blue] [fuchsia]255[/fuchsia][red];[/red]
		[red]}[/red]
	
		[olive][b]if[/b][/olive][red]([/red][blue]$vrs[/blue] != [blue]$dec_ent_f[/blue][red])[/red][red]{[/red]
		[blue]$vrs[/blue] = [blue]$dec_ent_f[/blue][red];[/red]
		[blue]$r_scale[/blue] -> [maroon]set[/maroon][red]([/red][blue]$vrs[/blue][red])[/red][red];[/red]
		[red]}[/red]
	[maroon]&r[/maroon][red];[/red]
	[red]}[/red]

	[olive][b]unless[/b][/olive][red]([/red][blue]$dec_ent_s[/blue] eq [red]'[/red][purple]0 to 255[/purple][red]'[/red] || [blue]$dec_ent_s[/blue] eq [red]"[/red][purple][/purple][red]"[/red] || [blue]$dec_ent_s[/blue] eq [red]"[/red][purple]0[/purple][red]"[/red][red])[/red][red]{[/red]
	[blue]$dec_ent_s[/blue] =~ [red]s/[/red][purple][purple][b]\D[/b][/purple][/purple][red]/[/red][purple][/purple][red]/[/red][red]g[/red][red];[/red]
	[blue]$dec_ent_s[/blue] =~ [red]s/[/red][purple]^0{0,}[/purple][red]/[/red][purple][/purple][red]/[/red][red];[/red]
		[olive][b]if[/b][/olive][red]([/red][blue]$dec_ent_s[/blue] > [fuchsia]255[/fuchsia][red])[/red][red]{[/red]
		[blue]$dec_ent_s[/blue] = [blue]$dec_ent_s[/blue] [blue]%[/blue] [fuchsia]255[/fuchsia][red];[/red]
		[red]}[/red]
	
		[olive][b]if[/b][/olive][red]([/red][blue]$vgs[/blue] != [blue]$dec_ent_s[/blue][red])[/red][red]{[/red]
		[blue]$vgs[/blue] = [blue]$dec_ent_s[/blue][red];[/red]
		[blue]$g_scale[/blue] -> [maroon]set[/maroon][red]([/red][blue]$vgs[/blue][red])[/red][red];[/red]
		[red]}[/red]
	[maroon]&g[/maroon][red];[/red]
	[red]}[/red]

	[olive][b]unless[/b][/olive][red]([/red][blue]$dec_ent_t[/blue] eq [red]'[/red][purple]0 to 255[/purple][red]'[/red] || [blue]$dec_ent_t[/blue] eq [red]"[/red][purple][/purple][red]"[/red] || [blue]$dec_ent_t[/blue] eq [red]"[/red][purple]0[/purple][red]"[/red][red])[/red][red]{[/red]
	[blue]$dec_ent_t[/blue] =~ [red]s/[/red][purple][purple][b]\D[/b][/purple][/purple][red]/[/red][purple][/purple][red]/[/red][red]g[/red][red];[/red]
	[blue]$dec_ent_t[/blue] =~ [red]s/[/red][purple]^0{0,}[/purple][red]/[/red][purple][/purple][red]/[/red][red];[/red]
		[olive][b]if[/b][/olive][red]([/red][blue]$dec_ent_t[/blue] > [fuchsia]255[/fuchsia][red])[/red][red]{[/red]
		[blue]$dec_ent_t[/blue] = [blue]$dec_ent_t[/blue] [blue]%[/blue] [fuchsia]255[/fuchsia][red];[/red]
		[red]}[/red]
	
		[olive][b]if[/b][/olive][red]([/red][blue]$vbs[/blue] != [blue]$dec_ent_t[/blue][red])[/red][red]{[/red]
		[blue]$vbs[/blue] = [blue]$dec_ent_t[/blue][red];[/red]
		[blue]$b_scale[/blue] -> [maroon]set[/maroon][red]([/red][blue]$vbs[/blue][red])[/red][red];[/red]
		[red]}[/red]
	[maroon]&b[/maroon][red];[/red]
	[red]}[/red]
[red]}[/red][red])[/red][red];[/red]

[gray][i]#-----------------------------[/i][/gray]

[url=http://perldoc.perl.org/functions/sub.html][black][b]sub[/b][/black][/url] [maroon]r[/maroon][red]{[/red]
	[olive][b]if[/b][/olive][red]([/red][blue]$varsr[/blue] == [red]"[/red][purple]0[/purple][red]"[/red][red])[/red][red]{[/red]
	[blue]$varsr[/blue] += [blue]$vrs[/blue][red];[/red]
	[red]}[/red]

	[olive][b]if[/b][/olive][red]([/red][blue]$varsr[/blue] > [fuchsia]0[/fuchsia][red])[/red][red]{[/red]
	[blue]$flag_r[/blue] = [fuchsia]1[/fuchsia][red];[/red]
	[blue]$rgb_r[/blue] = [maroon]&percent[/maroon][red]([/red][blue]$vrs[/blue][red])[/red][red];[/red]
	[blue]$h_couleur_r[/blue] = [maroon]&get_hexa[/maroon][red]([/red][blue]$vrs[/blue][red])[/red][red];[/red]
	[blue]$lr_hex[/blue] -> [maroon]configure[/maroon][red]([/red]-[purple]text[/purple] => [blue]$h_couleur_r[/blue][red])[/red][red];[/red]
	[blue]$lr_rgb[/blue] -> [maroon]configure[/maroon][red]([/red]-[purple]text[/purple] => [blue]$rgb_r[/blue][red])[/red][red];[/red]
	[blue]$lr_dec[/blue] -> [maroon]delete[/maroon][red]([/red][fuchsia]0[/fuchsia], [red]'[/red][purple]end[/purple][red]'[/red][red])[/red][red];[/red]
	[blue]$lr_dec[/blue] -> [maroon]insert[/maroon][red]([/red][red]'[/red][purple]1.0[/purple][red]'[/red], [blue]$vrs[/blue][red])[/red][red];[/red]
	[maroon]&see_this[/maroon][red];[/red]
	[red]}[/red]
[red]}[/red]

[gray][i]#-----------------------------[/i][/gray]

[black][b]sub[/b][/black] [maroon]g[/maroon][red]{[/red]
	[olive][b]if[/b][/olive][red]([/red][blue]$varsg[/blue] == [red]"[/red][purple]0[/purple][red]"[/red][red])[/red][red]{[/red]
	[blue]$varsg[/blue] += [blue]$vgs[/blue][red];[/red]
	[red]}[/red]

	[olive][b]if[/b][/olive][red]([/red][blue]$varsg[/blue] > [fuchsia]0[/fuchsia][red])[/red][red]{[/red]
	[blue]$flag_g[/blue] = [fuchsia]1[/fuchsia][red];[/red]
	[blue]$rgb_g[/blue] = [maroon]&percent[/maroon][red]([/red][blue]$vgs[/blue][red])[/red][red];[/red]
	[blue]$h_couleur_g[/blue] = [maroon]&get_hexa[/maroon][red]([/red][blue]$vgs[/blue][red])[/red][red];[/red]
	[blue]$lg_hex[/blue] -> [maroon]configure[/maroon][red]([/red]-[purple]text[/purple] => [blue]$h_couleur_g[/blue][red])[/red][red];[/red]
	[blue]$lg_rgb[/blue] -> [maroon]configure[/maroon][red]([/red]-[purple]text[/purple] => [blue]$rgb_g[/blue][red])[/red][red];[/red]
	[blue]$lg_dec[/blue] -> [maroon]delete[/maroon][red]([/red][fuchsia]0[/fuchsia], [red]'[/red][purple]end[/purple][red]'[/red][red])[/red][red];[/red]
	[blue]$lg_dec[/blue] -> [maroon]insert[/maroon][red]([/red][red]'[/red][purple]1.0[/purple][red]'[/red], [blue]$vgs[/blue][red])[/red][red];[/red]
	[maroon]&see_this[/maroon][red];[/red]
	[red]}[/red]

[red]}[/red]

[gray][i]#-----------------------------[/i][/gray]

[black][b]sub[/b][/black] [maroon]b[/maroon][red]{[/red]
	[olive][b]if[/b][/olive][red]([/red][blue]$varsb[/blue] == [red]"[/red][purple]0[/purple][red]"[/red][red])[/red][red]{[/red]
	[blue]$varsb[/blue] += [blue]$vbs[/blue][red];[/red]
	[red]}[/red]

	[olive][b]if[/b][/olive][red]([/red][blue]$varsb[/blue] > [fuchsia]0[/fuchsia][red])[/red][red]{[/red]
	[blue]$flag_b[/blue] = [fuchsia]1[/fuchsia][red];[/red]
	[blue]$rgb_b[/blue] = [maroon]&percent[/maroon][red]([/red][blue]$vbs[/blue][red])[/red][red];[/red]
	[blue]$h_couleur_b[/blue] = [maroon]&get_hexa[/maroon][red]([/red][blue]$vbs[/blue][red])[/red][red];[/red]
	[blue]$lb_hex[/blue] -> [maroon]configure[/maroon][red]([/red]-[purple]text[/purple] => [blue]$h_couleur_b[/blue][red])[/red][red];[/red]
	[blue]$lb_rgb[/blue] -> [maroon]configure[/maroon][red]([/red]-[purple]text[/purple] => [blue]$rgb_b[/blue][red])[/red][red];[/red]
	[blue]$lb_dec[/blue] -> [maroon]delete[/maroon][red]([/red][fuchsia]0[/fuchsia], [red]'[/red][purple]end[/purple][red]'[/red][red])[/red][red];[/red]
	[blue]$lb_dec[/blue] -> [maroon]insert[/maroon][red]([/red][red]'[/red][purple]1.0[/purple][red]'[/red], [blue]$vbs[/blue][red])[/red][red];[/red]
	[maroon]&see_this[/maroon][red];[/red]
	[red]}[/red]
[red]}[/red]

[gray][i]#-----------------------------[/i][/gray]

[black][b]sub[/b][/black] [maroon]percent[/maroon][red]{[/red]
[url=http://perldoc.perl.org/functions/return.html][black][b]return[/b][/black][/url][red]([/red][url=http://perldoc.perl.org/functions/sprintf.html][black][b]sprintf[/b][/black][/url][red]([/red][red]"[/red][purple]%1.2f[/purple][red]"[/red], [red]([/red][blue]$_[/blue][red][[/red][fuchsia]0[/fuchsia][red]][/red] [blue]*[/blue] [fuchsia]100[/fuchsia][red])[/red] / [fuchsia]255[/fuchsia][red])[/red][red])[/red][red];[/red]
[red]}[/red]

[gray][i]#-----------------------------[/i][/gray]

[black][b]sub[/b][/black] [maroon]get_hexa[/maroon][red]{[/red]
[blue]$back_hex[/blue] = [black][b]sprintf[/b][/black][red]([/red][red]"[/red][purple]%lx[/purple][red]"[/red], [blue]$_[/blue][red][[/red][fuchsia]0[/fuchsia][red]][/red][red])[/red][red];[/red]
	[olive][b]if[/b][/olive][red]([/red][black][b]length[/b][/black][red]([/red][blue]$back_hex[/blue][red])[/red] eq [fuchsia]1[/fuchsia][red])[/red][red]{[/red]
	[blue]$back_hex[/blue] = [url=http://perldoc.perl.org/functions/join.html][black][b]join[/b][/black][/url][red]([/red][red]"[/red][purple][/purple][red]"[/red], [red]([/red][fuchsia]0[/fuchsia], [blue]$back_hex[/blue][red])[/red][red])[/red][red];[/red]
	[red]}[/red]
[black][b]return[/b][/black][red]([/red][url=http://perldoc.perl.org/functions/uc.html][black][b]uc[/b][/black][/url][red]([/red][blue]$back_hex[/blue][red])[/red][red])[/red][red];[/red]
[red]}[/red]

[gray][i]#-----------------------------[/i][/gray]

[black][b]sub[/b][/black] [maroon]see_this[/maroon][red]{[/red]
	[olive][b]unless[/b][/olive][red]([/red][url=http://perldoc.perl.org/functions/defined.html][black][b]defined[/b][/black][/url][red]([/red][blue]$flag_r[/blue][red])[/red][red])[/red][red]{[/red]
	[blue]$h_couleur_r[/blue] = [red]'[/red][purple]00[/purple][red]'[/red][red];[/red]
	[red]}[/red]

	[olive][b]unless[/b][/olive][red]([/red][black][b]defined[/b][/black][red]([/red][blue]$flag_g[/blue][red])[/red][red])[/red][red]{[/red]
	[blue]$h_couleur_g[/blue] = [red]'[/red][purple]00[/purple][red]'[/red][red];[/red]
	[red]}[/red]

	[olive][b]unless[/b][/olive][red]([/red][black][b]defined[/b][/black][red]([/red][blue]$flag_b[/blue][red])[/red][red])[/red][red]{[/red]
	[blue]$h_couleur_b[/blue] = [red]'[/red][purple]00[/purple][red]'[/red][red];[/red]
	[red]}[/red]

[blue]$color[/blue] = [black][b]join[/b][/black][red]([/red][red]"[/red][purple][/purple][red]"[/red], [red]([/red][blue]$h_couleur_r[/blue], [blue]$h_couleur_g[/blue], [blue]$h_couleur_b[/blue][red])[/red][red])[/red][red];[/red]
[blue]$foreground_visibility[/blue] = [maroon]&get_visibility[/maroon][red]([/red][blue]$color[/blue][red])[/red][red];[/red] 
[blue]$look_it[/blue] -> [maroon]configure[/maroon][red]([/red]-[purple]background[/purple] => [red]"[/red][purple][purple][b]\#[/b][/purple][blue]$color[/blue][/purple][red]"[/red], -[purple]text[/purple] => [red]"[/red][purple][purple][b]\#[/b][/purple][blue]$color[/blue][/purple][red]"[/red], 
			-[purple]foreground[/purple] => [red]"[/red][purple][purple][b]\#[/b][/purple][blue]$foreground_visibility[/blue][/purple][red]"[/red][red])[/red][red];[/red]
[red]}[/red]

[gray][i]#-----------------------------[/i][/gray]

[black][b]sub[/b][/black] [maroon]get_visibility[/maroon][red]{[/red]
[blue]$gi[/blue] = [url=http://perldoc.perl.org/functions/hex.html][black][b]hex[/b][/black][/url][red]([/red][blue]$_[/blue][red][[/red][fuchsia]0[/fuchsia][red]][/red][red])[/red][red];[/red]

	[olive][b]if[/b][/olive][red]([/red][blue]$gi[/blue] >= [fuchsia]0[/fuchsia] && [blue]$gi[/blue] <= [fuchsia]4194303[/fuchsia][red])[/red][red]{[/red]
	[blue]$gib[/blue] = [black][b]sprintf[/b][/black][red]([/red][red]"[/red][purple]%lx[/purple][red]"[/red], [red]([/red][blue]$gi[/blue] + [fuchsia]8388608[/fuchsia][red])[/red][red])[/red][red];[/red]
	[red]}[/red]
	[olive][b]if[/b][/olive][red]([/red][blue]$gi[/blue] >= [fuchsia]4194304[/fuchsia]  && [blue]$gi[/blue] <= [fuchsia]8388607[/fuchsia][red])[/red][red]{[/red]
	[blue]$gib[/blue] = [black][b]sprintf[/b][/black][red]([/red][red]"[/red][purple]%lx[/purple][red]"[/red], [red]([/red][blue]$gi[/blue] + [fuchsia]8388608[/fuchsia][red])[/red][red])[/red][red];[/red]
	[red]}[/red]
	[olive][b]if[/b][/olive][red]([/red][blue]$gi[/blue] >= [fuchsia]8388608[/fuchsia] && [blue]$gi[/blue] <= [fuchsia]12582911[/fuchsia][red])[/red][red]{[/red]
	[blue]$gib[/blue] = [black][b]sprintf[/b][/black][red]([/red][red]"[/red][purple]%lx[/purple][red]"[/red], [red]([/red][blue]$gi[/blue] - [fuchsia]8388608[/fuchsia][red])[/red][red])[/red][red];[/red]
	[red]}[/red]
	[olive][b]if[/b][/olive][red]([/red][blue]$gi[/blue] >= [fuchsia]12582912[/fuchsia]  && [blue]$gi[/blue] <= [fuchsia]16777215[/fuchsia][red])[/red][red]{[/red]
	[blue]$gib[/blue] = [black][b]sprintf[/b][/black][red]([/red][red]"[/red][purple]%lx[/purple][red]"[/red], [red]([/red][blue]$gi[/blue] - [fuchsia]8388608[/fuchsia][red])[/red][red])[/red][red];[/red]
	[red]}[/red]

[blue]$l_gib[/blue] = [black][b]length[/b][/black][red]([/red][blue]$gib[/blue][red])[/red][red];[/red]

	[olive][b]if[/b][/olive][red]([/red][blue]$l_gib[/blue] ne [fuchsia]6[/fuchsia][red])[/red][red]{[/red]
	[blue]$add[/blue] = [fuchsia]6[/fuchsia] - [blue]$l_gib[/blue][red];[/red]
	[blue]$gi[/blue] = [red]'[/red][purple]0[/purple][red]'[/red] x [blue]$add[/blue][red];[/red]
	[blue]$gi[/blue] .= [blue]$gib[/blue][red];[/red]
	[blue]$gib[/blue] = [blue]$gi[/blue][red];[/red]
	[red]}[/red]

[black][b]return[/b][/black][red]([/red][blue]$gib[/blue][red])[/red][red];[/red]	
[red]}[/red]

[gray][i]#-----------------------------[/i][/gray]

[black][b]sub[/b][/black] [maroon]im[/maroon][red]{[/red]

[url=http://perldoc.perl.org/functions/my.html][black][b]my[/b][/black][/url] [blue]$egg_gif[/blue] = 
[red]"[/red][purple]R0lGODdhIAAgAPf/AAAAAIAAAACAAICAAAAAgIAAgACAgMDAwMDcwKbK8P//zP//mf//Zv//M//M[/purple]
[purple]///MzP/Mmf/MZv/MM//MAP+Z//+ZzP+Zmf+ZZv+ZM/+ZAP9m//9mzP9mmf9mZv9mM/9mAP8z//8z[/purple]
[purple]zP8zmf8zZv8zM/8zAP8AzP8Amf8AZv8AM8z//8z/zMz/mcz/Zsz/Zsz/M8z/AMzM/8zMzMzMmczM[/purple]
[purple]ZszMM8zMAMyZ/8yZzMyZmcyZZsyZM8yZAMxm/8xmzMxmmcxmZsxmM8xmAMwz/8wzzMwzmcwzZswz[/purple]
[purple]M8wzAMwA/8wAzMwAmcwAZswAM8wAAJn//5n/zJn/mZn/Zpn/M5n/AJnM/5nMzJnMmZnMZpnMM5nM[/purple]
[purple]AJmZ/5mZzJmZmZmZZpmZM5mZAJlm/5lmzJlmmZlmZplmM5lmAJkz/5kzzJkzmZkzZpkzM5kzAJkA[/purple]
[purple]/5kAzJkAmZkAZpkAM5kAAGb//2b/zGb/mWb/Zmb/M2b/AGbM/2bMzGbMmWbMZmbMM2bMAGaZ/2aZ[/purple]
[purple]zGaZmWaZZmaZM2aZAGZm/2ZmzGZmmWZmZmZmM2ZmAGYz/2YzzGYzmWYzZmYzM2YzAGYA/2YAzGYA[/purple]
[purple]mWYAZmYAM2YAADP//zP/zDP/mTP/ZjP/MzP/ADPM/zPMzDPMmTPMZjPMMzPMADOZ/zOZzDOZmTOZ[/purple]
[purple]ZjOZMzOZADNm/zNmzDNmmTNmZjNmMzNmADMz/zMzzDMzmTMzZjMzMzMzADMA/zMAzDMAmTMAZjMA[/purple]
[purple]MzMAAAD/zAD/mQD/ZgD/MwDM/wDMzADMmQDMZgDMMwDMAACZ/wCZzACZmQCZZgCZMwCZAABm/wBm[/purple]
[purple]zABmmQBmZgBmAABmMwAz/wAzzAAzmQAzZgAzMwAzAAAAzAAAmQAAZgAAM90AALsAAKoAAIgAAHcA[/purple]
[purple]AFUAAEQAACIAAADdAAC7AACqAACIAAB3AABVAABEAAAiAN3d3VVVVXd3d3d3d0RERCIiIhEREQAA[/purple]
[purple]dwAAVQAARAAAIv/78KCgpICAgP8AAAD/AP//AAAA//8A/wD//////yH5BAEAAAEALAAAAAAgACAA[/purple]
[purple]Bwj/AAMIHEiwoMGDCBMqXMiwocOHECNKnEixIkEAGDNqnJhRgUcF40J+zOgQY4wYH0OO+6hgjss5[/purple]
[purple]GBWajLEvBgOVDHLmzMPzJUwAB2fGuHFznM6jPPN8+JA05kUAJ2/suxFSZ9WdPJcmzeNUINSpN8Je[/purple]
[purple]LYp1a1ILEIB6jRp2X86xOs1utYBWLdShYK3iLKuVJ926Ae6GHXz0bdWkffP8pWtycN7ChuX6XYyx[/purple]
[purple]7WCicA9LXmyh8uWpZA3zZTqZLofKU8ESPWo0blbSiv+eDnw5rN7CkmNbmE3b8eqbohnkVsyBd2/V[/purple]
[purple]wIMjhp2nuFqvAGrDRfo6z5/rXaE7LtqaetLrf7IPKcS4r4d5w2Otg8f+PCgA8xLiy1cpYb34hBnl[/purple]
[purple]61dJUqLG/+1ZJOCAAgUEADs=[purple][b]\n[/b][/purple][purple][b]\n[/b][/purple][/purple][red]"[/red][red];[/red]

[black][b]my[/b][/black] [blue]%send_back[/blue] = [red]([/red]
[fuchsia]1[/fuchsia] => [blue]$egg_gif[/blue] [red])[/red][red];[/red]


[black][b]return[/b][/black][red]([/red][blue]$send_back[/blue][red]{[/red][blue]$_[/blue][red][[/red][fuchsia]0[/fuchsia][red]][/red][red]}[/red][red])[/red][red];[/red]

[red]}[/red]

[gray][i]#-----------------------------[/i][/gray]

MainLoop[red];[/red]
[tt]------------------------------------------------------------
Other Modules used :
[ul]
[li]Tk[/li]
[li]Tk::Entry[/li]
[li]Tk::Frame[/li]
[li]Tk::Label[/li]
[li]Tk::photo[/li]
[li]Tk::Scale[/li]
[/ul]
[/tt]

dmazzini
GSM/UMTS System and Telecomm Consultant

 
ok that helps sooo much! I have no idea what i was thinking, i didn't think to test and see if i could use Hexadecimal colors! and i was wondering about how to insert the icon for the main window. thank you soo much! you saved me hours of wondering google!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top