http://qs321.pair.com?node_id=1212934


in reply to Re^3: How to get foreground color from a TK::Listbox
in thread How to get foreground color from a TK::Listbox

OK! Seems like a good place to finally solve my project.
Will work on a canvas solution and see how that goes from there on. Thanks.
  • Comment on Re^4: How to get foreground color from a TK::Listbox

Replies are listed 'Best First'.
Re^5: How to get foreground color from a TK::Listbox
by zentara (Archbishop) on Apr 17, 2018 at 11:57 UTC
    Hi, one point I forgot to mention. It may or may not help. In Tk, is is sometimes useful to pre-define all the special fonts before you use them in widgets. Create the fonts first, then refer to them by a name, like 'big', or 'bold'.
    #!/usr/bin/perl use warnings; use strict; use Tk; my $mw = new MainWindow; $mw->fontCreate('big', -family=>'arial', -weight=>'bold', -size=> 28 ); my $c = $mw->Canvas(-bg=>'white')->pack; #---determine font spacing by making a capital W--- my $fonttest = $c->createText(100,100, -fill => 'black', -text => 'W', -font => 'big' ); my ($bx,$by,$bx1,$by1) = $c->bbox($fonttest); $c->{'f_width'} = $bx1 - $bx; $c->{'f_height'} = $by1 - $by; print 'width ',$c->{'f_width'},' ',$c->{'f_height'},"\n"; MainLoop;

    I'm not really a human, but I play one on earth. ..... an animated JAPH