Wiki
Download
Manual
Eggs
API
Tests
Bugs
show
edit
history
You can edit this page using
wiki syntax
for markup.
Article contents:
== Outdated egg! This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for [[/eggref/5/pstk|the CHICKEN 5 version of this egg]], if it exists. If it does not exist, there may be equivalent functionality provided by another egg; have a look at the [[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. == PS/Tk PS/Tk provides an interface to the Tk toolkit, and is an effective tool for creating graphical interfaces. [[toc:]] === Examples Several examples can be found in the [[https://github.com/utz82/pstk|git repository]] for this egg, as well as a detailed guide to using Tk from Scheme. ==== Hello World <enscript highlight=scheme> (use pstk) (tk-start) (tk/pack (tk 'create-widget 'button 'text: "Hello" 'command: (lambda () (display "Hello world") (newline))) 'padx: 20 'pady: 20) (tk-event-loop) </enscript> ==== Simple Dialog <enscript highlight=scheme> (use pstk) (define (celsius->fahrenheit item) (let ((number (string->number item))) (if (number? number) (+ (* number 9/5) 32) 0.0))) (tk-start) (tk/wm 'title tk "Celsius to Fahrenheit") (let* ((celsius (tk 'create-widget 'entry)) (label (tk 'create-widget 'label)) (button (tk 'create-widget 'button 'text: 'Calculate 'command: (lambda () (label 'configure 'text: (number->string (celsius->fahrenheit (celsius 'get)))))))) ; layout widgets in a grid (tk/grid celsius 'column: 2 'row: 1 'sticky: 'we 'padx: 5 'pady: 5) (tk/grid label 'column: 2 'row: 2 'sticky: 'we 'padx: 5 'pady: 5) (tk/grid button 'column: 2 'row: 3 'sticky: 'we 'padx: 5 'pady: 5) (tk/grid (tk 'create-widget 'label 'text: "celsius") 'column: 3 'row: 1 'sticky: 'w 'padx: 5 'pady: 5) (tk/grid (tk 'create-widget 'label 'text: "is") 'column: 1 'row: 2 'sticky: 'e 'padx: 5 'pady: 5) (tk/grid (tk 'create-widget 'label 'text: "fahrenheit") 'column: 3 'row: 2 'sticky: 'w 'padx: 5 'pady: 5) (tk-event-loop)) </enscript> === Tips on Using PS/Tk * By default, the program {{tclsh8.6}} is called, but an alternative program may be provided as an optional argument to {{(tk-start)}}. For a distributable application, you can bundle [[http://code.google.com/p/tclkit/|tclkit]] with your application, and call the tclkit application in {{tk-start}}. * 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. (tk-start "wish85") (tk/message-box 'title: "starting program" 'message: "Press ENTER" 'type: 'ok) (tk-wm title tk "PROGRAM") etc * It is helpful to put an exception handler around your tk code to prevent orphaned shells, especially when developing your program. e.g. <enscript> (handle-exceptions exn (tk-end) ; make sure tk is closed in event of any error ; begin program (tk-start) ; rest of gui setup ) </enscript> * 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 <enscript> (set! process (lambda (#!rest rest) (receive (a b c d) (apply process* rest) (values a b c)))) </enscript> to your .scm file like this: <enscript> (require-extension pstk) ;; http://bugs.call-cc.org/ticket/765 ;; broken posix/process function under Windows 7 (MingW) (set! process (lambda (#!rest rest) (receive (a b c d) (apply process* rest) (values a b c)))) (tk-start "tclsh85") (tk/pack (tk 'create-widget 'button 'text: "Hello" 'command: (lambda () (display "Hello world") (newline))) 'padx: 20 'pady: 20) (tk-event-loop) </enscript> * If you want to display unicode characters then you need to add the following to pstk.scm: <enscript> (tk-init-string (string-intersperse '("package require Tk" "fconfigure stdin -encoding utf-8" "fconfigure stdout -encoding utf-8" "if {[package version tile] != \"\"} {" " package require tile" "}" </enscript> Alternatively, add the following in your script: <enscript> (tk-start) (tk-eval "fconfigure stdin -encoding ascii") (tk-eval "fconfigure stdout -encoding ascii") </enscript> === Authors 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 [[/users/peter-lane|Peter Lane]]. === License BSD 2-clause === Requirements Requires an installation of [[http://www.tcl.tk/software/tcltk/|tcltk]] or [[http://code.google.com/p/tclkit/|tclkit]]. === Version History * version 1.3.0: set default tcl/tk runtime to tclsh8.6, Chicken 5 compatibility * version 1.2.2: get rid of implicit dependency on {{letrec*}}-semantics in {{letrec}} call (Peter Bex) * version 1.2.1: avoid hitting {{apply}} argument limit (Jim Ursetto) * version 1.2: removed posix dependency from meta file (felix) * version 1.1: working on windows as well as linux * version 1.0: first package.
Description of your changes:
I would like to authenticate
Authentication
Username:
Password:
Spam control
What do you get when you add 16 to 13?