Receiving an AttributeError: 'module' object has no attribute 'Intvar'
Receiving an AttributeError: 'module' object has no attribute 'Intvar'
我不知道我的代码发生了什么。每当我 运行 它时,我都会收到一个
AttributeError: 'module' object has no attribute 'Intvar'
这是我的代码:
import Tkinter
import math
root = Tkinter.Tk()
root.wm_title('Color-Shape Art Creation')
speed_intvar = Tkinter.Intvar()
speed_intvar.set(3)
r=10
x=150
y=150
direction=0.5
canvas = Tkinter.Canvas(root, height=300, width=300, background='white')
canvas.grid(row=0, column=1, rowspan=3)
new_shape = canvas.create_oval(1,1,4,4,outline='white',fill='white')
red_intvar = Tkinter.IntVar()
blue_intvar = Tkinter.IntVar()
green_intvar = Tkinter.IntVar()
shapes = []
class ColorSlider(Tkinter.Scale):
def __init__(self, parent, myLabel, model_intvar, canvas):
def slider_changed(new_val):
tk_color_string = color(red_intvar, blue_intvar, green_intvar)
canvas.itemconfig(shapes[-1],fill=tk_color_string)
Tkinter.Scale.__init__(self, parent, orient=Tkinter.HORIZONTAL, from_=0, to=255,
variable = model_intvar, label=myLabel, command=slider_changed)
red_slider = ColorSlider(root, 'Red: ', red_intvar, canvas)
red_slider.grid(row=1, column=0, sticky=Tkinter.W)
此外,如果我的代码中有任何其他错误或差异,请告诉我!
谢谢!
下一行有错别字:
speed_intvar = Tkinter.Intvar()
Intvar
应替换为 IntVar
:
speed_intvar = Tkinter.IntVar()
# ^
我不知道我的代码发生了什么。每当我 运行 它时,我都会收到一个
AttributeError: 'module' object has no attribute 'Intvar'
这是我的代码:
import Tkinter
import math
root = Tkinter.Tk()
root.wm_title('Color-Shape Art Creation')
speed_intvar = Tkinter.Intvar()
speed_intvar.set(3)
r=10
x=150
y=150
direction=0.5
canvas = Tkinter.Canvas(root, height=300, width=300, background='white')
canvas.grid(row=0, column=1, rowspan=3)
new_shape = canvas.create_oval(1,1,4,4,outline='white',fill='white')
red_intvar = Tkinter.IntVar()
blue_intvar = Tkinter.IntVar()
green_intvar = Tkinter.IntVar()
shapes = []
class ColorSlider(Tkinter.Scale):
def __init__(self, parent, myLabel, model_intvar, canvas):
def slider_changed(new_val):
tk_color_string = color(red_intvar, blue_intvar, green_intvar)
canvas.itemconfig(shapes[-1],fill=tk_color_string)
Tkinter.Scale.__init__(self, parent, orient=Tkinter.HORIZONTAL, from_=0, to=255,
variable = model_intvar, label=myLabel, command=slider_changed)
red_slider = ColorSlider(root, 'Red: ', red_intvar, canvas)
red_slider.grid(row=1, column=0, sticky=Tkinter.W)
此外,如果我的代码中有任何其他错误或差异,请告诉我!
谢谢!
下一行有错别字:
speed_intvar = Tkinter.Intvar()
Intvar
应替换为 IntVar
:
speed_intvar = Tkinter.IntVar()
# ^