Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Problem with Tk::chooseColor on Win32

by thundergnat (Deacon)
on May 24, 2007 at 17:45 UTC ( [id://617288]=note: print w/replies, xml ) Need Help??


in reply to Problem with Tk::chooseColor on Win32

If you cancel the dialog, the $colour variable is undefined. You then try to set the -background and -activebackground to an undefined value. CRASH!!

You need to check that $colour is defined before using it.

use strict; use warnings; use Tk; my $cfg; my $font_colour; my $wd = MainWindow->new(); $wd->Label( -text => 'Color', -justify => 'right', )->grid( -column => 0, -row => 4, -pady => 20, -padx => 20, -sticky => 'e' ); my $colour_button = $wd->Button( -width => 6, -command => sub { $font_colour = colour_picker() }, )->grid( -column => 2, -row => 4, -pady => 20, -padx => 20, -sticky => 'e' ); if ($font_colour) { $colour_button->configure( -background => $font_colour, -activebackg +round => $font_colour ); } MainLoop; sub colour_picker { my $colour = $wd->chooseColor( -title => 'Color Picker', -initialcol +or => '#000000' ); $colour ? print "Colour chosen: " . $colour . "\n" : return; $colour_button->configure( -background => $colour, -activebackground + => $colour ); return $colour; }

Replies are listed 'Best First'.
Re^2: Problem with Tk::chooseColor on Win32
by jdtoronto (Prior) on May 24, 2007 at 18:42 UTC
Re^2: Problem with Tk::chooseColor on Win32
by ldln (Pilgrim) on May 24, 2007 at 18:09 UTC
    ...just curious : Is there an similar command to bring out the font-selection-window on win32 from perl/Tk also?

      Not that I am aware of. It isn't too hard to fake it though... and you could probably access it through Win32::API with a little tinkering.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://617288]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2024-04-19 08:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found