混乱して申し訳ありません。ラベル内のコンテンツを消去するにはどうすればよいですか?
私は座席図を作成していますので、正しく動作するように思われます。私は実行ボタンを押すたびにラベルをリセットするようにしています。
#commands: add name , Run
#imports
import random
from time import sleep
from tkinter import *
#Console and background Handlers
Tables = 6
Names = []
def AddNames():
NewNames = e.get("1.0", 'end -1c')
if NewNames in Names:
print("Name Already exists")
elif NewNames == "":
print("Empty")
else:
Names.append(NewNames)
print(Names)
e.delete(1.0, END)
def Random():
RandomNum = random.randrange(Tables)
if RandomNum == 0:
RandomNum = random.randrange(Tables)
return RandomNum
def run():
X = 0
for i in Names:
#print(Names[X])
print("Table: " + str(Random()))
X += 1
#text = Label(popup, text = "")
text = Label(popup, text= Names[X] + "\n" + "Table: " + str(Random()))
text.pack()
#GUI Handler
root = Tk()
root.geometry("1024x768")
e = Text(root, bd = 10, font=("Comic Sans MS", 50) ,width = 15, height = 2)
e.pack()
popup = Toplevel()
popup.title("Seating Chart")
AddNameButton = Button(root, text = ("Add Name"), width = 15, height = 5, command = AddNames)
AddNameButton.pack()
RunButton = Button(root, text = ("Run"), width = 15, height = 5, command = run)
RunButton.pack()
root.mainloop()
私は、テキストをリセットしようとしていたユーザが実行ボタン
を押すたびに、あなただけに、実行機能をしたいかは、内容を消去するか、それはあまりにも何かをしますか? –
実行関数kindは、異なる名前に番号を割り当てます。 – PinkChicken
すでに 'AddNames()'メソッドで行っています。 – Zety