+ 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)

25th Jun 2019, 12:48 AM
harshit
harshit - avatar
5 odpowiedzi
+ 2
Diego please see this
25th Jun 2019, 2:06 AM
harshit
harshit - avatar
+ 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?
25th Jun 2019, 3:44 AM
Diego
Diego - avatar
+ 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)
25th Jun 2019, 11:55 PM
harshit
harshit - avatar
+ 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().
26th Jun 2019, 12:20 AM
Diego
Diego - avatar
+ 1
Diego thanks. Also there is an answer on stackoverflow about pack( ) topic which is very useful. You can also refer.
26th Jun 2019, 2:17 AM
harshit
harshit - avatar