小甲鱼的铁粉 发表于 2020-7-23 11:38:49

tkinter的问题

自己打了一下甲鱼哥在视频里面的例子,报错了,麻烦鱼油们看一下吧
代码
from tkinter import *

master = Tk()

s1 = Scale(master, from_=0, to=50, tickinterval=5, length=200)
s1.pack()
s2 = Scale(master, from_=0, to=200, tickinterval=5,orient=HORIZONTAL,length=1000)
s2.pack()

def show():
    print(s1.get(),s2,get())
   
Button(master, text="选择吧", command=show).pack()

mainloop()


报错内容
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\86188\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py", line 1883, in __call__
    return self.func(*args)
File "C:\Users\86188\Desktop\Python\课后作业\65-78Tkinter\class5_3.py", line 11, in show
    print(s1.get(),s2,get())
NameError: name 'get' is not defined

zltzlt 发表于 2020-7-23 11:40:19

打错符号了,, 打成了 .,敲代码可得细心一点呢{:10_277:}

正确代码:

from tkinter import *

master = Tk()

s1 = Scale(master, from_=0, to=50, tickinterval=5, length=200)
s1.pack()
s2 = Scale(master, from_=0, to=200, tickinterval=5, orient=HORIZONTAL, length=1000)
s2.pack()


def show():
    print(s1.get(), s2. get())


Button(master, text="选择吧", command=show).pack()

mainloop()

小甲鱼的铁粉 发表于 2020-7-23 11:41:31

zltzlt 发表于 2020-7-23 11:40
打错符号了,, 打成了 .,敲代码可得细心一点呢

正确代码:

{:10_266:}
页: [1]
查看完整版本: tkinter的问题