如何链接单选按钮等一组切换按钮? [英] How can I link a set of toggle buttons like radio buttons?
问题描述
我正在将Python 3与gobject内省一起用于Gtk。如何将多个切换按钮链接在一起,使它们的行为类似于标签或单选按钮-例如默认情况下,一个被选中,而当另一个被单击
时,先前的活动
被取消选择。
I am using Python 3 with gobject introspection for Gtk. How can I have more than one toggle button linked together so they behave similar to tabs or radiobuttons - e.g. one is selected by default, and when another is clicked
the previously active
one is de-selected.
我尝试使用 set_sensetive
,但这会使应用它的小部件变灰。
I have tried using set_sensetive
, but that greys out the widget that it is applied on.
推荐答案
使用 set_active()
(或 props.active
)。另外,您可以创建一些 Gtk.RadioButton
小部件,并将 draw_indicator
属性设置为 False
。在后一种情况下,您可以按常规方式创建无线电组,而无需自定义处理。
Use set_active()
(or props.active
). Alternatively, you can create some Gtk.RadioButton
widgets and set draw_indicator
property to False
. In the latter case you can create radio groups in normal way, without custom handling.
这篇关于如何链接单选按钮等一组切换按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!