#!/usr/bin/wish
#line
canvas .c1 -width 50 -height 50 -relief ridge -bd 6 -bg darkgreen
.c1 create line 5 15 15 25 35 5 50 15 -width 2 -fill cyan
.c1 create line 5 30 15 40 35 20 50 30 -arrow both -fill purple
.c1 create line 5 45 15 55 35 35 50 45 -smooth yes -fill orange \
-width 2
#rectangle
canvas .c2 -width 50 -height 50 -relief ridge -bd 6 -bg darkgreen
.c2 create rectangle 10 10 35 35 -width 4 -fill brown
.c2 create rectangle 17 20 45 45 -fill orange -stipple gray50
#polygon
canvas .c3 -width 50 -height 50 -relief ridge -bd 6 -bg darkgreen
.c3 create polygon 10 5 30 20 45 10 \
40 45 20 35 10 40 -fill brown
#oval
canvas .c4 -width 50 -height 50 -relief ridge -bd 6 -bg darkgreen
.c4 create oval 15 10 30 30 -fill blue
.c4 create oval 20 15 45 45 -outline brown -width 3
#arc
canvas .c5 -width 50 -height 50 -relief ridge -bd 6 -bg darkgreen
.c5 create arc 15 10 30 30 -extent 240 -fill blue
.c5 create arc 20 15 45 45 -start 45 -extent -100 \
-style arc -width 3 -outline brown
#bitmap
canvas .c6 -width 50 -height 50 -relief ridge -bd 6 -bg darkgreen
.c6 create bitmap 30 30 -anchor se -bitmap questhead
.c6 create bitmap 30 25 -anchor nw -bitmap error \
-background cyan -foreground red
#image
canvas .c7 -width 50 -height 50 -relief ridge -bd 6 -bg darkgreen
image create photo img \
-file /home/pi/tk8.6.1/library/demos/images/tcllogo.gif
.c7 create image 35 15 -anchor c -image img
#text
canvas .c8 -width 50 -height 50 -relief ridge -bd 6 -bg darkgreen
.c8 create text 35 25 -anchor se -text "Hello" -font {Sans 8}
.c8 create text 45 45 -anchor se -text "Hello" \
-font {Sans 12}
#window
canvas .c9 -width 50 -height 50 -relief ridge -bd 6 -bg darkgreen
.c9 create oval 5 5 45 45 -fill blue
entry .c9.e -width 5
.c9 create window 25 25 -anchor c -window .c9.e
pack .c1 .c2 .c3 .c4 .c5 .c6 .c7 .c8 .c9 -side left

下記のアイテムのほとんどには点描パターン(-stipple)のオプションが使用できる。
アイテムはデフォルトでは単色で描画されるが、点描パターンにgray25などのビットマップスクリーンを指定すると網掛けの効果が得られる。
#linelineには2個以上の座標がある。
両方の端は矢印(arrow)にすることができる。
またスムージング(smooth)を有効にすると線は一連のベジェ曲線によるスプラインとして描かれる。
【オプション】
-dash (点線のパタンを指定します。)
-activedash (点線のパタンを指定します。)
-disableddash (点線のパタンを指定します。)
-dashoffset (dashの開始オフセットを指定します。)
-fill (図形の色を指定します。)
-activefill (図形の色を指定します。)
-disabledfill (図形の色を指定します。)
-stipple (fillにビットマップを指定します。)
-activestipple (fillにビットマップを指定します。)
-disabledstipple (fillにビットマップを指定します。)
-state (状態を指定します。normal, disabled, hiddenのいずれか。)
-tags (アイテムにタグ名を付けます。)
-width (輪郭線の太さを指定します。)
-activewidth (輪郭線の太さを指定します。)
-disabledwidth (輪郭線の太さを指定します。)
-arrow (矢印。first. last. both. default:none)
-arrowshape (矢印の形状。)
-capstyle (ラインの端点に描画。butt. projecting. round)
-joinstyle (ラインの頂点に描画。)
-smooth (滑らかな曲線。)
-splinesteps (カーブのために必要な平滑度)
#rectanglerectangleには相対する2角を示す2つの座標がある。
輪郭線の色(outline)と太さ(width)および塗りつぶし色(fill)を指定できる。
【オプション】
-dash (点線のパタンを指定します。)
-activedash (点線のパタンを指定します。)
-disableddash (点線のパタンを指定します。)
-dashoffset (dashの開始オフセットを指定します。)
-fill (図形の色を指定します。)
-activefill (図形の色を指定します。)
-disabledfill
-offset (開始オフセットを設定します。)
-outline (輪郭線の色を指定します。)
-activeoutline (輪郭線の色を指定します。)
-disabledoutline (輪郭線の色を指定します。)
-outlineoffset
-outlinestipple (outlineにビットマップを指定します。)
-activeoutlinestipple (outlineにビットマップを指定します。)
-disabledoutlinestipple (outlineにビットマップを指定します。)
-stipple
-activestipple
-disabledstipple
-state
-tags
-width
-activewidth
-disabledwidth
#polygonpolygonには3つ以上の座標がある。
rectangleと同じように輪郭線の色と太さ、塗りつぶし色を指定できる。
また、線と同様にスムージングを設定でき、そうすると輪郭が一連のベジェ曲線によるスプラインで描かれる。
【オプション】
-dash (点線のパタンを指定します。)
-activedash (点線のパタンを指定します。)
-disableddash (点線のパタンを指定します。)
-dashoffset (dashの開始オフセットを指定します。)
-fill (図形の色を指定します。)
-activefill (図形の色を指定します。)
-disabledfill
-offset (開始オフセットを設定します。)
-outline (輪郭線の色を指定します。)
-activeoutline (輪郭線の色を指定します。)
-disabledoutline (輪郭線の色を指定します。)
-outlineoffset
-outlinestipple
-activeoutlinestipple
-disabledoutlinestipple
-stipple
-activestipple
-disabledstipple
-state
-tags
-width
-activewidth
-disabledwidth
-joinstyle
-smooth
-splinesteps
#ovalrectangleと同じく輪郭線の色と太さ塗りつぶし色を指定できる。
【オプション】
-dash (点線のパタンを指定します。)
-activedash (点線のパタンを指定します。)
-disableddash (点線のパタンを指定します。)
-dashoffset (dashの開始オフセットを指定します。)
-fill (図形の色を指定します。)
-activefill (図形の色を指定します。)
-disabledfill
-offset (開始オフセットを設定します。)
-outline (輪郭線の色を指定します。)
-activeoutline (輪郭線の色を指定します。)
-disabledoutline (輪郭線の色を指定します。)
-outlineoffset
-outlinestipple
-activeoutlinestipple
-disabledoutlinestipple
-stipple
-activestipple
-disabledstipple
-state
-tags
-width
-activewidth
-disabledwidth
#arc円弧(arc)は楕円(oval)に似ているが、開始角(start)と楕円のどこまでを描くかを決める範囲(extent)がある。
【オプション】
-dash (点線のパタンを指定します。)
-activedash (点線のパタンを指定します。)
-disableddash (点線のパタンを指定します。)
-dashoffset (dashの開始オフセットを指定します。)
-fill (図形の色を指定します。)
-activefill (図形の色を指定します。)
-disabledfill
-offset (開始オフセットを設定します。)
-outline (輪郭線の色を指定します。)
-activeoutline (輪郭線の色を指定します。)
-disabledoutline (輪郭線の色を指定します。)
-outlineoffset
-outlinestipple
-activeoutlinestipple
-disabledoutlinestipple
-stipple
-activestipple
-disabledstipple
-state
-tags
-width
-activewidth
-disabledwidth
円弧は線で描くほか、パイ型や、開始点と終了点を結ぶ弦をつけて描くこともできる。
これらのスタイルは-styleオプションで制御できる。
#bitmapビットマップにはアンカーポイントを示す座標がある。
ビットマップは-anchorオプションによる指定に従って、このポイントに寄せられる。
ビットマップはそれぞれ2色である。
前景色は通常、黒であり、背景色は通常、canvasウィジェットと同じ色である。
【オプション】
-anchor
-state
-tags
-background
-activebackground
-disabledbackground
#imageimageにはアンカーポイントを示す座標がある。
しかしビットマップとは違って、画像は任意の数の色を持つことができる。
【オプション】
-anchor
-state
-tags
-image
-activeimage
-disabledimage
-dash (点線のパタンを指定します。)
-activedash (点線のパタンを指定します。)
-disableddash (点線のパタンを指定します。)
-dashoffset (dashの開始オフセットを指定します。)
-fill (図形の色を指定します。)
-activefill (図形の色を指定します。)
-disabledfill (塗りつぶしの色を指定)
-stipple (塗りつぶし部分のパターンをビットマップ名で指定)
-activestipple (塗りつぶし部分のパターンをビットマップ名で指定)
-disabledstipple (塗りつぶし部分のパターンをビットマップ名で指定)
-state (状態を指定します。normal, disabled, hidden)
-tags (与えられたタグのリストの要素をタグとして設定)
-width (線幅。デフォルト:1)
-activewidth
-disabledwidth
-arrow
-arrowshape
-capstyle
-joinstyle
-smooth
-splinesteps
#texttextにはアンカーポイントを示す座標がある。
1個のテキストは複数の行を持つことができ、その行揃え(justification)を制御できる。
またテキストの色とフォントも指定できる。
【オプション】
-anchor
-fill (図形の色を指定します。)
-activefill (図形の色を指定します。)
-disabledfill
-stipple
-activestipple
-disabledstipple
-state
-tags
-angle
-font
-justify
-text
-underline
-width
#windowwindowにはアンカーポイントを示す座標がある。
このアイテムはキャンバスに埋め込まれるウィジェットの場所を確保するのに使われる。
これによって、ボタンやエントリを他のグラフィックスと混在させてキャンバス上に置くことができる。
【オプション】
-anchor
-state
-tags
-height
-width
-window
Tkコマンド【目次】