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.bind ( sequence=None, func=None, add=None )This method is used to attach an event binding to a widget. See Events, below, <strong>for</strong> theoverview of event bindings.The sequence argument describes what event we expect, and the func argument is afunction to be called when that event happens to the widget. If there was already abinding <strong>for</strong> that event <strong>for</strong> this widget, normally the old callback is replaced with func,but you can keep them both by passing add="+".w.bind_all ( sequence=None, func=None, add=None )Like .bind(), but applies to all widgets in the entire application.w.bind_class ( className, sequence=None, func=None, add=None )Like .bind(), but applies to all widgets named className (e.g., "Button").w.bindtags ( tagList=None )If you call this method, it will return the “binding tags” <strong>for</strong> the widget as a sequence ofstrings. A binding tag is the name of a window (starting with ".") or the name of a class(e.g., "Listbox").You can change the order in which binding levels are called by passing as an argumentthe sequence of binding tags you want the widget to use.See Events, below, <strong>for</strong> a discussion of binding levels and their relationship to tags.w.cget ( option )Returns the current value of option as a string. You can also get the value of an option<strong>for</strong> widget w as w[option].w.clipboard_append ( string )Appends the given string to the display’s clipboard, where cut and pasted strings arestored <strong>for</strong> all that display’s applications.w.clipboard_clear()Clears the display’s clipboard (see .clipboard_append(), above)..config ( option=value, ... ).configure ( option=value, ... )Set the values of one or more options. For the options whose names are <strong>Python</strong> reservedwords (class, tt from, in), use a trailing underbar: class_, tt from_, in_).You can also set the value of an option <strong>for</strong> widget w with the statementw[option] = valueIf you call the .config() method on a widget with no arguments, you’ll get a dictionaryof all the widget’s current options. The keys are the option names (including aliases likebd <strong>for</strong> borderwidth). The value <strong>for</strong> each key is: <strong>for</strong> most entries, a five-tuple: (option name, option database key, option databaseclass, default value, current value); or, <strong>for</strong> alias names (like “fg”), a two-tuple: (alias name, equivalent standard name).You can use either .config() or .configure(); the two names are equivalent.New Mexico Tech Computer Center <strong>Tkinter</strong> <strong>reference</strong>: Universal widget methods Page 62

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

Saved successfully!

Ooh no, something went wrong!