Search the FAQ Archives

3 - A - B - C - D - E - F - G - H - I - J - K - L - M
N - O - P - Q - R - S - T - U - V - W - X - Y - Z - Internet FAQ Archives FAQ part5 of 3

( Part0 - Part1 - Part2 - Part3 - Part4 )
[ Usenet FAQs | Web FAQs | Documents | RFC Index | Neighborhoods ]
Summary: Frequently Asked Questions.
Archive-name: perl-faq/ptk-faq/part5
Posting-Frequency: monthly
Last-modified: Date: Sat May 31 16:48:37 1997
Version: 1.00_07

See reader questions & answers on this topic! - Help others by sharing your knowledge
URL (Hypertext-split):
URL (Plaintext):

Perl/Tk FAQ part 5 of 5 - Miscellany       

 19. How do I "clear the screen"? 
 What screen are you trying to clear? 
 If you are trying to clear a tty (e.g. xterm) screen then try either of the
 following within your script: 
     system "clear";
     print `clear`;
 (where the choice between these two depends on the rest of the script: the first
 is fast - but proceeds via fork and may not occur at exactly the time that you
 want it to in the script). 
 David and Rachel Weintraub <> recommend using the
 old p4 library. You might also consider the perl 5 equivalents: (especially the Term::Control module),,, PV. 
 Returning to X-windows and perl/Tk: if you are trying to eliminate a 
 TopLevel or a MainWindow then try: 
     $main -> destroy;
 If you would rather not destroy then try: 
     $main->withdraw;    # remove
     $main->deiconify;   # put back
 If $w is a sub-window (sub-widget) then 
     $w->pack('forget'); # remove if packed (newer Tk-b9.01++) 
     $w->packForget;     # remove if packed (older versions)
     $w->pack(...);      # put back
 There are also ways to call low level C-ish versions: 
 but that is for special purposes only.... 
 If you are trying to erase an $item on a Canvas then try: 
 (Thanks to the post by <> which extended this
 answer considerably.) 
 20. Is there a way to have an X application draw inside a perl/Tk window? 
 (This question was posed by Andrew Allen March 19 1997): 
 No not yet. But according to Nick Ing-Simmons: 
 If app. can take XID of window to draw on it should be doable now,
 but if Tk has to pro-actively watch for creation of app's 'top level',
 and "capture" it is more tricky.
 21. Is there a version for Microsoft Windows(tm)? 
 Yes. Tk402.000 is in alpha release at this time (Spring 1997) and builds with
 perl 5.004, nmake, and Visual C++ on at least Windows NT. 
 22. Are there any international font packages for perl/Tk? 
 In principle you may specify the -font configuration option on all your 
 Button, Entry, Label, Message, etc. widgets. In addition to the Unix
 programs xfontsel and xlsfonts you may find xset useful for determining and/or
 specifying fonts - especially international ones. 
 KOBAYASI Hiroaki <> has converted the Tcl/Tk
 "japanization" by <> so that it may be used with perl/Tk. It
 is presently available (the current README file is in Japanese) from the
 following ftp site:
 >From the author's own description: 
 Currently, the "japanization patch for perl/Tk" enables:
   [1] To show kanji & ASCII (by choosen kanji-font) in every widget.
   [2] To edit kanji (double width of ASCII) correctly in Text & Entry.
   [3] To support of Kanji Input method. (tkKinput.c)
   [4] Automatic kanji-code-detection & conversion with 'insert/get'.
       Supports: "JIS(Japanese Industrial Standard)", "MS-KANJI", "EUC".
 & the patch lacks:
   [5] by manual Kanji-code conversion. (JIS <=> MS-KANJI <=> EUC)
   [6] 'Good' interface to specify kanji-code used in internal. (tkWStr.c)
   [7] Documentation in English about [1-6].
       # but, since interface-change is suspected in near future, 
       # documenting them is ...
 I thought that[5-7] was not enough for world-people, but already worth
 for natives. So I announced it on "fj.lang.perl".
 23. Are there any other ways to create event based interfaces from perl? 
 Yes. A short list would have to mention these for X: 
 For perl 4: 
 For perl 5:
    Sx (uses Athena & Xlib), Motif (uses Motif & Xt), Fresco (post
    X11R6.1). This perl extension was originally written by Dominic
    Giampaolo, but was re-written for Sx by Frederic Chauveau. The code
    is available from CPAN in the authors/Frederic_Chauveau/
    There is an X11::* hierarchy of perl->X modules under development
    and available from CPAN.
    For hooking into the C++ Qt library there is Ashley Winters' PerlQt. 
 The Perl 5 Module List has a listing of User Interfaces (Character and
 There is also Malcolm Beattie's Tkperl (which is largely incompatible with
 Further information on X interfaces to Perl is provided in the perl FAQ. 
 For primarily graphics (with some user interface programming) there is also
 an OpenGL Perl Module of particular interest to anyone with either OpenGL
 or the MesaGL library. This package allows for compact perl VRML scripting.
 If you would like to see the OpenGL network X demonstration go to:
 (to run that demo one needs only a forms capable web browser and a local
 X-server, hence running Lynx on Windows 95 with eXodus is perfectly OK.)
 If you would like to see the OpenGL netscape plugin go to:
 For perl generation of images see the question in this FAQ on graphics
 The X window system is not the only means of doing event based user
 interface programming in perl. There is, for example, William Setzer's Curses
 modules for perl 5 too. 
 For Active X scripting on Windows try the PerlScript package from
 which will work with Internet Explorer, Internet Information Server, as well
 as the wscript command line interface. 
 24. Where can I get more information on graphics (modules|scripts)? 
 To generate server side push animation in perl please see the perl cgi FAQ. To
 generate GIF89a loops from a collection of stills visit the Gifloop page at
 For other animation from perl see the OpenGL module listed below (it does
 3D VRML animation). 
 There are several graphics modules in perl already available - with several
 more still under development. Among them:
    The perl module is a perl interface to the C code of a similar
    name and was written by Lincoln Stein. It allows for the generation of
    GIF (Graphics Inline Format) images from within a perl script. The
    module itself is available from any CPAN ftp site, and Lincoln
    maintains an informational web page at:
    The gd/ module is similar to (generates GIFs using
    gd.c) and was written by Roberto Cecchini who maintains a web page
    for his module at:
    The module was written by Nick Ing-Simmons expressly
    for use with the Tk family of modules. It is distributed on CPAN in the 
    authors/id/NI-S/ directories as a Tk-JPEG-*.tar.gz file. 
 Open/Mesa-GL Perl Module
    This module can use the OpenGL lib on computers that have it
    (available for SGI, AIX, Linux), or with the MesaGL package (which
    allegedly runs a little slower but does not require the X accelerator
    hardware that OpenGL does). This package supports relatively easy
    graphics programming, 3D shading, etc. Very cool stuff! The URL for
    the OpenGL perl module is:
    If you will be interfacing to the PGPLOT FORTRAN language
    routines you might consider Karl Glazebrook's PGPERL which has an
    interactive web demo as well a a web home page at:
 A pgperl/tk script might look like this: 
     use PGPLOT;
     use Tk;
     open(IMG,"test.img");       # Read 128x128 image from binary file 
     read(IMG, $img, 4*128*128); # data - list of 4 byte float [C type]
     close(IMG);                 # stored as perl string.
     pggray($img,128,128,1,128,1,128,1,0,*tr); # pg-Plot it
     my $main = new MainWindow;
     $main ->Label(-text => 'Main')->pack;
     $main -> Photo('IMG', -file => "test.gif");
     my $l = $main->Label('-image' => 'IMG')->pack;
     $main->Button(-text => 'close',
                   -command => sub{destroy $main}
                   )->pack(-side => 'left');
     $main->Button(-text => 'exit',
                   -command => [sub{exit}]
                   )->pack(-side => 'right');
     MainLoop;                    # pg-tk plot it
    perlDL or PDL is the Perl Data Language for fast manipulation of
    large arrays - such as those that often occur in image
    processing/analysis/creation (or scientific data sets). PDL is also by 
    Karl Glazebrook. This is a very hot module full of programmer
    convenience features such as overloaded operators etc. There is a
    mailing list and a home page for this module:
 Another tip: it is quite useful to have the PBMPlus/NetPBM set of graphics
 file interconversion programs if you will be dealing with many graphics file
 formats. There is a Sunsite web server with many graphics utilities including
 netpbm at:
 (Note there are linux binaries as well as source code kits there - also at sunsite
 mirrors.) You might also be interested in some of the graphics file format
 Other programming tools/utilities are of help with graphics. The X11 release
 contains many such tools. There is also The GIMP. Consider also the 
 ImageMagick program. 
 25. Are there any major applications written in perl/Tk? 
 Yes. In fact, there are some interesting perl/Tk applications already available
 Your very own perl/Tk distibution:
 The following programs may be found in your own Tk#/ directory (you
 already have these if you have the Tk extension to perl)*: 
 program        description
 pfm            perl file manager - cute iconic front to emacs
 ptknews        a GUI perl newsreader - a work in progress.
 tkpsh          perl/Tk equivalent of the Tcl/Tk wish shell.
 toyedit        a Text widget editor.
 The following programs may be found either in your demos directory (consult
 the README file there for fuller descriptions) or in your perl/bin install
 program        description
 browse         Simple file browser front end for emacs.
 color_editor   Front end to Tk::ColorEditor
                allows RGB, CMY, and HSV color cube manipulation
                (based on tcolor.tcl).
 ixset          GUI front end to xset - for terminal settings.
 pgs            Perl front end to Ghostscript (viewing PostScript(c) files).
 rmt            perl/Tk 
                "development shell/remote control application"
                You can launch or talk to other perl/Tk apps with rmt.
 rolodex        Like the Tcl/Tk app of the same name.
                Requires editing for personal use.
 timer          Stopwatch-like seconds timer.
 tkpod          The perl gui pod viewer (like xman).
 tkweb          The perl "Rough and Ready" web browser.
 *Peter Prymmer recently posted a means by which one can integrate any or all
 of these GUI applications into one's own X-window environment. Here for
 terse illustration is the basic idea behind using an X11R6.1 .mwmrc.m4
 resource file for making a Menu (make sure the applications are in your
 PATH or specify a full path to each one as needed): 
 Menu Perl
     "Perl"          f.title
     "editor"        f.exec "toy_edit &"
     "tkemacs"       f.exec "browse &"
     "manual"        f.exec "tkpod perl.pod &"
     "the web"       f.exec "tkweb &"
     "news"          f.exec "ptknews &"
     "pgs"           f.exec "pgs &"
     "stop watch"    f.exec "timer &"
 # We bind it so that left mouse button when pressed while 
 # over the root or background pops up with this Perl menu:
 Buttons DefaultButtonBindings
     <Btn1Down>      root  Commands
     # etc.
 Buttons ExplicitButtonBindings
     <Btn1Down>      root  Commands
     # etc.
 Other perl/Tk application distributors:
    an xbiff like mailbox watcher. Available from 
    Was announced by Gregg Helt <> recently.
    See the home page at:
    Source at: 
    KOBAYASI Hiroaki's EVA is a sophisticated wish like perl/Tk
    "shell". It is available from:*.tar.gz 
    Stephen Lidie's very useful arbitrary function Plot Program, was
    featured in the premier issue of The Perl Journal and is available on
    the web at: 
    Yet another Lidie creation. This one hails from Issue 2 of The Perl
 neko (et al.)
    In the third issue of The Perl Journal Stephen Lidie makes creative
    use of approaches to event timing from perl/Tk. neko is one axample. 
    Is an integrated front end to the fvwm window manager that makes use
    of Perl/Tk. See the web page at for more
    The original 8 line wonder by Jon Orwant. Pick it up (and modify it)
    (Please note: www is for amusement, the more serious perl/Tk browser
    - tkweb - is distributed with perl/Tk and it is "only" 60 lines long!.) 
 ptkclock & ptkmines
    From the generous software archive of Jason Smith at RPI. 
    This application was written by Nem Schlecht. 
 Be sure to also check the newsgroups, 
 comp.lang.perl.announce, comp.lang.perl.misc, and comp.lang.perl.modules, as
 well as the mailing list archive for more Perl/Tk program and package
 26. What is the history of pTk and perl/Tk? 
 This list is only slowly coming together. Please forgive any absences. 
  o tkperl5a5 is announced Thu, 20 Oct 1994 14:44:23 +0000 (BST) 
 This project is unrelated to the one which is adding usersubs to
 perl4 to get access to Tk via Tcl. Often, postings on comp.lang.perl
 just say "tkperl" without saying which one is meant. They are two
 totally different kettles of fish.
 --Malcolm (Beattie)
  o Fri, 25 Nov 94 14:29:53 GMT Nick Ing-Simmons is working on what
    will be known as "nTk" eventually. 
  o Mon, 12 Dec 94 08:56:36 GMT, Nick Ing-Simmons reports: 
 I have a re-port of ext/Tk nearly ready for alpha.
 It builds its own "pTk" library from sources semi-automatically derived
 from Tk3.6.  There is no Tcl library at all. 
 Would anyone like to assist me in testing it?
  o nTk-a2 announced Fri, 16 Dec 1994 10:59:36 -0500 
  o nTk-a3 announced Mon, 19 Dec 1994 18:03:27 -0500 
  o nTk-a5 announced Fri, 23 Dec 1994 10:18:16 -0500 (last to use Tk 3.6
  o nTk-a6 first to use Tk 4.0 (?) 
  o nTk-a7 announced Fri, 13 Jan 1995 10:55:27 -0500 
  o nTk-a8 has appeared before Tue, 17 Jan 95 09:04:33 GMT 
  o nTk-a9 has appeared before Wed, 18 Jan 95 19:25:10 GMT 
  o nTk-a10 announced Tue, 24 Jan 1995 14:32:02 -0500 
  o nTk-a11 announced Tue, 31 Jan 95 19:05:32 GMT 
  o Malcolm Beattie suggests the nTk -> Tk name change, Larry Wall 
  o nTk-a12 announced Thu, 16 Feb 1995 09:12:26 -0500 
  o Nick Ing-Simmons calls for a new mail list Thu, 16 Feb 95 14:13:55
  o Tk-a13 announced Wed, 1 Mar 1995 11:38:15 -0500 (Name has
    changed from "nTk") 
  o Tk-b1 announced Tue, 14 Mar 95 16:58:40 GMT 
  o Tk-b2 announced Wed, 29 Mar 95 15:52:44 BST 
  o Tk-b3 announced Fri, 31 Mar 95 16:54:54 BST 
  o Tk-b4 announced Fri, 12 May 1995 11:45:32 -0400 EST 
  o Tk-b5 announced Mon, 26 Jun 95 17:14:06 BST 
  o Tk-b6 announced Fri, 21 Jul 95 15:42:35 BST 
  o Tk-b7 announced Fri, 28 Jul 95 15:16:02 BST 
  o Tk-b8 announced Wed, 16 Aug 95 12:34:05 BST 
  o an RFD (Request For Discussion) for a new usenet group is circulated by Jon Orwant Fri, 4 Aug 1995 08:29:46
  o unmoderated newsgroup passes by a vote of 352 to 18
    with 1 abstention in an announcement made Mon, 9 Oct 1995 10:13:17
    -0400 (EDT). The new group makes its appearance at news-servers
    roughly 18 October 1995. 
  o Tk-b9.01 announced Wed, 20 Dec 95 10:06:47 GMT. 
  o Tk-b10 announced Sat, 23 Mar 96 17:16:27 GMT. 
  o Tk-b11 announced Mon, 1 Apr 96 16:44:48 GMT. 
  o Tk-b11.01 announced Wed, 3 Apr 96 17:48:09 GMT. 
  o Tk-b11.02 announced 10 Apr 96 12:52:28 GMT. 
  o Tk-b12 announced 28 August 1996. 
  o Tk400.200 announced 6 September 1996. 
  o Tk400.201 announced Fall 1996. 
  o Tk400.202 announced Late Fall 1996. 
  o Tk402.000 (alpha release for Windows) announced May 1997. 
 27. What can we expect the future to hold? 
 With the production release of Tk400.202 and the alpha release of Tk402.000
 the future of this code looks quite bright. (Hopefully the FAQ maintainer will
 manage to keep up :-). 
 28. How do I obtain the latest version of this FAQ? 
 On the world wide web
 Hypertext (split by question):
 Hypertext (whole thing - may be too large for some browsers, but is amenable
 to searching):
 As far as I know any other source may be slightly out of date with respect to
 those two web URLs. Nevertheless, there are many other places to retrieve
 this FAQ from, in a variety of formats, such as: 
 Plaintext (whole):
 Plaintext (multi-part):
 or gzipped PostScript(c) (about 60 US 8.5"x11" pages):
 or gzipped PostScript(c) (about 60 A4 pages):
 29. Acknowledgements & maintainer. 
 The Perl/Tk extension to the Perl programming language is copyrighted by its
 author Nick Ing-Simmons <> whose Tk400.202/COPYING
 file reads as follows: 
 Copyright (c) 1995-1996 Nick Ing-Simmons. All rights reserved.
 This package is free software; you can redistribute it and/or
 modify it under the same terms as Perl itself, with the exception
 of the files in the pTk sub-directory which have separate terms
 derived from those of the orignal Tk4.0 sources and/or Tix.
 See pTk/license.terms for details of this Tk license, 
 and pTk/Tix.license for the Tix license.
 Especial thanks to:
 Nick Ing-Simmons for writing perl/Tk.
 Dan Riley <> for outstanding networking and
 countless other tough jobs.
 Malcolm Beattie for tkperl.
 An anonymous poster for writing the initial "pseudo-FAQ"
 that got this started.
 Larry Wall for writing extensible Perl 5 & John Ousterhout for writing Tk 4.
 Tom Christiansen and Stephen P. Potter for writing and maintaining excellent
 perl documentation, and general doc help.
 Jon Orwant <> for organizing the
 Usenet newsgroup.
 Alan Stange & Tom Schlagel for the hypermail archive, the ftp & e-mail
 distribution of the FAQ, etc.
 Achim Bohnet for an excellent searchable hypermail archive.
 Ilya Zakharevich <> for great perl/Tk pod docs.
 KOBAYASI Hiroaki <> for great perl/Tk scripts.
 William J. Middleton <> for archive help.
 Ioi Kim Lam for Tix.
 Larry Virden for cross-posting the Tcl FAQ, as well as editorial comments on
 this one.
 Don Libes <> for lucid informative conversations on Tcl
 & Expect.
 Terry Carroll <> for valuable usage advice.
 Nancy Walsh for great bibliographic help.
 In addition, this FAQ has benefitted from the contributions of many people
 all over the net to whom I am quite grateful.
 I am:
 Peter Prymmer
 Wilson Synchrotron Laboratory
 Cornell University
 Ithaca, NY 14853
 Hypertext (split by question) FAQ:
 Hypertext whole (very big) FAQ:
 Plaintext FAQ:
 Plaintext multi-part FAQ:[0..5].txt
 Reference manual:

User Contributions:

Comment about this article, ask questions, or add new information about this topic:


Part0 - Part1 - Part2 - Part3 - Part4

[ Usenet FAQs | Web FAQs | Documents | RFC Index ]

Send corrections/additions to the FAQ Maintainer:

Last Update March 27 2014 @ 02:12 PM