PTKSH(1p)

πŸ’– PTKSH(1p) β€” the perl/Tk playground shell πŸ’–

okay bestie, welcome to ptksh, the perl/Tk script that hands you a whole graphical user interface just so you can test out Perl/Tk commands and scripts interactively. it's giving "REPL but make it widgets". ✨


🌸 SYNOPSIS 🌸

% ptksh  ?scriptfile?
... version information ...
ptksh> $b=$mw->Button(-text=>'Hi',-command=>sub{print 'Hi'})
ptksh> $b->pack
ptksh> o $b
... list of options ...
ptksh> help
... help information ...
ptksh> exit
%

like. look at her go. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

ptksh is a perl/Tk shell where you type perl commands interactively, and it actually answers you back. when you start it up, a MainWindow gets created automatically, plus a ptksh command window. you reach the main window by typing commands with the variable $mw at the ptksh> prompt inside the command window. main character access, honestly. πŸ‘‘

ptksh supports command line editing and history. just type <Up> at the command prompt to see a history list. the last 50 commands you entered get saved, and then reloaded into the history list the next time you start ptksh. no cap.

ptksh also supports some convenient commands for inspecting Tk widgets. see below bestie, they're iconic.

to exit ptksh use: exit.

lowkey important: ptksh is *not* a full symbolic debugger. if you wanna debug perl/Tk programs at a low level, use the more powerful perl debugger instead. (just enter O tk on the debugger's command line to start the Tk eventloop.) πŸ™ˆ

✨ FEATURES ✨

πŸŽ€ History

press <Up> (the Up Arrow) in the perlwish window to get a gui-based history list. press <Enter> on any history line to enter it into the perlwish window. then hit return. so, for example, repeat last command is <Up><Enter><Enter>. you can quit the history window with <Escape>. πŸ¦‹

NOTE: history is only saved if exit is "graceful" (i.e. by the exit command from the console, or by quitting all main windows β€” NOT by interrupt). so like, don't just ctrl-C your way out and then be shocked. 😭

πŸ’œ Debugging Support

ptksh provides some convenience functions to make browsing in perl/Tk widgets easier:

  • ?, or h β€” displays a short help summary.
  • d, or x ?args, ...? β€” Dumps recursively arguments to stdout. (see Data::Dumper). you must have <Data::Dumper> installed to support this feature. x was introduced for perl debugger compatibility.
  • p ?arg, ...? β€” appends "|\n" to each of its arguments and prints it. if the value is undef, (undef) is printed to stdout.
  • o $widget ?-option ...? β€” prints the option(s) of $widget, one on each line. if no options are given, all options of the widget are listed. see Tk::options for more details on the format and contents of the returned list.
  • o $widget /regexp/ β€” Lists options of $widget matching the regular expression regexp.
  • u ?class? β€” if no argument is given, it lists the modules loaded by the commands you executed, or since the last time you called u. if the argument is the empty string, it lists all modules that are loaded by ptksh. if the argument is a string, text, it tries to do a use Tk::Text;.

🌈 Packages

Ptksh compiles into package Tk::ptksh. your code is eval'ed into package main. the coolness of this is that your eval code should not interfere with ptksh itself. we love a clean separation. periodt.

⭐ Multiline Commands

ptksh will accept multiline commands. simply put a \ character immediately before the newline, and ptksh will continue your command onto the next line. slay.

🫢 Source File Support

if you have a perl/Tk script that you want to do debugging on, try running the command

ptksh> do 'myscript';

-- or (at shell command prompt) --

% ptksh myscript

then use the perl/Tk commands to try out different operations on your script. 🧚


🌸 ENVIRONMENT 🌸

looks for your .ptksh_history in the directory specified by the $HOME environment variable ($HOMEPATH on Win32 systems).


πŸŽ€ FILES πŸŽ€

  • .ptksh_init β€” if found in the current directory it is read in and evaluated after the mainwindow $mw is created. .ptksh_init can contain any valid perl code.
  • ~/.ptksh_history β€” contains the last 50 lines entered in ptksh session(s).

πŸ’€ PITFALLS πŸ’€

it is best not to use my in the commands you type into ptksh. for example my $v will make $v local just to the command or commands entered until <Return> is pressed. for a related reason, there are no file-scopy my variables in the ptksh code itself (else the user might trounce on them by accident). protect the internals bestie. 🫢


😭 BUGS 😭

Tk::MainLoop function interactively entered, or sourced in an init or script file, will block ptksh.


πŸ‘‘ SEE ALSO πŸ‘‘

Tk perldebug


⭐ VERSION ⭐

VERSION 2.03


πŸ’œ AUTHORS πŸ’œ

Mike Beller <beller@penvision.com>, Achim Bohnet <ach@mpe.mpg.de>

Copyright (c) 1996 - 1998 Achim Bohnet and Mike Beller. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


and that's the whole page bestie πŸ’– this little gem shipped as part of Tk version Tk804.036, dated 2025-04-13 β€” go forth and widget, iykyk βœ¨πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from