((section 2 "Outdated egg!" (p "This is an egg for CHICKEN 4, the unsupported old release.  You're almost certainly looking for " (int-link "/eggref/5/pstk" "the CHICKEN 5 version of this egg") ", if it exists.") (p "If it does not exist, there may be equivalent functionality provided by another egg; have a look at the " (link "https://wiki.call-cc.org/chicken-projects/egg-index-5.html" "egg index") ". Otherwise, please consider porting this egg to the current version of CHICKEN.")) (section 2 "PS/Tk" (p "PS/Tk provides an interface to the Tk toolkit, and is an effective tool for creating graphical interfaces.") (toc) (section 3 "Examples" (p "Several examples can be found in the " (link "https://github.com/utz82/pstk" "git repository") " for this egg, as well as a detailed guide to using Tk from Scheme.") (section 4 "Hello World" (highlight scheme "(use pstk)\n\n(tk-start)\n\n(tk/pack \n  (tk 'create-widget 'button 'text: \"Hello\" \n      'command: (lambda () (display \"Hello world\") (newline)))\n  'padx: 20 'pady: 20)\n(tk-event-loop)")) (section 4 "Simple Dialog" (highlight scheme "(use pstk)\n\n(define (celsius->fahrenheit item)\n  (let ((number (string->number item)))\n    (if (number? number)\n      (+ (* number 9/5) 32)\n      0.0)))\n\n(tk-start)\n(tk/wm 'title tk \"Celsius to Fahrenheit\")\n\n(let* ((celsius (tk 'create-widget 'entry))\n       (label (tk 'create-widget 'label))\n       (button (tk 'create-widget 'button\n\t\t   'text: 'Calculate\n\t\t   'command: (lambda () \n\t\t\t       (label 'configure \n\t\t\t\t      'text: (number->string (celsius->fahrenheit (celsius 'get))))))))\n  ; layout widgets in a grid\n  (tk/grid celsius 'column: 2 'row: 1 'sticky: 'we 'padx: 5 'pady: 5)\n  (tk/grid label 'column: 2 'row: 2 'sticky: 'we 'padx: 5 'pady: 5)\n  (tk/grid button 'column: 2 'row: 3 'sticky: 'we 'padx: 5 'pady: 5)\n  (tk/grid (tk 'create-widget 'label 'text: \"celsius\") \n\t   'column: 3 'row: 1 'sticky: 'w 'padx: 5 'pady: 5)\n  (tk/grid (tk 'create-widget 'label 'text: \"is\") \n\t   'column: 1 'row: 2 'sticky: 'e 'padx: 5 'pady: 5)\n  (tk/grid (tk 'create-widget 'label 'text: \"fahrenheit\") \n\t   'column: 3 'row: 2 'sticky: 'w 'padx: 5 'pady: 5)\n\n  (tk-event-loop))"))) (section 3 "Tips on Using PS/Tk " (ul (li "By default, the program " (tt "tclsh8.6") " is called, but an alternative program may be provided as an optional argument to " (tt "(tk-start)") ".  For a distributable application, you can bundle " (link "http://code.google.com/p/tclkit/" "tclkit") " with your application, and call the tclkit application in " (tt "tk-start") ". ") (li "Under windows, there is a problem with keyboard input.  Currently, the fix is to show a dialog box which is dismissed by pressing 'Enter' (not clicking!) directly after starting tk.  ")) (pre "(tk-start \"wish85\")\n(tk/message-box 'title: \"starting program\" 'message: \"Press ENTER\" 'type: 'ok)\n(tk-wm title tk \"PROGRAM\") \netc") (ul (li "It is helpful to put an exception handler around your tk code to prevent orphaned shells, especially when developing your program. e.g.")) (highlight scheme "(handle-exceptions\n  exn\n  (tk-end)  ; make sure tk is closed in event of any error\n  ; begin program\n  (tk-start)\n ; rest of  gui setup\n )") (ul (li "PS/Tk currently does not work on Windows 7 due some problem with Posix/process.  It will simply hang after (tk-start \"tclsh85\") See http://bugs.call-cc.org/ticket/765 for a workaround (You need to add ")) (highlight scheme "(set! process (lambda (#!rest rest)\n    (receive (a b c d) (apply process* rest)\n    (values a b c))))") (p "to your .scm file like this:") (highlight scheme "(require-extension pstk)\n\n;; http://bugs.call-cc.org/ticket/765\n;; broken posix/process function under Windows 7 (MingW)\n(set! process (lambda (#!rest rest)\n    (receive (a b c d) (apply process* rest)\n    (values a b c))))\n(tk-start \"tclsh85\")\n(tk/pack \n  (tk 'create-widget 'button 'text: \"Hello\" \n      'command: (lambda () (display \"Hello world\") (newline)))\n  'padx: 20 'pady: 20)\n(tk-event-loop)") (ul (li "If you want to display unicode characters then you need to add the following to pstk.scm:")) (highlight scheme "     (tk-init-string\n       (string-intersperse\n                          '(\"package require Tk\"\n                            \"fconfigure stdin -encoding utf-8\"\n                            \"fconfigure stdout -encoding utf-8\"\n                            \"if {[package version tile] != \\\"\\\"} {\"\n                            \"    package require tile\"\n                            \"}\"") (p "Alternatively, add the following in your script:") (highlight scheme "(tk-start)\n(tk-eval \"fconfigure stdin -encoding ascii\")\n(tk-eval \"fconfigure stdout -encoding ascii\")")) (section 3 "Authors" (p "Kenneth A Dickey, Nils M Holm and Wolf-Dieter Busch created the initial versions of pstk.  This port to Chicken, plus some additions, is by " (int-link "/users/peter-lane" "Peter Lane") ".")) (section 3 "License" (p "BSD 2-clause")) (section 3 "Requirements" (p "Requires an installation of " (link "http://www.tcl.tk/software/tcltk/" "tcltk") " or " (link "http://code.google.com/p/tclkit/" "tclkit") ".")) (section 3 "Version History" (ul (li "version 1.3.0: set default tcl/tk runtime to tclsh8.6, Chicken 5 compatibility") (li "version 1.2.2: get rid of implicit dependency on " (tt "letrec*") "-semantics in " (tt "letrec") " call (Peter Bex)") (li "version 1.2.1: avoid hitting " (tt "apply") " argument limit (Jim Ursetto)") (li "version 1.2: removed posix dependency from meta file (felix)") (li "version 1.1: working on windows as well as linux") (li "version 1.0: first package.")))))