tkinter之Radiobutton

简介: tkinter之Radiobutton
import tkinter as tk


def select():
    dict1 = {
   1: 'JAVA', 2: 'C++', 3: 'python', 4: 'C'}
    strings = '您选择了' + dict1.get(v.get()) + ',祝您学习愉快'
    lable.config(text=strings)


window = tk.Tk()
window.title("逻辑网")
window.geometry('400x180')
window.iconbitmap('../image/icon.ico')
lable = tk.Label(window, font=('微软雅黑', '15', 'bold'), fg='#43CD80')
lable.pack(side='bottom')
site = [('JAVA', 1),
        ('C++', 2),
        ('python', 3),
        ('C', 4)]
# IntVar() 用于处理整数类型的变量
v = tk.IntVar()
for name, num in site:
    radio_button = tk.Radiobutton(window, text=name, variable=v, value=num, command=select, indicatoron=True)
    radio_button.pack(anchor='w')
# 显示窗口
window.mainloop()
目录
相关文章
|
6月前
|
Python
tkinter之panedwindow
tkinter之panedwindow
73 0
|
6月前
|
容器
Qt6学习笔记七(ToolButton、RadioButton、GroupBox、CheckBox、ListWidget、TreeWidget、TableWidget)
Qt6学习笔记七(ToolButton、RadioButton、GroupBox、CheckBox、ListWidget、TreeWidget、TableWidget)
188 0
|
6月前
|
Shell Python
Tkinter:功能按钮Button
Tkinter:功能按钮Button
|
Android开发 索引
Android RadioButton 单选框
Android RadioButton 单选框
85 0
|
6月前
|
Python
tkinter之Combobox复选框
tkinter之Combobox复选框
152 2
|
6月前
|
Python
tkinter之Button按钮
tkinter之Button按钮
49 1
|
6月前
|
Python
tkinter之button添加背景图片
tkinter之button添加背景图片
147 1
|
6月前
|
Python
tkinter之下拉菜单
tkinter之下拉菜单
122 1
|
6月前
|
Python
tkinter之ListBox示例
tkinter之ListBox示例
48 1
|
6月前
|
Python
tkinter之button简单使用
tkinter之button简单使用
46 1