Try the Tk-Canvas-Point module, by Slaven Rezic. It is mostly a proof-of-concept trial module, and not gauranteed to do what you want. Try this sample code. It makes little circles, but that is just so you can see them, it will do a single pixel.
#!/usr/bin/perl -w use Tk; use Tk::Canvas::Point; use strict; #adapted from Tk::CanvasPoint by Slaven Rezic my $mw = MainWindow->new; my $c = $mw->Canvas->pack(-fill => "both", -expand => 1); $c->bind("all", "<1>" => sub { my($c) = @_; my(@tags) = $c->gettags("current"); warn "Tags of current item: @tags\n"; my(@coords) = $c->coords("current"); warn "Coords of current item: @coords\n"; }); my $tag = ""; $c->bind("all", "<Enter>" => sub { my($c) = @_; $tag = ($c->gettags("current"))[0]; }); $c->bind("all", "<Leave>" => sub { my($c) = @_; $tag = ""; }); my @p; $mw->update; create_points(); $mw->update; for (1..10) { delete_last_point(); $mw->update; } postscript(0); $mw->update; my $f = $mw->Frame->pack; $mw->Button(-text => "Create points", -command => sub { create_points() } )->pack(-side => "left"); $mw->Button(-text => "Delete last point", -command => sub { delete_last_point() }, )->pack(-side => "left"); $mw->Button(-text => "PS", -command => sub { postscript(1) })->pack(-side => "left"); $mw->Label(-width => 10, -textvariable => \$tag)->pack; MainLoop; sub create_points { for(1..100) { my $width = rand(20); push @p, $c->create('point', rand($c->width),rand($c->height), -width => $width, -activefill => "white", -activewidth => $width+2, -fill => [qw(blue red green yellow black white)]->[ran +d(5)], -tags => "tag".int(rand(100)), ); } } sub delete_last_point { $c->delete(pop @p) if @p; } sub postscript { my $display = shift; my $f = "test.$$.ps"; $c->postscript(-file => $f); open(F, $f) or die $!; my($firstline) = <F>; close F; system("gv $f &") if $display; } __END__
Otherwise, you need to go to SDL to do this. SDL just "blits" stuff to the screen, and there is no object-item associated with it. That is why it is used for games, it can be alot faster. To erase what you previously blited, you write the background color to it's location. Tk is designed to have items, that you can tag, and have mouse and key bindings to it.

I'm not really a human, but I play one on earth. Cogito ergo sum a bum

In reply to Re^4: Problems with Tk freezing by zentara
in thread Problems with Tk freezing by wulvrine

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.