Summary: comp.lang.perl.tk Frequently Asked Questions. Archive-name: perl-faq/ptk-faq/part0 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: ptkfaq@pubweb.bnl.gov Perl/Tk FAQ part 0 of 5 - Introduction ************************************** The Perl/Tk extension to the Perl programming language is copyrighted by its author Nick Ing-Simmons <nik@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. This compilation of Frequently Asked Questions & answers (FAQ) is intended to answer several of the first (and largely more basic) questions posted to the comp.lang.perl.tk newsgroup and the ptk mailing list. This document concerns itself with the Perl/Tk programming language (or, if you prefer, the Tk extension to Perl). Please be aware that this is not the Perl FAQ, this is not the Tcl FAQ, nor is this the Tcl/Tk FAQ. Each of those other documents is a useful source of information for Perl/Tk programmers but they are completely different from this one. This is a dynamic document and contributions, clarifications, and corrections are most welcome! Please send e-mail to <pvhp@lns62.lns.cornell.edu> or to <pvhp@forte.com>. With your help this document will get better (-: perl/Tk FAQ 1. What is perl/Tk? 2. What is the difference between perl/Tk and Tkperl? 3. Do I need Tcl/Tk in order to build Perl/Tk? 4. Where is it? 5. What/Where is CPAN? 6. How do I build it? 7. Where is the Documentation? 8. How do I write scripts in perl/Tk? 9. What widget types are available under perl/Tk? 10. How do I get widget X to do Y ? 1. How do I get a Button to call a Perl subroutine? 2. How do I get a Button to actively change under my mouse pointer? 3. How do I arrange the layout of my widgets? 4. How do I get a Popup to popup? 5. How do I bind keyboard keys? 6. How do I add bindings? 7. How do I bind the action of a slider (sic) to ... ? 8. How do I configure a Scrollbar to scroll multiple widgets? 9. How do I display a bitmap? 10. How do I display an image? 11. What Image types are available? 12. Is there any way to have more than one Listbox contain a selection? 13. How do I select a range of tags in a Text widget? 14. How do I group Radiobuttons together? 15. How do I specify fonts? 16. How do I get the entry in an Entry? 17. How do I hide a password Entry? 18. How do I limit an Entry's insertion width? 19. How do I obtain Menus that do not tear off? 11. How do I get a Canvas to ... ? 1. Display a bitmap? 2. Erase a display? 3. Display an Image? 4. What things can be created on a Canvas? 5. How do I redraw a line on a Canvas? 6. How do I use the Canvas as a geometry manager? 7. How do I get a Canvas to output PostScript(c)? 8. How do I get a PostScript(c) output of a Canvas w/ widgets? 9. How do I get the size of a Canvas? After a re-size? 10. How do I bind different actions to different areas of the same Canvas? 12. Common Problems. 1. What do the ->, => and :: symbols mean? 2. What happened to the ampersands &? 3. What happened to the quotation marks? 4. Must I use "my" on all my variables? 5. Is there a way to find out what is in my perl/Tk "PATH"? 6. What is the difference between use and require? 7. How do I change the cursor/color? 8. How do I ring the bell? 9. How do I determine the version of perl/Tk that I am running? 10. How do I call perl from C? 11. How do I call Tcl code from perl/Tk? 13. What are some of the primary differences between Tcl/Tk and Perl/Tk? 14. How do I install new scripts | modules | extensions? 15. How do I write new modules? 16. Composite Widgets. 1. How do I get a Dialog box? 2. Is there a file selector? 3. Is there a color editor? 4. Is there a round Scale? 5. Is there something equivalent to tkerror? 6. Are there Tables? 17. Programming/development tools. 1. Is there a Tcl/Tk to perl/Tk translator? 2. Is there something equivalent to wish in perl/Tk? 3. Is there a debugger specifically for perl/Tk? 4. Is there a GUI builder in perl/Tk? 18. Processes & Inter-Process Communication under Perl/Tk. 1. How does one get Perl/Tk to act on events that are not coming from X? 2. Is there a send and do I need xauth? 3. How can I do animations using after? 4. How do I update widgets while waiting for other processes to complete? 5. How do you fork on System V (HP)? 19. How do I "clear the screen"? 20. Is there a way to have an X application draw inside a perl/Tk window? 21. Is there a version for Microsoft Windows(tm)? 22. Are there any international font packages for perl/Tk? 23. Are there any other ways to create event based interfaces from perl? 24. Where can I get more information on graphics (modules|scripts)? 25. Are there any major applications written in perl/Tk? 26. What is the history of pTk and perl/Tk? 27. What can we expect the future to hold? 28. How do I obtain the latest version of this FAQ? 29. Acknowledgements & maintainer. ______________________________________________________________________ 1. What is perl/Tk? Perl/Tk (also known as pTk or ptk) is a collection of modules and code that attempts to wed the easily configured Tk 4 widget toolkit to the powerful lexigraphic, dynamic memory, I/O, and object-oriented capabilities of Perl 5. In other words, it is an interpreted scripting language for making widgets and programs with Graphical User Interfaces (GUI). (Examples of widget programs [not necessarily written in perl/Tk] include xterm, xclock, most web-browsers, etc.. They are programs with "GUI" interfaces of one sort or another and are subject to the effects of your window manager.) The current release of Perl/Tk is based on "Tk 4.0p3" the widget Toolkit originally associated with the Tcl (Tool command language) scripting language. However, Perl/Tk does not require any of the lexical features/idiosynchrocies of Tcl. Perl/Tk uses perl 5 syntax, grammar, and data structures. The ``Tk400.202'' package is the production release of perl/Tk (corresponding to Tcl/Tk-4.0p3) and was written primarily by Nick Ing-Simmons <Nick.Ing-Simmons@tiuk.ti.com> at Texas Instruments in Northampton, England, to work with the latest version of Larry Wall's ``perl''. Nick Ing-Simmons is currently busy converting the Tcl/Tk-4.1 code to perl callable code as well. An initial alpha release of the effort is available from CPAN as ``Tk402.000''. The pTk code proper is an externally callable Tk toolkit (i.e. a re-write of the Tk 4.0 code that allows easier external linking & calling, especially by perl). Ptk can then be called from Perl 5 via the Tk.pm et al perl glue modules. Hence "ptk" does not necessarily refer to Perl Tk but could be taken to mean portable Tk - given a glue package to another language. The stated goal of the pTk code is to have its library usable from perl, Tcl, LISP, C++, python, etc.. It just so happens that present work is concentrating on perl. Historical note: "ptk" was known as "ntk" before about 11:30 EST 4 May 1995. The perl/Tk language is itself further extensible via the standard perl 5 module mechanism. A number of composite widget and special character extensions to the language have been written using perl modules. ______________________________________________________________________ 2. What is the difference between perl/Tk and Tkperl? TkPerl was originally the name of a (now unsupported) perl 4 package that Malcolm Beattie <mbeattie@sable.ox.ac.uk> at Oxford University gave to his code to wed the Tk X toolkit with Perl. (He has since referred to that package as a different "kettle of fish" from perl/Tk.) Since that beginning Malcolm has also come up with a Tcl module for perl 5 that has a Tcl::Tk module extension. That module allows the use of Tcl within a Perl script (i.e. you must know both languages to get your widgets to work.) If you are interested in that package instead, see the necessary kits for Malcolm Beattie's Tcl/Tk extensions to Perl, which have been distrubuted as Tcl-b#.tar.gz and TclTk-b#.tar.gz files in the authors/id/MICB/ directory at CPAN sites (locations given in a separate question in this FAQ). The name "tkperl" is sometimes applied to the "perl/Tk" or "ptk" package that is the subject of this FAQ. Nick Ing-Simmons prefers "perl/Tk" as the name of the package, with "pTk" or "ptk" as contractions of that name as well as referring to something technically distinct: given the extensibility of the pTk code the "p" could also be taken to mean 'portable' or 'pure' (not to be confused with either the Helsinki University of Technology portTk, nor with Brian Warkentine's Rivet). In this document the code of interest is either referred to as "perl/Tk", "pTk", or "ptk" though the primary focus is on perl/Tk. Warning: do not attempt to install both perl/Tk and Tcl/Tkperl in the same perl installation. The names in the respective modules overlap. In particular the Tcl::Tk module is declared in a Tk.pm file - so a statement like: use Tk; will probably confuse your perl. If you cannot live without either module then install make & maintain separate perls for each and arrange your script writing accordingly (this will not be easy). A more extensive comparison of the differences between the Tkperl and the perl/Tk code is given in the Tcl-perl.pod file that is distributed with perl/Tk (see the following questions for locations). Lastly, it should be mentioned that if you build your perl/Tk statically rather than dynamically it will make a new perl interpreter called tkperl (confusing isn't it? :-). ______________________________________________________________________ 3. Do I need Tcl/Tk in order to build Perl/Tk? Short answer: No not at all. Perl/Tk is completely independent of Tcl/Tk. Longer answer: In order to build Perl/Tk from source code you do need a recent version of perl, the perl/Tk source code kit, a graphical user interface library such as Xlib, a C or C++ compiler, and a make utility. In some rare cases Perl/Tk binaries are distributed for some platforms but that is more the exception than a general rule (see below). If you will be attempting to port Perl/Tk to your platfrom then you might want to consult the document at: http://w4.lns.cornell.edu/~pvhp/ptk/ptkPORT.html where each of these necessities is discussed in a bit more detail. ______________________________________________________________________ 4. Where is it? Source code ----------- Tk400.202 & Tk402.00 the latest production and alpha releases are available from the modules/by-authors/Nick_Ing-Simmons/"> directory on the CPAN. You will need a made and installed perl (Perl 5.004 being an excellent choice), a recent MakeMaker and the Tk4* kit. To obtain all of these (as well as several other modules that sophisticated Tk programs now rely on) visit a CPAN ftp site. CPAN (the Comprehensive Perl Archive Network) and what you need to get from it, is discussed in more detail in the next question. (The rest of this question remains for historical reasons, as well as to point out some non CPAN resources.) Tk-b8: The Tk-b8 kit remains on CPAN since it was compatible with the widely distributed and installed Perl (5.001m) Binaries -------- A pre-compiled binary distribution of Perl5.001m with Tk-b8 for Linux is available from: Australia (please be patient and only try during off hours) ftp://syd.dit.csiro.au/pub/perl5/local/perl5.001m+Tk-b8-Linux-ELF.tar.gz It unpacks into /usr/local. You need to have ELF running and to have the ELF X11 libraries (please be patient and only try during off hours). Binaries for the old Perl 5 & Tk-b6 are available for a number of UNIX platforms courtesy of Thomas Schlagel and Alan Stange of Brookhaven Lab at: USA http://pubweb.bnl.gov/~ptk/ Thomas and Alan have recently (winter 1995-1996) announced that they will update the Tk module version number of the many binaries they distribute. Physical media (mostly source code) ----------------------------------- With traffic jams on today's information superhighway more and more common it is often convenient to be able to snail mail a CD rather than suffer with .tar.gz files that are corrupted by network spottiness. Here is a very brief list of some folks who distribute perl (and hopefully Tk too!) on physical media. This list is not intended to be complete, nor an endorsement of any vendor (I personally do not have the time to check out any of these but have seen that some tend to be out of date by a few months with respect to CPAN so please be careful). See the hypertext version of this document for hyperlinks to the following vendors: Walnut Creek Perl CD This CD specifies a release date. $39.95 Cosmos Engineering Company Offers Linux plus perl for sale on a 1 Gigabyte IDE hard drive for PC-like computers. $279.00 (Fall 1996) Unix Review System Administration A CD that contains "Perl 5.0" (and much other stuff including Tcl/Tk and Expect) for $49.95. Telephone: (800) 444-4881. InfoMagic Mother of Perl This 2 CD set contains perl 5.001 and sells for $35.00 Ready to Run Perl (unknown version) available for sale for many types of Unix and other operating systems. ______________________________________________________________________ 5. What/Where is CPAN? "CPAN" = Comprehensive Perl Archive Network a worldwide collection of anonymous ftp sites for Perl et al (not to be confused with CTAN which is for TeX, nor CSPAN which rarely deals with computer software). The files of particular interest to a perl/Tk programmer would include: o The latest Tk release should be in the modules/by-authors/Nick_Ing-Simmons/ directory at any CPAN ftp site (listed below). o The latest official Perl release should be in the src/ directory in a file called latest.tar.gz at any CPAN ftp site (listed below). o If you need something older or newer than the "latest supported release" try the src/5.0/ directory at any CPAN ftp site (listed below). There are a number of modules available for use with Tk. Among them: o Alan Scheinine's SelFile.pm is in the modules/by-authors/Alan_Scheinine/ directory at any CPAN ftp site (listed below). o Guy Decoux's BLT_Table geometry manager is in the modules/by-authors/id/GUYDX/ directory at any CPAN ftp site (listed below). o Ilya Zakharevich's eText plug in replacement for the Text widget is in the modules/by-authors/id/ILYAZ/etext/ directory at any CPAN ftp site (listed below). o Brent B. Powers' Tk-FileDialog and Tk-WaitBox are available from the modules/by-authors/id/BPOWERS/ directory at any CPAN ftp site (listed below). Some of the fancier perl/Tk scripts (news readers and web browsers e.g.) make use of other perl modules/module-bundles. Among those that you ought to consider installing are: o To run the ptknews script you will need Mail/Internet.pm from the Mailtools module kit, available from the modules/by-authors/id/GBARR/ directory at any CPAN ftp/http site (listed below). While there pick up the latest libnet-* module bundle too. o The build of recent versions of perl/Tk requests that you have the URI::URL and HTML::Parse modules already installed. These modules are part of the libwww-perl-*.tar.gz kit, available from the modules/by-authors/id/GAAS/ at any CPAN ftp/http site (listed below). Documentation is available from CPAN: o Assorted documentation for perl is in the doc/ directory at any CPAN ftp site (listed below). o Fairly up-to-date versions of some Perl/Tk external documentation (such as this FAQ) is in the modules/by-authors/id/PVHP/ directory at any CPAN ftp/http site (listed below). (for Perl/Tk official documentation check the Tk/doc/*.htm files that are built with Nick's Tk kit on your computer.) Bringing it all together one can look at: o Most things perl/Tk (with certain exceptions) are also linked to a modules/by-module/Tk/ directory at any CPAN ftp/http site (listed below). o The long version of Tim Bunce and Andreas Koenig's module list helps you sort out things like "which kit is HTML::Parse a part of?". It is in modules/00modlist.long.html and is also posted periodically to newsgroups. Here are the 52 CPAN sites/directories (with dotted quads [IP numbers] given on the right for those without name-servers): Updated: Sun Dec 8 17:12:55 EST 1996 Africa South Africa ftp://ftp.is.co.za/programming/perl/CPAN/ 196.4.160.12 Asia Hong Kong ftp://ftp.hkstar.com/pub/CPAN/ 202.82.7.4 Japan ftp://ftp.jaist.ac.jp/pub/lang/perl/CPAN/ 150.65.7.5 ftp://ftp.lab.kdd.co.jp/lang/perl/CPAN/ 192.26.91.6 South Korea ftp://ftp.nuri.net/pub/CPAN/ 203.255.112.6 Taiwan ftp://dongpo.math.ncu.edu.tw/perl/CPAN/ 140.115.25.3 Australasia Australia ftp://coombs.anu.edu.au/pub/perl/CPAN/ 150.203.76.2 ftp://ftp.mame.mu.oz.au/pub/perl/CPAN/ 128.250.209.2 New Zealand ftp://ftp.tekotago.ac.nz/pub/perl/CPAN/ 202.49.6.24 Europe Austria ftp://ftp.tuwien.ac.at/pub/languages/perl/CPAN/ 128.130.34.160 Belgium ftp://ftp.kulnet.kuleuven.ac.be/pub/mirror/CPAN/ 134.58.127.2 Czech Republic ftp://sunsite.mff.cuni.cz/Languages/Perl/CPAN/ 194.50.23.220 Denmark ftp://sunsite.auc.dk/pub/languages/perl/CPAN/ 130.225.51.30 Finland ftp://ftp.funet.fi/pub/languages/perl/CPAN/ 128.214.248.6 France ftp://ftp.pasteur.fr/pub/computing/unix/perl/CPAN/ 157.99.64.12 Germany ftp://ftp.leo.org/pub/comp/programming/languages/perl/CPAN/ 131.159.0.252 ftp://ftp.rz.ruhr-uni-bochum.de/pub/CPAN/ 134.147.32.42 ftp://ftp.uni-hamburg.de/pub/soft/lang/perl/CPAN/ 134.100.32.54 Greece ftp://ftp.ntua.gr/pub/lang/perl/ Hungary ftp://ftp.kfki.hu/pub/packages/perl/CPAN/ 148.6.0.5 Italy ftp://cis.utovrm.it/CPAN/ 160.80.22.17 the Netherlands ftp://ftp.cs.ruu.nl/pub/PERL/CPAN/ 131.211.80.17 ftp://ftp.EU.net/packages/cpan/ 134.222.91.7 Norway ftp://ftp.uit.no/pub/languages/perl/cpan/ 129.242.4.34 Poland ftp://ftp.pk.edu.pl/pub/lang/perl/CPAN/ 149.156.132.152 ftp://sunsite.icm.edu.pl/pub/CPAN/ 148.81.209.3 Portugal ftp://ftp.ci.uminho.pt/pub/lang/perl/ 193.136.16.247 ftp://ftp.telepac.pt/pub/CPAN/ 194.65.5.98 Russia ftp://ftp.sai.msu.su/pub/lang/perl/CPAN/ 158.250.29.1 Slovenia ftp://ftp.arnes.si/software/perl/CPAN/ 193.2.1.72 Spain ftp://ftp.etse.urv.es/pub/mirror/perl/ 193.144.20.6 ftp://ftp.rediris.es/mirror/CPAN/ 130.206.1.2 Sweden ftp://ftp.sunet.se/pub/lang/perl/CPAN/ 130.238.253.4 Switzerland ftp://sunsite.cnlab-switch.ch/mirror/CPAN/ 193.5.24.1 UK ftp://ftp.demon.co.uk/pub/mirrors/perl/CPAN/ 158.152.1.44 ftp://sunsite.doc.ic.ac.uk/packages/CPAN/ 193.63.255.1 ftp://unix.hensa.ac.uk/mirrors/perl-CPAN/ 129.12.200.129 North America Ontario ftp://ftp.utilis.com/public/CPAN/ 207.34.209.49 ftp://enterprise.ic.gc.ca/pub/perl/CPAN/ 192.197.182.100 California ftp://ftp.digital.com/pub/plan/perl/CPAN/ 204.123.2.4 ftp://ftp.cdrom.com/pub/perl/CPAN/ 165.113.58.253 Colorado ftp://ftp.cs.colorado.edu/pub/perl/CPAN/ 128.138.243.20 Florida ftp://ftp.cis.ufl.edu/pub/perl/CPAN/ 128.227.205.206 Illinois ftp://uiarchive.cso.uiuc.edu/pub/lang/perl/CPAN/ 128.174.5.14 Massachusetts ftp://ftp.iguide.com/pub/mirrors/packages/perl/CPAN/ 206.15.105.99 New York ftp://ftp.rge.com/pub/languages/perl/ 157.225.178.12 North Carolina ftp://ftp.duke.edu/pub/perl/ 152.3.233.7 Oklahoma ftp://ftp.ou.edu/mirrors/CPAN/ 129.15.2.40 Oregon ftp://ftp.orst.edu/pub/packages/CPAN/ 128.193.4.12 Texas ftp://ftp.sedl.org/pub/mirrors/CPAN/ 198.213.9.194 ftp://ftp.metronet.com/pub/perl/ 192.245.137.6 South America Chile ftp://sunsite.dcc.uchile.cl/pub/Lang/perl/CPAN/ 146.83.5.204 For those equipped with multi-protocol browsers you might pay a visit to Tom Christiansen's CPAN multiplexer whose relevant Tk URLs are (the second one is not active since it violates the HTML-2.0 spec according to nsgmls): http://perl.com/cgi-bin/cpan_mod?module=Tk http://perl.com/cgi-bin/cpan_mod?module=Tk&readme=1 According to Stephen P. Potter some of the CPAN sites have decompression on the fly for people who do not have programs like gunzip. For example, at the ufl site (Florida USA) type this into your ftp session to download a gunzipped version of Tk: ftp> get Tk400.202.tar.gz Tk400.202.tar If you have the appropriate CPAN and FTP modules (yes there is a CPAN module for retreiving CPAN modules and its name is CPAN oddly enough) already installed you can retrieve a module from CPAN and carry out a complete installation with a perl one-liner like this: perl -MCPAN -e 'install "Tk"' For more information on CPAN you can send e-mail to the CPAN administrators, <cpan-adm@ftp.funet.fi>. If you know of some Perl resources that seem not to be in the CPAN (you did check the contents listings in indices/, didn't you?) please tell the CPAN administrators. If you have some modules/scripts/documentation yourself that you would like to contribute to CPAN, please read the file authors/00upload.howto and let the CPAN administrators know about it.
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |