in reply to problem with TK, tag, passing param with binding, destroying binds
#!/usr/bin/perl # http://perlmonks.org/?node_id=1213205 use strict; use warnings; use Tk; my $mw = MainWindow->new( -bg=> "#000000", -borderwidth=> 0); $mw->geometry( '1000x600' ); my $LB = $mw->Scrolled ( 'ROText', -bg => '#C0C0C0', -fg => '#000000', -selectforeground => '#000000', -selectbackground => '#C0C0C0', -font => 'Courier 16 normal', -relief => 'groove', -cursor => 'top_left_arrow', -scrollbars => 'e', )->pack( -side => 'right', -expand => 1, -fill => 'both', ); sub selectAccount { my $this = shift; print "select: $this\n"; } sub markAccount { my $this = shift; print "mark: $this\n"; } sub InitializeListBox { $LB->delete('1.0','end'); #for (my $i=1; $i<200; $i++) { for my $i (1..200) { $LB->insert('end', $i x 10, "A$i" ); $LB->tag( 'bind', "A$i", '<Button-1>' => sub { selectAccount( +$i) } ); $LB->tag( 'bind', "A$i", '<Double-1>' => sub { markAccount($i +) } ); $LB->insert('end', "\n" ); } } InitializeListBox(); MainLoop;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: problem with TK, tag, passing param with binding, destroying binds
by jsteng (Beadle) on Apr 20, 2018 at 02:15 UTC | |
by tybalt89 (Monsignor) on Apr 20, 2018 at 04:08 UTC | |
by AnomalousMonk (Archbishop) on Apr 20, 2018 at 03:18 UTC | |
by jsteng (Beadle) on Apr 20, 2018 at 05:33 UTC | |
by AnomalousMonk (Archbishop) on Apr 20, 2018 at 15:01 UTC | |
by tybalt89 (Monsignor) on Apr 20, 2018 at 03:12 UTC |