易截截图软件、单文件、免安装、纯绿色、仅160KB

Python:请教Tk中radiobutton控件的两个属性作用

请先看下面的简单代码:

Python code:

from tkinter import *

root = Tk()
v = IntVar()
v.set(0)

for i in range(3):
Radiobutton(root,
variable = v,
value = i).pack()
root.mainloop()



问题:
1、Radiobutton空间中的variable属性和value属性分别起到什么作用?
2、variable为什么赋值为v,然后给v赋值为0,可以正常工作,但是如果直接给variable赋值为0,就不行了呢?


谢谢!
value 指定的是 RadioButton 关联的值

Python code:
Command-Line Name: -value
Database Name: value
Database Class: Value
Specifies value to store in the button's associated variable whenever
this button is selected.



variable 指定的是 RadioButton 选中时设置的变量名,这个必须是全局的变量名,用 0 肯定是不行的

Python code:
Command-Line Name: -variable
Database Name: variable
Database Class: Variable
Specifies name of global variable to set whenever this button is selected.
Changes in this variable also cause the button to select or deselect itself.
Defaults to the value selectedButton.



谢谢你的指教,不


相关问答:

python PIL模块打开图片问题

请问下,我的是python2.5安装了PIL模块,然后编写程序打开本机上的一个图片时,为什么老出现错误呢,老是找不到图片,错误提示如下:File "C:\Python25\Lib\site-packages\PIL\Image.py", line 1888, in o ......

python正则表达式 如何取出以下字符串 多谢

s='aaa111aaa,bbb222,333ccc,444ddd444,555eee666,fff777ggg'
用正则表达式取出 前后字母相同的数据 结果如下:
111 ddd
谢谢~
Python code:

import re
s='aaa111aaa,bbb222,333ccc,444ddd444,555eee666,ff ......

python怎么print 'hello world'

大家好,我是一个新手,刚开始学python,但是刚开始的helloworld都没法打印,让我很无奈。
我的python安装路径为f:\python31。在path中也设置对了,在windows下运行是这样显示的,希望各位前辈指点一下。谢谢
Pyth ......

python解析xml文件

使用xml.dom解析几兆的xml文件,非常缓慢,有种假死的感觉。怎么解决?用其他库是否会好些,暂时只知道这个库的。
你可以试一下ElementTree


python的官方例子
import xml.parsers.expat

# 3 handler ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号