+ 1
widgets in Python using tkinter
In the following code, why pack() is not used and still it is working ? Also while using mainloop() , there is no prefix widget object and still it works ? https://code.sololearn.com/c9FCgn9eXXe4 (It will not work in the online IDE)
5 Answers
+ 2
Diego please see this
+ 2
mainloop() can be used without a widget object. There's not much difference in the normal case.
>>> help(tkinter.Tk.mainloop)
mainloop(self, n=0)
Call the mainloop of Tk.
>>> help(tkinter.mainloop)
mainloop(n=0)
Run the mainloop of Tcl.
Where would widget.pack() be in your code?
+ 1
Diego
widget.pack() is not in this code but generally I had used only pack() and it is still working in other code
Also what is Tcl ? When should we use mainloop() and when wd.mainloop()
(wd is the name of random widget)
+ 1
Tcl: Embeddable scripting language.
Tk: GUI toolkit and widgets based on Tcl.
https://wiki.tcl-lang.org/page/An+Overview+of+Tcl+and+Tk
About mainloop() vs widget.mainloop():
https://stackoverflow.com/questions/51428209/
Same answer goes for pack() and widget.pack().
+ 1
Diego thanks.
Also there is an answer on stackoverflow about pack( ) topic which is very useful. You can also refer.