Well I just happened to have this Gtk2 example handy, that uses it's built-in Ruler widget. You might find it interesting. Just run it, it will auto save when closing.

Also the Gtkdatabox widget has rulers and criss-crossing gridlines. The only drawback is a perl port is only available for the earliest versions (< 0.30 ) See example screenshots

I suppose the advantage of using it, is the ease of making modifications to scales.

#!/usr/bin/perl -w # this example came from Stephen Wilhelm's gtk-perl tutorial, # http://personal.riverusers.com/~swilhelm/gtkperl-tutorial/ # which was derived from the original gtk tutorial, # http://gtk.org/tutorial/ # # ported to gtk2-perl (which wan't hard) by muppet # save function added by zentara use strict; use Glib qw/FALSE/; use Gtk2 -init; my $xsize = 600; my $ysize = 400; my $window; my $table; my $area; my $hrule; my $vrule; # Create the window $window = new Gtk2::Window ( "toplevel" ); $window->signal_connect ("delete_event", sub { &screenshot; exit; }); $window->set_border_width (10); # Create a table for placing the ruler and the drawing area $table = new Gtk2::Table (3, 2, FALSE); $window->add ($table); # Create the drawing area. $area = new Gtk2::DrawingArea; $area->size ($xsize, $ysize); $table->attach ($area, 1, 2, 1, 2, ['expand', 'fill'], ['expand', 'fill'], 0, 0); $area->set_events (['pointer_motion_mask', 'pointer_motion_hint_mask'] +); # The horizontal ruler goes on top. As the mouse moves across the # drawing area, a motion_notify_event event is propagated to the # ruler so that the ruler can update itself properly. $hrule = new Gtk2::HRuler; $hrule->set_metric ('pixels'); $hrule->set_range (7, 13, 0, 20); $area->signal_connect (motion_notify_event => sub { $hrule->event ($_[ +1]) }); $table->attach ($hrule, 1, 2, 0, 1, ['expand', 'shrink', 'fill'], [], 0, 0 ); # The vertical ruler goes on the left. As the mouse moves across the # drawing area, a motion_notify_event event is propagated to the # ruler so that the ruler can update itself properly. $vrule = new Gtk2::VRuler; $vrule->set_metric ('pixels'); $vrule->set_range (0, $ysize, 10, $ysize); $area->signal_connect (motion_notify_event => sub { $vrule->event ($_[ +1]) }); $table->attach ($vrule, 0, 1, 1, 2, [], ['fill', 'expand', 'shrink'], 0, 0 ); # Now show everything $window->show_all; Gtk2->main; ##################################### sub delete_event { Gtk2->main_quit; return FALSE; } ##################################### sub screenshot{ #we are going to save only the graph area my $gdkwindow = $window->window; my ($width, $height) = $gdkwindow->get_size; # create blank pixbuf to hold the image my $gdkpixbuf = Gtk2::Gdk::Pixbuf->new ('rgb', 0, 8, $width, $height); $gdkpixbuf->get_from_drawable ($gdkwindow, undef, 0, 0, 0, 0, $width, $height); #only jpeg and png is supported !!!! it's 'jpeg', not 'jpg' $gdkpixbuf->save ("$0.jpg", 'jpeg', quality => 100); return FALSE; }

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

In reply to Re: Making ruled paper by zentara
in thread Making ruled paper by John M. Dlugosz

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.