Privacy Policy Cookie Policy Terms and Conditions Tk (computing) - Wikipedia, the free encyclopedia

Tk (computing)

From Wikipedia, the free encyclopedia

Tk is an open source, cross-platform widget toolkit, that is, a library of basic elements for building a graphical user interface (GUI).

Contents

[edit] History

Tk was developed by John Ousterhout as an extension for the Tcl scripting language. Bindings exist for several other languages, including Perl, Python, Ruby, and Common Lisp. There are two ways to use Tk from Perl: the Tcl::Tk Perl module, which uses Tcl as a bridge (this approach provides more flexibility), and Perl/Tk, which has Tcl stripped away (only adopted Tcl/Tk extensions are available). The Python and Ruby bindings also use Tcl as a bridge for Tk.

Tk has been ported to run on most flavors of Linux, Apple Macintosh, Unix, and Windows. Since Tcl/Tk 8, it offers "native look and feel" (for instance, menus and buttons are displayed in the manner of "native" software for any given platform). Also, there are several extensions to provide external drag-and-drop, non-rectangular windows, and native widgets.

Like Tcl, Tk supports Unicode within the Basic Multilingual Plane but it has not yet been extended to handle 32-bit Unicode.

[edit] Features

Tk provides the following widgets:

  • button
  • canvas
  • checkbutton
  • entry
  • frame
  • label
  • labelframe
  • listbox
  • menu
  • menubutton
  • message
  • tk_optionMenu
  • panedwindow
  • radiobutton
  • scale
  • scrollbar
  • spinbox
  • text

as well as the following top-level windows:

  • tk_chooseColor - pops up a dialog box for the user to select a color.
  • tk_chooseDirectory - pops up a dialog box for the user to select a directory.
  • tk_dialog - Create modal dialog and wait for response
  • tk_getOpenFile - pop up a dialog box for the user to select a file to open or save.
  • tk_messageBox - pops up a message window and waits for user response.
  • tk_popup - Post a popup menu
  • toplevel - Create and manipulate toplevel widgets

Tk also provides three geometry managers:

  • place - which positions widgets at absolute locations
  • grid - which arranges widgets in a grid
  • pack - which packs widgets into a cavity

The most unusual features of Tk are its canvas and text widgets, which provide capabilities found in few if any other widget toolkits.

[edit] Some Examples

Button

button .b -text "Button" -command "exit"

Label

label .l -text "Label" -foreground Yellow -background Blue -font {-family times -size 24}

Check Buttons

checkbutton .c1 -text Bold -variable bold   -anchor w

Radio Buttons

radiobutton .r1 -text Helvetica -variable font -value helvetica

Entry

entry .e -width 40 -relief sunken -bd 2 -textvariable name

Canvas

canvas .c -width 250 -height 100

List Box

listbox .l -yscroll ".s set"

Scale

scale .scale -orient vertical -length 284 -from 0 -to 250 -tickinterval 50 -command "setHeight .canvas" 

tk_messageBox

tk_messageBox -icon question -type yesno -title Message -parent . -message "Do you like me so far?"

tk_getOpenFile

tk_getOpenFile -filetypes $types -parent .

tk_chooseColor

tk_chooseColor -title "Choose a background color" -parent .

Text

text .t -yscrollcommand ".scroll set" -setgrid true -width 40 -height 10 -wrap word

Menu

menu ???

menubutton

menubutton ???

cursor

cursor ???

image

image ???

bitmaps

bitmaps ???

[edit] See also

[edit] External links

[edit] Generic Tk and Tcl/Tk

[edit] Perl/Tk

[edit] Ruby/Tk

[edit] Common Lisp/Tk

  • LTK LTK, the Lisp ToolKit. Tk interface (through tcl) for Common Lisp
Static Wikipedia 2006 (no images)

aa - ab - af - ak - als - am - an - ang - ar - arc - as - ast - av - ay - az - ba - bar - bat_smg - bcl - be - be_x_old - bg - bh - bi - bm - bn - bo - bpy - br - bs - bug - bxr -
 
ca - cbk_zam - cdo - ce - ceb - ch - cho - chr - chy - co - cr - crh - cs - csb - cu - cv - cy - da - de - diq - dsb - dv - dz - ee - el - eml - en - eo - es - et - eu - ext -
fa - ff - fi - fiu_vro - fj - fo - fr - frp - fur - fy - ga - gan - gd - gl - glk - gn - got - gu - gv - ha - hak - haw - he - hi - hif - ho - hr - hsb - ht - hu - hy - hz -
 
ia - id - ie - ig - ii - ik - ilo - io - is - it - iu - ja - jbo - jv - ka - kaa - kab - kg - ki - kj - kk - kl - km - kn - ko - kr - ks - ksh - ku - kv - kw - ky -
la - lad - lb - lbe - lg - li - lij - lmo - ln - lo - lt - lv - map_bms - mdf - mg - mh - mi - mk - ml - mn - mo - mr - mt - mus - my - myv - mzn -
 
na - nah - nap - nds - nds_nl - ne - new - ng - nl - nn - no - nov - nrm - nv - ny - oc - om - or - os - pa - pag - pam - pap - pdc - pi - pih - pl - pms - ps - pt -
qu - quality - rm - rmy - rn - ro - roa_rup - roa_tara - ru - rw - sa - sah - sc - scn - sco - sd - se - sg - sh - si - simple - sk - sl - sm - sn - so - sr - srn - ss - st - stq - su - sv - sw - szl -
 
ta - te - tet - tg - th - ti - tk - tl - tlh - tn - to - tpi - tr - ts - tt - tum - tw - ty - udm - ug - uk - ur - uz - ve - vec - vi - vls - vo - wa - war - wo - wuu - xal - xh -
yi - yo - za - zea - zh - zh_classical - zh_min_nan - zh_yue - zu -

Static Wikipedia 2008 (no images)

aa - ab - af - ak - als - am - an - ang - ar - arc - as - ast - av - ay - az - ba - bar - bat_smg - bcl - be - be_x_old - bg - bh - bi - bm - bn - bo - bpy - br - bs - bug - bxr - ca - cbk_zam - cdo - ce - ceb - ch - cho - chr - chy - co - cr - crh - cs - csb - cu - cv - cy - da - de - diq - dsb - dv - dz - ee - el - eml - en - eo - es - et - eu - ext - fa - ff - fi - fiu_vro - fj - fo - fr - frp - fur - fy - ga - gan - gd - gl - glk - gn - got - gu - gv - ha - hak - haw - he - hi - hif - ho - hr - hsb - ht - hu - hy - hz - ia - id - ie - ig - ii - ik - ilo - io - is - it - iu - ja - jbo - jv - ka - kaa - kab - kg - ki - kj - kk - kl - km - kn - ko - kr - ks - ksh - ku - kv - kw - ky - la - lad - lb - lbe - lg - li - lij - lmo - ln - lo - lt - lv - map_bms - mdf - mg - mh - mi - mk - ml - mn - mo - mr - mt - mus - my - myv - mzn - na - nah - nap - nds - nds_nl - ne - new - ng - nl - nn - no - nov - nrm - nv - ny - oc - om - or - os - pa - pag - pam - pap - pdc - pi - pih - pl - pms - ps - pt - qu - quality - rm - rmy - rn - ro - roa_rup - roa_tara - ru - rw - sa - sah - sc - scn - sco - sd - se - sg - sh - si - simple - sk - sl - sm - sn - so - sr - srn - ss - st - stq - su - sv - sw - szl - ta - te - tet - tg - th - ti - tk - tl - tlh - tn - to - tpi - tr - ts - tt - tum - tw - ty - udm - ug - uk - ur - uz - ve - vec - vi - vls - vo - wa - war - wo - wuu - xal - xh - yi - yo - za - zea - zh - zh_classical - zh_min_nan - zh_yue - zu -