I have a very simple app in Tkinkter. I am running it in Ipython Notebook.
The issue is whenever i run the app and press the button 'Get' once, nothing is returned. I press the button again and two values are returned. I press button 3 or more times and 1 value is returned per time I press the button as expected. The issue is around the first press of the button. Is there something going on I do not understand.
from tkinter import *
from tkinter import ttk, Tk
class SampleApp(tk.Tk):
def __init__(self):
tk.Tk.__init__(self)
self.entry = tk.Entry(self)
self.button = tk.Button(self, text="Get", command=self.on_button)
self.button.pack()
self.entry.pack()
def on_button(self):
value = float(self.entry.get())
print (value*2)
app = SampleApp()
app.mainloop()
input = 5
output i get after 1 button press (not expected)
nothing
after 2 button presses (whilst i would expect 2 values at this stage, i do not expect 2 values to appear at the same time)
10
10
after 3 button presses (expected)
10
10
10
after 4 button presses (expected)
10
10
10
10