Please find the following independent application to reproduce the
issue.
click on check
click on choose color
===> Now check the predefined color in this dialog box. It is shown on
the left side.
choose a color and press ok
again click on check and choose color
===> Try to see the predefined colors. You will find none.
use strict;
use Tk;
my $newColor='';
my $mw=MainWindow->new(-title=>'SpyGlass Power Browser');
my $tl;
my $but=$mw->Button(-text=>'check',-command=>\&func)->pack;
sub func
{
$tl=$mw->Toplevel(-title=>'top level');
my $but2=$tl->Button(-text=>'choose color',-command=>\&func2)-
>pack;
}
sub func2
{
$newColor=$tl->chooseColor(-title=>"Choose Color for Range ",
-parent=>$tl);
$tl->destroy;
}
MainLoop;
I don't know whether the issue is there due to perl/tk installation.
Any help is appreciated.
Thanks in advance.
/Robert
On Windows, perl/Tk uses the native color chooser widget,
which varies depending on which version of Windows you are
running. On other OSes, it uses Tk::ColorEditor which does
not have a 'predefined' selection.
You can specify an '-initialcolor' attribute, if that helps.
--S
Hi,
I can reproduce the behaviour of your example with 804.027_500 (linux)
and 804.027_501 (macos).
Here is a workaround (it seems, that Tk's chooseColor Dialog does not
want its parent to be destroyed...)
Christoph
use warnings;
use strict;
use Tk;
my $newColor='';
my $mw=MainWindow->new(-title=>'SpyGlass Power Browser');
my $tl;
my $but=$mw->Button(-text=>'check',-command=>\&func)->pack;
sub func{
if (Tk::Exists($tl)){
$tl->deiconify;
$tl->raise;
return;
}
$tl=$mw->Toplevel(-title=>'top level');
my $but2=$tl->Button(-text=>'choose color',-command=>\&func2)->pack;
}
sub func2
{
$newColor=$tl->chooseColor(-title=>"Choose Color for Range ",
-parent=>$tl);
$tl->withdraw;
}
MainLoop;
An even smaller testcase directly from command line.
$ perl -MTk -MTk::ColorEditor -e '$mw=tkinit;$mw->ColorSelect->pack;$c=$mw->ColorSelect->pack;MainLoop'
This is now solved in the Perl/Tk SVN repository:
------------------------------------------------------------------------
r10080 | srezic | 2007-10-14 13:27:03 +0200 (So, 14 Okt 2007) | 7 lines
Geänderte Pfade:
M /Tk/trunk
M /Tk/trunk/MANIFEST
M /Tk/trunk/Tk/ColorEditor.pm
A /Tk/trunk/t/coloreditor.t
r1861@biokovo-amd64: eserte | 2007-10-14 13:26:50 +0200
* solved chooseColor issue reported in
http://groups.google.com/group/comp.lang.perl.tk/browse_frm/thread/8a1f994f532648be
(only first color dialog gets a color list)
* additional tests for ColorEditor
* make sure a destroyed waiting color dialog does not "block" the application
------------------------------------------------------------------------
Regards,
Slaven
--
Slaven Rezic - slaven <at> rezic <dot> de
sf-upload: make batch releases on SourceForge
http://sf-upload.sf.net