PTK - Pascal TK Interface for Linux
Welcome to the homepage of PTK.
PTK is a very nice solution for smaller applications that don't need the added bloat of
GTK or QT.
It is not however a library interface. It is an advanced backend system designed to allow you to easilly embed tk commands
directly INTO your pascal code.
Here's a small example program to help you understand the system:
Program TestPTK;
Uses ptk;
Var MyWindow:Wish
Event:String;
Begin
MyWindow.Init('Test');
MyWindow.command('wm title "A Simple PTK Test Program";');
MyWindow.Command('button .button1 -text "Click" -command{puts "You Clicked Me"};');
MyWindow.Command('button .button2 -text "Quit" -command{puts "Quit"};');
MyWindow.Command('pack .button1 .button2');
MyWindow.draw;
Repeat
Event := MyWindow.Said;
If Event <> Nothing then
Writeln(Event);
Until (event='Quit') or (MyWindow.Killed);
end.
So let's run through this code quickly:
MyWindow.Init('Test') Initialize the unit using the parameter for an initial ONE WORD window title.
MyWindow.command('wm title "A Simple PTK Test Program";'); Change to a better multi-word title.
MyWindow.Command('button .button1 -text "Click" -command{puts "You Clicked Me"};');
MyWindow.Command('button .button2 -text "Quit" -command{puts "Quit"};');
More standard TK commands.
Notice that the COMMAND option to all widgets is a string output. This is not vital to the system, however you need
to do it that way to know what has happened on the Pascal side ok.
MyWindow.Draw This finally takes our finished TK code and displays it.
Here lies PTK's greatest catch. If you want to make a dynamic screen you HAVE to do it inside the TK code.
PTK cannot change the TK screen after you do this. So any widgets that have events that you cannot put in a new screen
must be done in TK. You can still use the puts to let Pascal know about them, but you cannot change the output of THIS
window anymore. However you can create as many windows as you want.
Event := MyWindow.Said; The function MyWindow.Said returns a string containing the LAST line of output from
your ptk window. It only returns any given value once however, so store it in a variable unless your sure you won't
need the same output again.
Until (event='Quit') The MyWindow.Killed function returns true if the PTK window has been killed by the window manager, false if not. Normally, you could test it directly but it's not nescecary. MyWindow.Said will
perform the test for you and output the string 'Quit' if it is true.
Just one more note on event handling in PTK.
Some input widgets don't have associated command actions. They take variables as options instead and store their values
into these variables.
To obtain such values simply use PUTS to write the value to the screen, perhaps even with a formatting to indicate what
it is. You may even link the PUTS that does this to a button.
Current Version: 0.1 - First Public Release.