我想知道是否有人可以給我一個簡單的解決我的問題。 我正在嘗試製作一個程序(作爲一個gcse模擬),它將獲得句子中單詞的位置。Python Tkinter/GUI不更新/正常工作
我在句子中的句子很棒,但是我想要超越以獲得最高的分數,所以我用gui重新創建它!
到目前爲止,我有下面的代碼,它不能正常工作,它不更新'句子'變量,我正在尋找一個簡單的方法來解決這個問題而不是更新。我得到一些隨機數,我不確定它來自哪裏。任何幫助都感激不盡。 :)
#MY CODE:
#GCSE MOCK TASK WITH GUI
import tkinter
from tkinter import *
sentence = ("Default")
window = tkinter.Tk()
window.resizable(width=FALSE, height=FALSE)
window.title("Sentence")
window.geometry("400x300")
#Add custom logo here later on
def findword():
print ("")
sentencetext = tkinter.Label(window, text="Enter Sentence: ")
sentence = tkinter.Entry(window)
sentencebutton = tkinter.Button(text="Submit")
findword = tkinter.Label(window, text="Enter Word To Find: ")
wordtofind = tkinter.Entry(window)
findwordbutton = tkinter.Button(text="Find!", command = findword)
usersentence = sentence.get()
usersentence = tkinter.Label(window,text=sentence)
shape = Canvas (bg="grey", cursor="arrow", width="400", height="8")
shape2 = Canvas (bg="grey", cursor="arrow", width="400", height="8")
#Packing & Ordering Modules
sentencetext.pack()
sentence.pack()
sentencebutton.pack()
shape.pack()
findword.pack()
wordtofind.pack()
findwordbutton.pack()
usersentence.pack()
shape2.pack()
window.mainloop()
歡迎來到Stack Overflow。我剛剛編輯了你的文章來修復一些語法問題,並且爲了可讀性而分手了。 –