Note: if the widget is destroyed, it cannot be restored again. Print ( "Checking for existance =", bool (widget.winfo_exists ()))ī2 = Button (root, text = "Btn 2", command = lambda : dest (b1))ī3 = Button (root, text = "Btn 3", command = lambda : exist (b1)) Print ( "Destroy method called. Widget exists? = " , Syntax: widget.winfo_exists () Return value: Returns True if widget exists, False otherwise. A toplevel has an owner which can be the Tk root window or other application window. Instead we have Toplevel for new toplevel windows (ie dialogs). ![]() However, you should not be calling Tk() again in the message function. This method is used to check if the specified widget exists or not, i.e. widget destroyed or not. You can check for the existence of a window using the winfoexists() method of the widget object. # infinite loop, interrupted by keyboard or mouse mainloop () # This is used to make the widget invisibleī2 = Button (root, text = "Btn 2", command = lambda : forget (b1))ī3 = Button (root, text = " Btn 3 ", command = lambda : retrieve (b1)) Print ( "After Forget method called. Is widget mapped? = " , I enclose a script to better clarify what I would like to do. However, I cannot test the existence of a Toplevel by passing the name of this to winfoexists () method. Exception: If widget is destroyed, then it throws error. I’m trying to test the existence of a toplevel using the winfoexists () method made available by Tkinter. In order of preference: Add self.weightingFuncNameDim2 None to your class' init method, and change your if condition to if self. Syntax: widget.winfo_ismapped () Return Value: Returns True if widget is visible (or mapped), otherwise returns False. 1,754 7 27 38 Add a comment 2 Answers Sorted by: 5 I see three possible solutions. This method is used to test, whether the specified widget is visible or not. ![]() It provides all the essentials about core Tk concepts, the various widgets, layout, events and more that you need for your application. Tkinter provides many generic widget methods or base widget methods that work with almost all available widgets. This tutorial will quickly get you up and running with the latest Tk from Python, Tcl, Ruby, and Perl on macOS, Windows, or Linux.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |