多选radiobuttons / Checkbuttons [“indicatoron”] = False(Multiselection radiobuttons / Checkbuttons[“in

编程入门 行业动态 更新时间:2024-10-21 13:38:30
多选radiobuttons / Checkbuttons [“indicatoron”] = False(Multiselection radiobuttons / Checkbuttons[“indicatoron”]=False)

我的tkinter界面上有两组radiobuttons:

1)平均值 - 中值...

2)每月 - 每周......

我想添加一个多选小部件组,但我希望它具有前两个组的相同方面。

我的第一个想法是创建一组radiobuttons并选择任何多选模式,但这种模式似乎不存在。 第二个想法是使用一组检查按钮并将指示器设置为False,但检查按钮上不存在此选项。

我错过了什么可以解决我的问题吗? 或者还有其他可能性我尚未考虑过吗?

I have two groups of radiobuttons on my tkinter interface :

1) Average - Median Value ...

2) Monthly - Weekly ...

I would like to add a multiselection group of widgets BUT I would like it to have the same aspect of both previous groups.

The first idea I had was to create a group of radiobuttons and choose any multiselection mode but this mode seems not to exist. The second idea was to use a group of checkbuttons and set indicatoron on False but this option doesn't exist on checkbuttons.

Did I miss anything which could solve my problem? Or is there any other possibility that I have not yet considered?

最满意答案

正确的选择是使用明确设计用于多个选择的检查按钮。 与您在问题中所写的内容相反,检查按钮确实包含indicatoron选项。

import tkinter as tk root = tk.Tk() vars = {} frame = tk.Frame(root) frame.pack(side="top", fill="x", padx=10, pady=10) for color in ("red", "orange", "green", "blue", "indigo", "violet"): checkbutton = tk.Checkbutton(frame, onvalue=1, offvalue=0, text=color, indicatoron=False, width=6) checkbutton.pack(side="left", fill="x", expand=True) root.mainloop()

checkoff的屏幕截图设置为true

The proper choice is to use checkbuttons, which are explicitly designed for multiple selections. Contrary to what you wrote in your question, checkbuttons do indeed include an indicatoron option.

import tkinter as tk root = tk.Tk() vars = {} frame = tk.Frame(root) frame.pack(side="top", fill="x", padx=10, pady=10) for color in ("red", "orange", "green", "blue", "indigo", "violet"): checkbutton = tk.Checkbutton(frame, onvalue=1, offvalue=0, text=color, indicatoron=False, width=6) checkbutton.pack(side="left", fill="x", expand=True) root.mainloop()

screenshot of checkbuttons with indicatoroff set to true

更多推荐

本文发布于:2023-04-28 01:54:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1330295.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多选   radiobuttons   Checkbuttons   Multiselection   False

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!