Tcl-tk-tk-images
提供:Dev Guides
Tk-画像
画像ウィジェットは、画像の作成と操作に使用されます。 イメージを作成するための構文は次のとおりです-
image create type name options
上記の構文では、タイプは写真またはビットマップで、名前は画像識別子です。
オプション
イメージの作成に使用できるオプションは、次の表のとおりです-
Sr.No. | Syntax & Description |
---|---|
1 |
-file fileName 画像ファイル名の名前。 |
2 |
-height number ウィジェットの高さを設定するために使用されます。 |
3 |
-width number ウィジェットの幅を設定します。 |
4 |
-data string Base 64エンコード文字列の画像。 |
画像ウィジェットの簡単な例を以下に示します-
#!/usr/bin/wish
image create photo imgobj -file "/Users/rajkumar/Desktop/F Drive/pictur/vb/Forests/
680049.png" -width 400 -height 400
pack [label .myLabel]
.myLabel configure -image imgobj
上記のプログラムを実行すると、次の出力が得られます-
画像の利用可能な機能は、次の表に以下に記載されています-
Sr.No. | Syntax & Description |
---|---|
1 |
image delete imageName メモリおよび関連するウィジェットから画像を視覚的に削除します。 |
2 |
image height imageName 画像の高さを返します。 |
3 |
image width imageName 画像の幅を返します。 |
4 |
image type imageName 画像のタイプを返します。 |
5 |
image names メモリ内にある画像のリストを返します。 |
上記の画像ウィジェットコマンドを使用するための簡単な例を以下に示します-
#!/usr/bin/wish
image create photo imgobj -file "/Users/rajkumar/images/680049.png"
-width 400 -height 400
pack [label .myLabel]
.myLabel configure -image imgobj
puts [image height imgobj]
puts [image width imgobj]
puts [image type imgobj]
puts [image names]
image delete imgobj
「image delete imgobj」コマンドが実行されると、画像は視覚的におよびメモリから削除されます。 コンソールでは、出力は次のようになります-
400
400
photo
imgobj ::tk::icons::information ::tk::icons::error ::tk::icons::
warning ::tk::icons::question