Self.button = tk.Button(self, text="Open a new window", command=self. A Toplevel widget is used to create a window on top of all other windows. Note: For more information, refer to Python GUI tkinter. This is a small working example where you can see how it would work: import Tkinter as tk Tkinter uses an object-oriented approach to make GUIs. aka config destroy () identify (x, y) instate (statespec, callbackNone, args, kw) keys () lower (belowThisNone) state (statespecNone) tkraise (aboveThisNone). To set this attribute to None when you close the window, you can use the protocol method to set a callback. Method resolution order PanedWindow Widget BaseWidget Misc Pack Place Grid Constructor & Destructor Documentation def ( args ) Construct a panedwindow widget with the parent MASTER. Methods: Inherited from ttk.Widget: bindtags (tagListNone) cget (key) configure (cnfNone, kw). aka config destroy () keys () lower (belowThisNone) tkraise (aboveThisNone). Even Tkinter has lots of classes with its respective methods, so it looks like it is necessary for your purpose.īack to your question, a solution could be setting the Toplevel window as an attribute of a class where you wrap all your application, and only open a new window if this attribute is None. Methods: Inherited from Widget: bindtags (tagListNone) cget (key) configure (cnfNone, kw). The alternative (global variables and functions everywhere) is not definitely a good approach. import random from tkinter import from PIL import ImageTk, Image root Tk () root.title ('DVD Logo') root.resizable (False, False) root.attributes ('-fullscreen', True) width root.winfoscreenwidth () height root.winfoscreenheight () dvdvermelho Image.open ('dvdvermelho.png').resize ( (256, 256)) dvdverde Image. Sooner or later, you'll have to understand object-oriented programming if you want to program in Python successfully. I am not (yet) a OOP programmer so please avoid that paradigm if possible.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |