📜  Tk-基本小工具

📅  最后修改于: 2020-10-16 06:33:37             🧑  作者: Mango


基本窗口小部件是几乎所有Tk应用程序中可用的常见窗口小部件。可用的基本小部件列表如下:

Sr.No. Widgets & Description
1 Label

Widget for displaying single line of text.

2 Button

Widget that is clickable and triggers an action.

3 Entry

Widget used to accept a single line of text as input.

4 Message

Widget for displaying multiple lines of text.

5 Text

Widget for displaying and optionally edit multiple lines of text.

6 Toplevel

Widget used to create a frame that is a new top level window.

下面是一个使用基本小部件的简单Tk示例-

#!/usr/bin/wish

grid [label .myLabel -text "Label Widget" -textvariable labelText] 
grid [text .myText -width 20 -height 5]
.myText insert 1.0 "Text\nWidget\n"
grid [entry .myEntry -text "Entry Widget"]
grid [message .myMessage -background red -foreground white -text "Message\nWidget"]
grid [button .myButton1  -text "Button" -command "set labelText clicked"]

当我们运行上面的程序时,我们将获得以下输出-

基本小部件示例