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.
谢谢你的指教,不
相关问答:
我每次上传的文件读到的数据都不正确。2M 的图片读得10多K 。。哪位大侠可以帮帮我啊。
#!D:\ProgrammerTools\python26\python.exe
#encoding=utf-8
import cgitb
import os
cgitb.enable()
import cgi,urllib ......
>>> x=-1
>>> if x>0:
print ('11')
>>> else:
SyntaxError: invalid syntax (<pyshell#20>, line 1)
网上搜的也是:
>>> x=int(input("Please ent ......
python的PIL库自带的方法只能进行矩形的切割,如果我有了一个多边形各个顶点的坐标,如何对现有的图片按照这个多边形进行切割呢?
不一定要用PIL库,任何能实现这个功能的方法都行。
图片切割的js不是很多吗?
......
异常代码如下:
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\桌面\复 ......
RT。
我想要下载一个网站上的图片,但是该网站的图片地址是通过浏览器执行网页的JavaScript脚本后才返回的,使用urllib2的urlopen只能得到带有JavaScript代码的网页源代码。
想要用wx模块的wx.lib.iew ......