So, I am making a program that requires the user to enter a value. I want the value to be displayed through the message widget (or label widget) and updated whenever a new input is entered.
def Enter(): s = v.get() print (v.get()) e.delete(0, END) e.insert(0, "")
Is there a way for v to replace Message Widget text ??
Note:
If I replaced text with textvariable , it will update the text after each key is pressed, where I need it to be updated when the user clicks the button.
My full code is:
from tkinter import * import os # All Functions Below def callback(): print ("HI") def Exit(): os._exit(0) def Enter(): s = e.get() print (e.get()) m.configure(text=s) e.delete(0, END) e.insert(0, "") def Population(): root = Tk root.mainloop() def SurvivalRate(): root = Tk root.mainloop() def BirthRate(): root = Tk root.mainloop() def NewGen(): root = Tk root.mainloop() root = Tk() generation = 0 menubar = Menu(root) menubar.add_command(label="Hello!", command=callback) menubar.add_command(label="Quit!", command=Exit) # Area To Enter Text e = Entry(root) e.pack() m = Message(root, text = e) m.pack() # Enter Button b = Button(root, text="OK", command=Enter) b.pack() Pop = Button(root, text="Population", command=Population) Pop.pack()
source share