Tk 中的 Radiobutton部件函数

首页 / Tcl/Tk入门教程 / Tk 中的 Radiobutton部件函数

单选按钮小部件实现了多项选择按钮,这是一种向用户提供许多可能选择并让用户仅选择其中一项的方法。单选按钮小部件的语法如下所示-

radiobutton radiobuttonName options

Radiobutton - 参数

下表在下表中列出了可用于单选按钮窗口小部件的选项-

Sr.No.Syntax & Remark
1

-font fontDescriptor

用于设置小部件的字体。

2

height number

用于设置小部件的高度。

3

-command action

设置按钮的command action。

4

-text text

设置小部件的文本。

链接:https://www.learnfk.comhttps://www.learnfk.com/tcl-tk/tk-radio-button-widget.html

来源:LearnFk无涯教程网

5

width number

设置小部件的宽度。

6

-variable variableName

设置小部件的变量。

7

-value variableValue

用变量值设置变量。

下面是一个简单的单选按钮小部件示例-

#!/usr/bin/wish

grid [frame .gender ]
grid [label .myLabel  -text "Male" -textvariable myLabel1 ] 
grid [radiobutton .gender.maleBtn -text "Male"   -variable gender -value "Male"
   -command "set  myLabel1 Male"] -row 1 -column 2
grid [radiobutton .gender.femaleBtn -text "Female" -variable gender -value "Female"
   -command "set  myLabel1 Female"] -row 1 -column 3
.gender.maleBtn select

当无涯教程运行上面的程序时,将获得以下输出-

无涯教程网

Radio Button Example

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

Service Mesh实践指南 -〔周晶〕

深入浅出gRPC -〔李林锋〕

即时消息技术剖析与实战 -〔袁武林〕

Node.js开发实战 -〔杨浩〕

Electron开发实战 -〔邓耀龙〕

技术管理案例课 -〔许健〕

WebAssembly入门课 -〔于航〕

流程型组织15讲 -〔蒋伟良〕

徐昊 · TDD项目实战70讲 -〔徐昊〕

好记忆不如烂笔头。留下您的足迹吧 :)