Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/322.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Tkinter语法错误,位于;文本=”文本;“一些随机文本”;_Python_Tkinter_Syntax - Fatal编程技术网

Python Tkinter语法错误,位于;文本=”文本;“一些随机文本”;

Python Tkinter语法错误,位于;文本=”文本;“一些随机文本”;,python,tkinter,syntax,Python,Tkinter,Syntax,我是编程新手,从python和Tkinter开始。 我在线观看了这个教程视频,在试图理解它的同时,我完全按照教程中的那个家伙所做的那样编写了代码。但是,我遇到语法错误,无法运行它 对不起,这是我在这里的第一篇文章。好的,下面是代码: from tkinter import * #key down function def click(): entered_text=textentry.get() #this will collect the text from the text ent

我是编程新手,从python和Tkinter开始。 我在线观看了这个教程视频,在试图理解它的同时,我完全按照教程中的那个家伙所做的那样编写了代码。但是,我遇到语法错误,无法运行它

对不起,这是我在这里的第一篇文章。好的,下面是代码:

from tkinter import *

#key down function
def click():
    entered_text=textentry.get() #this will collect the text from the text entry box
    output.delete(0,0, END)
    try:
        definition = my_compdictionary[entered_text]
    except:
        definition = "Sorry there is no word like that , try again"
        output.insert(END, definition)
#MAIN
window = Tk()
window.title("My computer Science Glosarry")
#MY PHOTO
photo1 = PhotoImage(file="C:/Users/zahar/Desktop/photo2.gif")
Label (window, image=photo1, bg="black") .grid(row=0, column=0, sticky=E)
# create label
Label = (window, text="Enter a word you would like a definition for:", bg="black", fg="white", font="none 12 bold") .grid(row1, column=0, sticky=W)
你错过了什么:)

#


请发布代码的最小版本,该版本仍以文本形式复制错误供我们复制。
Label=(窗口,文本…
语法不正确请不要发布代码图片的链接。花点时间直接在问题中复制、粘贴并正确设置格式。图片不可搜索,我们无法复制和粘贴代码来重现问题。@BryanOakley在这种情况下,我们也可以获得隐私信息:|@Atlas435 OP有责任提供详细信息并确保删除个人信息。特别要求以文本格式发布有问题的代码。我怀疑其目的是重新分配名称
标签
。要么他需要这样做。配置,要么他试图创建两个。不确定他使用
Label
作为变量试图避免什么,因为它将覆盖类
Label
。我的观点是
=
符号很可能是多余的,即
Label=(window,…)
应该是
Label(window,…)
@r.ook这是另一种可能的解决方案。
Label1 = tk.Label(window..)
#####^use Label1 instead of Label, cause you cold overwrite the tk class
from tkinter import *

#key down function
def click():
    entered_text=textentry.get() #this will collect the text from the text entry box
    output.delete(0,0, END)
    try:
        definition = my_compdictionary[entered_text]
    except:
        definition = "Sorry there is no word like that , try again"
        output.insert(END, definition)
#MAIN
window = Tk()
window.title("My computer Science Glosarry")
#MY PHOTO
photo1 = PhotoImage(file="C:/Users/zahar/Desktop/photo2.gif")
Label(window, image=photo1, bg="black").grid(row=0, column=0, sticky=E)
# create label
Label(window, text="Enter a word you would like a definition for:", bg="black", fg="white", font="none 12 bold").grid(row1, column=0, sticky=W)
######^ here is the syntax error
###### either you do Label(window...)
###### or you sign a variable to the label like Label1 = Label(window...)