jsteng has asked for the wisdom of the Perl Monks concerning the following question:
Problems:#!/usr/bin/perl use warnings; use strict; use Tk; my ($DimX,$DimY)=(400,600); my ($mX,$mY) = (2,2); my $mw = MainWindow->new( -bg=> "#000000", -borderwidth=> 0); $mw->minsize( $DimX, $DimY ); $mw->maxsize( $DimX, $DimY ); my %canvas; my $fontsize=int(20); $canvas{'canvas'} = $mw->Scrolled( 'Canvas', -width => $DimX-2*$mX, -height => 2*$DimY, -bg => '#60C8BC', -borderwidth => 2, -relief => 'raised', -scrollbars => 'e', )->pack(); $canvas{'canvas'}->CanvasBind("<Button-1>", [ \&print_xy, Ev('x'), Ev( +'y') ]); sub print_xy { my ($canv, $x, $y) = @_; my $sel = int($canvas{'canvas'}->canvasy($y) / (1.4*$fontsize+2)); printf "Selected: %d, (%d,%d)\n", $sel, $canvas{'canvas'}->canvasx +($x),$canvas{'canvas'}->canvasy($y); $canvas{'text'}{$sel}->itemconfigure( -fill => '#0000FF', -font => "Courier $fontsize bold", ); } for (my $y=0; $y<200; $y++) { $canvas{'text'}{$y} = $canvas{'canvas'}->createText( 5, 4+$y*(1.4* +$fontsize+2), -fill => '#000000', -text => "GgYy".$y x 20, -font => "Courier $fontsize normal", -anchor => 'nw', ); } MainLoop;
But it is not working.$canvas{'text'}{$sel}->itemconfigure( -fill => '#0000FF', -font => "Courier $fontsize bold", );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: tk canvas text
by tybalt89 (Monsignor) on Apr 16, 2018 at 20:13 UTC | |
by jsteng (Beadle) on Apr 16, 2018 at 23:46 UTC | |
by tybalt89 (Monsignor) on Apr 17, 2018 at 00:00 UTC | |
by jsteng (Beadle) on Apr 17, 2018 at 06:03 UTC | |
|
Re: tk canvas text
by Anonymous Monk on Apr 16, 2018 at 10:17 UTC | |
by jsteng (Beadle) on Apr 16, 2018 at 15:44 UTC | |
by Anonymous Monk on Apr 16, 2018 at 17:22 UTC | |
by Anonymous Monk on Apr 16, 2018 at 18:42 UTC |