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.
谢谢你的指教,不
相关问答:
在list中添加一个类的局部变量 这样做是否合法 请看下面例子:
Python code:
class A():
def __init__( self ):
self.__a = 0
self.__b = 'hello'
def get_a( self ):
ret ......
>>> x=-1
>>> if x>0:
print ('11')
>>> else:
SyntaxError: invalid syntax (<pyshell#20>, line 1)
网上搜的也是:
>>> x=int(input("Please ent ......
我想用python解析网页中的url 在下载之前, 我想先发一个head请求 不需要下载整个网页, 先获得该网站的head信息, 读取一些信息之后 在调用这些库的read方法来读取整个网页 该怎么操作呢 多谢
帮顶了
有人能指教一 ......
异常代码如下:
write a file error: [Errno 2] No such file or directory: 'C:\x0cile.txt'
Traceback (most recent call last):
File "C:\Documents and Settings\USER\桌面\复 ......
以下代码是Tk做了一个简单的密码验证功能,输入一个字符串,并验证其是否正确,请先看代码:
Python code:
from tkinter import *
root = Tk()
e = StringVar()
t = 'cashlu'
def yanzheng():
if e ......