comp.lang.perl.tk FAQ part5 of 3

0 views
Skip to first unread message

Peter Prymmer

unread,
Jun 1, 1997, 3:00:00 AM6/1/97
to

Summary: comp.lang.perl.tk Frequently Asked Questions.
Archive-name: perl-faq/ptk-faq/part5
Posting-Frequency: monthly
Last-modified: Date: Sat May 31 16:48:37 1997
URL: http://w4.lns.cornell.edu/~pvhp/ptk/ptkFAQ.html
Version: 1.00_07

URL (Hypertext-split): http://w4.lns.cornell.edu/~pvhp/ptk/ptkTOC.html
URL (Plaintext): http://w4.lns.cornell.edu/~pvhp/ptk/ptkFAQ.txt
Image-supplement: http://w4.lns.cornell.edu/~pvhp/ptk/ptkIMG.html
ftp-Archive: ftp://ftp.ccd.bnl.gov/pub/ptk/ptkFAQ.txt
ftp-Archive: ftp://rtfm.mit.edu/pub/usenet/perl-faq/ptk-faq/
e-mail-Archive: ptk...@pubweb.bnl.gov

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";
or
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 <dav...@cnj.digex.net> recommend using the
old termcap.pl p4 library. You might also consider the perl 5 equivalents:
Term.pm (especially the Term::Control module), Curses.pm,
Perlmenu.pm, 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:

$w->UnmapWindow;

but that is for special purposes only....

If you are trying to erase an $item on a Canvas then try:

delete($item);

(Thanks to the post by <a90...@pluto.tiuk.ti.com> 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 <koba...@sowa.is.uec.ac.jp> has converted the Tcl/Tk
"japanization" by <nisi...@sra.co.jp> 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:

ftp://ftp.sowa.is.uec.ac.jp/pub/Lang/perl5/Tk/

>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:
WAFE, STDWIN
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/
directory.

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
Graphical).

There is also Malcolm Beattie's Tkperl (which is largely incompatible with
perl/Tk).

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:

http://www.arc.ab.ca/vr/opengl/examples/

(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:

http://www.arc.ab.ca/vr/opengl/plugin.html

For perl generation of images see the question in this FAQ on graphics
modules.

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

http://www.activeware.com/

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

http://www.homecom.com/gifanim.html

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:

GD.pm
The GD.pm 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:

http://www-genome.wi.mit.edu/ftp/pub/software/WWW/GD.html

gd/GIF.pm
The gd/GIF.pm module is similar to GD.pm (generates GIFs using
gd.c) and was written by Roberto Cecchini who maintains a web page
for his module at:

http://www.fi.infn.it/pub/perl/GIF/

JPEG.pm
The JPEG.pm 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:

http://www.arc.ab.ca/vr/opengl/

PGPERL
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:

http://www.aao.gov.au/local/www/kgb/pgperl.html

A pgperl/tk script might look like this:

#!/usr/bin/perl
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.
pgbegin(0,'test.gif/gif',1,1);
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
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:

http://www.aao.gov.au/local/www/kgb/perldl/
perldl-...@jach.hawaii.edu
http://www.rosat.mpe-garching.mpg.de/mailing-lists/perldl/

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:

http://sunsite.unc.edu/pub/Linux/apps/graphics/convert/INDEX.short.html

(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
specifications.

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
from:

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
directory:


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 http://www.perl.com/perl/ &"
"news" f.exec "ptknews comp.lang.perl.tk &"
"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 f.menu Commands
# etc.
}
Buttons ExplicitButtonBindings
{
<Btn1Down> root f.menu Commands
# etc.
}

Other perl/Tk application distributors:
---------------------------------------

ptkb.pl
an xbiff like mailbox watcher. Available from
ftp://ftp.wpi.edu/perl5/pTk-Modules/ptkb.pl
bioTkperl
Was announced by Gregg Helt <gr...@fruitfly.berkeley.edu> recently.
See the home page at: http://www.cbil.upenn.edu/~dsearls/bioTk.html.
Source at: ftp://fruitfly.berkeley.edu/pub/bioTk/bioTkperl0.8.tar.gz
EVA
KOBAYASI Hiroaki's EVA is a sophisticated wish like perl/Tk
"shell". It is available from:
ftp://ftp.sowa.is.uec.ac.jp/pub/Lang/perl5/Tk/eva-*.tar.gz
plop
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: http://tpj.com/tpj/programs/Vol_1_Issue_1_Tk/plop
modo
Yet another Lidie creation. This one hails from Issue 2 of The Perl
Journal
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.
Workspace
Is an integrated front end to the fvwm window manager that makes use
of Perl/Tk. See the web page at http://www.mirai.com/wks/ for more
information.
www
The original 8 line wonder by Jon Orwant. Pick it up (and modify it)
from: http://sun20.ccd.bnl.gov/~ptk/archive/ptk.1995.08/0411.html.
(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.
XCricket
This application was written by Nem Schlecht.

Be sure to also check the newsgroups comp.lang.perl.tk,
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
announcements.

______________________________________________________________________



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)

NOTE
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
concurs
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
GMT
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
comp.lang.perl.tk is circulated by Jon Orwant Fri, 4 Aug 1995 08:29:46
-0400
o unmoderated newsgroup comp.lang.perl.tk 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):
http://w4.lns.cornell.edu/~pvhp/ptk/ptkTOC.html
Hypertext (whole thing - may be too large for some browsers, but is amenable
to searching):
http://w4.lns.cornell.edu/~pvhp/ptk/ptkFAQ.html
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):
http://w4.lns.cornell.edu/~pvhp/ptk/ptkFAQ.txt
Plaintext (multi-part):
http://w4.lns.cornell.edu/~pvhp/ptk/ptkFAQ0.txt
http://w4.lns.cornell.edu/~pvhp/ptk/ptkFAQ1.txt
http://w4.lns.cornell.edu/~pvhp/ptk/ptkFAQ2.txt
http://w4.lns.cornell.edu/~pvhp/ptk/ptkFAQ3.txt
http://w4.lns.cornell.edu/~pvhp/ptk/ptkFAQ4.txt
http://w4.lns.cornell.edu/~pvhp/ptk/ptkFAQ5.txt
or gzipped PostScript(c) (about 60 US 8.5"x11" pages):
http://w4.lns.cornell.edu/~pvhp/ptk/ptkFAQ.US.ps.gz
or gzipped PostScript(c) (about 60 A4 pages):
http://w4.lns.cornell.edu/~pvhp/ptk/ptkFAQ.A4.ps.gz

______________________________________________________________________



29. Acknowledgements & maintainer.

The Perl/Tk extension to the Perl programming language is copyrighted by its
author Nick Ing-Simmons <n...@tiuk.ti.com> 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.

IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE
IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
MODIFICATIONS.

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 <d...@mail.lns.cornell.edu> for outstanding networking and
countless other tough jobs.
Malcolm Beattie for tkperl.
An anonymous comp.lang.perl.tk 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 <orw...@media.mit.edu> for organizing the comp.lang.perl.tk
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 <il...@math.ohio-state.edu> for great perl/Tk pod docs.
KOBAYASI Hiroaki <koba...@sowa.is.uec.ac.jp> for great perl/Tk scripts.
William J. Middleton <w...@best.com> 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 <li...@cme.nist.gov> for lucid informative conversations on Tcl
& Expect.
Terry Carroll <car...@tjc.com> 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

pv...@lns62.lns.cornell.edu

______________________________________________________________________


Hypertext (split by question) FAQ:
http://w4.lns.cornell.edu/~pvhp/ptk/ptkTOC.html
Hypertext whole (very big) FAQ:
http://w4.lns.cornell.edu/~pvhp/ptk/ptkFAQ.html
Plaintext FAQ:
http://w4.lns.cornell.edu/~pvhp/ptk/ptkFAQ.txt
Plaintext multi-part FAQ:
http://w4.lns.cornell.edu/~pvhp/ptk/ptkFAQ[0..5].txt
Image-supplement:
http://w4.lns.cornell.edu/~pvhp/ptk/ptkIMG.html
Reference manual:
http://w4.lns.cornell.edu/~pvhp/ptk/doc/

Reply all
Reply to author
Forward
0 new messages