易截截图软件、单文件、免安装、纯绿色、仅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正则表达式 如何取出以下字符串 多谢

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

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

IIS 7 python 2.6 cgi 文件上传问题

我每次上传的文件读到的数据都不正确。2M 的图片读得10多K 。。哪位大侠可以帮帮我啊。
#!D:\ProgrammerTools\python26\python.exe
#encoding=utf-8
import cgitb
import os
cgitb.enable()
import cgi,urllib ......

python 3.x的if语句

>>> x=-1
>>> if x>0:
print ('11')

>>> else:

SyntaxError: invalid syntax (<pyshell#20>, line 1)
网上搜的也是:
>>> x=int(input("Please ent ......

python解析xml文件

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


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

# 3 handler ......

python win下调用dll

  小弟接触python 2个星期了,安装的是python3.1版。
我用的是windows7,想写个调用dll的程序实践。问题来了:

C++代码:
extern "C" int __stdcall test();

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