Change Default Tkinter Entry Value In Python
checkLabel = ttk.Label(win,text = ' Check Amount ', foreground = 'blue') checkLabel.grid(row = 0 , column = 1) checkEntry = ttk.Entry(win, textvariable = checkVariable) checkEntr
Solution 1:
Use the entry widget's function, .insert()
and .delete()
. Here is an example.
entry = tk.Entry(root)
entry.insert(END, "Hello") # this will start the entry with "Hello" in it# you may want to add a delay or something here.
entry.delete(0, END) # this will delete everything inside the entry
entry.insert(END, "WORLD") # and this will insert the word "WORLD" in the entry.
Another way to do this is with the Tkinter StrVar. Here is an example of using the str variable.
entry_var = tk.StrVar()
entry_var.set("Hello")
entry = tk.Entry(root, textvariable=entry_var) # when packing the widget# it should have the world "Hello" inside.# here is your delay or you can make a function call.
entry_var.set("World") # this sets the entry widget text to "World"
Post a Comment for "Change Default Tkinter Entry Value In Python"