ptktrl - Simple perl/Tk shell with cmd line editing and a persistent history


  % ptktrl  ?I<scriptfile>?
  ... version informations ...
  ptktrl> $b=$mw->Button(-text=>'Hi',-command=>sub{print 'Hi'})
  ptktrl> $b->grid
  ptktrl> o $b
  ... list of options ...
  ptktrl> ...
  ptktrl> ^D


ptktrl is a simple perl/Tk shell to enter perl commands interactively. When one starts ptktrl a MainWindow is automaticly created. One can access it with $mw on the command line.

ptktrl supports command line editing and history via ReadLine interface (see Term::ReadLine). The last 50 commands entered are saved on exit to ~/.ptktrl_history. The history file is loaded into history cache the next time you start ptktrl.

To exit ptktrl use: ^D, exit, or quit.

The primary target of ptktrl is to experiment with perl/Tk widgets. To debug perl/Tk programs use the more powerful the perl debugger. Just enter ``O tk'' on debuggers command line to start the Tk eventloop. The only advantage ptktrl has is that history file support and that a MainWindow is automaticly created.


ptktrl provides some convenience function to make browsing in perl/Tk widgets easier:


displays a short help summary.

d ?args, ...?

Dumps recursicely arguments to stdout. (see Data::Dumper).

p ?arg, ...?

appends "|\n" to each of it's arguments and prints it. If 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 argument is the empty string lists all modules that are loaded by ptktrl.

If argument is a string, ``text'' it tried does a ``use Tk::Text''.


Same as for Term::ReadLine and perl. See Term::ReadLine and "ENVIRONMENT" in perlrun for further details.



If found in current directory it is read in an evaluated after the mainwindow $mw is created. .ptktrl_init can contain any valid perl code.


Contains the last 50 lines entered in ptktrl session(s).


Work only on Unix systems.

Term::Readline::Perl command line history is broken when used in conjunction with perl/Tk. Term::ReadLine::Gnu has no problems.

Tk::MainLoop function interactively entered or sourced in a init or script file will block ptktrl.


Tk Term::ReadLine perldebug


Achim Bohnet <>

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