Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Advice on learning Perl and graphics

by tybalt89 (Monsignor)
on Oct 21, 2022 at 21:16 UTC ( [id://11147586]=note: print w/replies, xml ) Need Help??


in reply to Advice on learning Perl and graphics

My vote is for Perl/Tk (mainly because I still use it a lot). It uses the basic widget callback paradigm which applies to many other systems, and for that reason it's reasonable to learn.

And since one of my philosophies is "always show code", here's a very simple drawing program in Perl/Tk:

#!/usr/bin/perl use strict; use warnings; use Tk; my @lines; my $mw = MainWindow->new; my $c = $mw->Canvas(-width => 900, -height => 900,)->pack(-side => 'bo +ttom'); $mw->Button(-text => $_->[0], -command => $_->[1])->pack(-side => 'rig +ht') for [ Exit => sub { $mw->destroy } ], [ 'Clear Last' => sub { pop @lines; draw() } ], [ 'Clear All' => sub { @lines = (); draw() } ]; $c->Tk::bind('<1>' => sub { push @lines, [ &xy ]; $c->Tk::bind('<Motion>' => sub { push @{ $lines[-1] }, &xy; draw() } + ); } ); $c->Tk::bind('<ButtonRelease-1>' => sub { $c->Tk::bind('<Motion>' => ' +') } ); MainLoop; sub xy { $_[0]->XEvent->x, $_[0]->XEvent->y } sub draw { $c->delete('pen'); @$_ >= 4 and $c->createLine(@$_, -smooth => 1, -width => 5, -tag => +'pen') for @lines; }

Maybe others can post a comparable program in other GUIs for comparison purposes.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11147586]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (8)
As of 2024-04-24 09:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found