I'm new in python Tkinter and finding an issue here. I'm trying to get input from the user without pressing enter and want to use the input as updated label2
. However, I'm getting an updated label only when while
loop finish executing (only last input is getting displayed). Can you please help me to know where I am going wrong?
import tkinter as tk
import msvcrt
root= tk.Tk()
myCanvas = tk.Canvas(root, width = 500, height = 200)
myCanvas.pack()
def do_printing():
count=1
while (count>0):
print('Count before= ',count)
while 1:
input1 = msvcrt.getwch()
count=count+1
break
label2 = tk.Label(root, font=('Arial', 20))
label2.config(text=input1)
myCanvas.create_window(100, 50, window=label2)
if count==7:
break
print('finished')
B1 = tk.Button(root, text ="Option 1", font=('Courier', 12), command= do_printing)
myCanvas.create_window(40, 30, window=B1)
root.mainloop()