12.07.2015 Views

Tkinter reference: A GUI for Python

Tkinter reference: A GUI for Python

Tkinter reference: A GUI for Python

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

w.focus_set()If w’s application has the input focus, the focus will jump to w. If w’s application doesn’thave focus, Tk will remember to give it to w next the application gets focus.w.grab_current()If there is a grab in <strong>for</strong>ce <strong>for</strong> w’s display, return its identifier, otherwise return None. Referto Events, below, <strong>for</strong> a discussion of grabs.w.grab_release()If w has a grab in <strong>for</strong>ce, release it.w.grab_set()Widget w grabs all events <strong>for</strong> w’s application. If there was another grab in <strong>for</strong>ce, it goesaway. See Events, below, <strong>for</strong> a discussion of grabs.w.grab_set_global()Widget w grabs all events <strong>for</strong> the entire screen. This is considered impolite and shouldbe used only in great need. Any other grab in <strong>for</strong>ce goes away.w.grab_status()If there is a local grab in <strong>for</strong>ce (set by .grab_set()), this method returns the string"local". If there is a global grab in <strong>for</strong>ce (from .grab_set_global()), it returns"global". If no grab is in <strong>for</strong>ce, it returns None.w.image_names()Returns the names of all the images in w’s application as a sequence of strings.w.keys()Returns the option names <strong>for</strong> the widget as a sequence of strings.w.mainloop()This method must be called, generally after all the static widgets are created, to startprocessing events. You can leave the main loop with the .quit() method (below). Youcan also call this method inside an event handler to resume the main loop.w.nametowidget ( name )This method returns the actual widget whose path name is name. The path name <strong>for</strong> anywidget x is str(x); see also the .winfo_pathname() method, below.w.option_add ( pattern, value, priority=None )This method adds default option values to the <strong>Tkinter</strong> option database. The pattern isa string that specifies a default value <strong>for</strong> options of one or more widgets. The priorityvalues are one of:widgetDefault Level 20, <strong>for</strong> global default properties of widgets.startupFile Level 40, <strong>for</strong> default properties of specificapplications.userDefaultLevel 60, <strong>for</strong> options that come from user files suchas their .Xdefaults file.interactiveLevel 80, <strong>for</strong> options that are set after the applicationstarts up. This is the default priority level.New Mexico Tech Computer Center <strong>Tkinter</strong> <strong>reference</strong>: Universal widget methods Page 64

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!