【发布时间】:2022-11-29 16:59:40
【问题描述】:
我有一个将我的列表存储到文本文件的输入字段 当我按下按钮存储信息时,它被存储但我必须重新启动应用程序才能在选项菜单上看到它 如何在不重启的情况下更新应用程序? `
from tkinter import *
from tkinter import messagebox
root = Tk()
root.title("test tool") #App Title
root.iconbitmap("D:\\Software\\GigaPixel Frames\\Dump\\New folder\\imgs\\Logo.ico")
root.geometry("1600x800") #App Dimensions
DropDownvar = StringVar(value="Select an option")
DropDownvar.set("Select an option")
my_list = open("Characters.txt").readlines()
DropDownMenu = OptionMenu(root, DropDownvar, *my_list)
DropDownMenu.pack()
inputBox = Entry(root)
inputBox.pack()
def ButtonFun():
InputBoxEntry = inputBox.get()
with open("Characters.txt", "a") as text_file:
text_file.write(InputBoxEntry + "\n")
root.update()
inputBoxButton = Button(root, text="Input", command=ButtonFun)
inputBoxButton.pack()
root.mainloop()
`
找不到答案
【问题讨论】: