Henlo,
I'm a noob to Python and Tkinter, learning things, Using Python 3.7.4 in a Windows PC, using default IDLE for programming. This is a simple test program for example to my question.
-----------------------
#Example-1
question on Example-1:
If I keep or remove root.mainloop() results will be same, program will run indefinitely. If I keep, it will run without a >>> in the interactive shell of IDLE and on closing the window manually, >>> comes back. If I run it without .mainloop(), >>> comes immediately. On manual closing it another >>> comes on the shell. Button works all the time, until I close it manually. Not only Example-1, all programs works without .mainloop(). If I try to exit any program using a custom exit button/menu item, command line functions cease to respond but window remains open with all widgets on it. Same thing happens when I double click on .py file and let it run on windows command prompt. Is it normal? or a bug? or I'm doing something wrong?
I'm a noob to Python and Tkinter, learning things, Using Python 3.7.4 in a Windows PC, using default IDLE for programming. This is a simple test program for example to my question.
-----------------------
#Example-1
from tkinter import * def printer(event): print('Printing') root = Tk() frame1 = Frame(root) frame1.pack() button1 = Button(root, text='Button', command=printer) button1.pack() root.mainloop()------------------------
question on Example-1:
If I keep or remove root.mainloop() results will be same, program will run indefinitely. If I keep, it will run without a >>> in the interactive shell of IDLE and on closing the window manually, >>> comes back. If I run it without .mainloop(), >>> comes immediately. On manual closing it another >>> comes on the shell. Button works all the time, until I close it manually. Not only Example-1, all programs works without .mainloop(). If I try to exit any program using a custom exit button/menu item, command line functions cease to respond but window remains open with all widgets on it. Same thing happens when I double click on .py file and let it run on windows command prompt. Is it normal? or a bug? or I'm doing something wrong?