#!/usr/local/bin/perl -w ############################################################### # # helloX.pl - from Steve Lidie, # http://www.perltk.org/articles/Perl_and_the_Tk_Extension.htm # # A simple Tk script to create a button that prints "Hello, world". # Click on the button to terminate the program. # # --- Jim's instructions for running this as an X windows script on bob : # (1) Make sure X is running on your remote machine (your.machine.com) # (2) ssh to bob.marlboro.edu from your remote terminal, as usual. # (3) Test that the Xwindow things are working. From the command line, # xclock -display your.machine.com:0.0 # should display a clock on your remote terminal. If not, then # something about X isn't working, and this script won't work either. # Once X is working, then this script will pop up a window # on your remote machine by typing # ./helloX -display your.machine.com:0.0 # at the bob.marlboro.edu command line prompt. # ################################################################ use Tk; # Define all the Perl/Tk stuff. my $main = MainWindow->new; # Create the main window. # Create a button that'll print to STDOUT and quit the program. my $hello = $main->Button( -text => 'Hello, world.', -command => sub {print STDOUT "Hello, world.\n"; exit;} ); $hello->pack; # Position the button in the window. # Add another text widget into the window. my $comment = $main->Label( -text => ' A simple Perl/Tk example. ' ); $comment->pack; # Display the windows, and handle all the events. MainLoop;