22.07.2013 Views

A Comprehensive Introduction to Python Programming and ... - MSDL

A Comprehensive Introduction to Python Programming and ... - MSDL

A Comprehensive Introduction to Python Programming and ... - MSDL

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

3.2 The Different Widgets 29 / 75<br />

Option Description<br />

selectmode Specifies the selection mode. One of SINGLE,<br />

BROWSE, MULTIPLE, or EXTENDED. Default is<br />

BROWSE. Use MULTIPLE <strong>to</strong> get checklist behavior,<br />

EXTENDED if the user usually selects one item, but<br />

sometimes would like <strong>to</strong> select one or more ranges of<br />

items.<br />

xscrollcomm<strong>and</strong>,<br />

yscrollcomm<strong>and</strong> Used <strong>to</strong> connect a listbox <strong>to</strong> a scrollbar. These options<br />

should be set <strong>to</strong> the set methods of the corresponding<br />

scrollbars.<br />

The Listbox widget defines the following methods:<br />

Method Description<br />

delete(index),<br />

delete(first, last) Deletes one or more items. Use delete(0, END) <strong>to</strong><br />

delete all items in the list.<br />

get(index) Gets one or more items from the list. This function<br />

returns the string corresponding <strong>to</strong> the given index (or<br />

the strings in the given index range). Use get(0, END)<br />

<strong>to</strong> get a list of all items in the list. Use ACTIVE <strong>to</strong> get<br />

the selected (active) item(s).<br />

insert(index, items) Inserts one or more items at given index (index 0 is<br />

before the first item). Use END <strong>to</strong> append items <strong>to</strong> the<br />

list. Use ACTIVE <strong>to</strong> insert items before the selected<br />

(active) item.<br />

size( ) Returns the number of items in the list.<br />

3.2.8 Menu<br />

The Menu widget is used <strong>to</strong> implement <strong>to</strong>plevel, pulldown, <strong>and</strong> popup menus.<br />

The Menu widget provides the following options:<br />

Option Description<br />

postcomm<strong>and</strong> If specified, this callback is called whenever Tkinter<br />

is about <strong>to</strong> display this menu. If you have dynamic<br />

menus, use this callback <strong>to</strong> update their contents.<br />

tearoff If set, menu entry 0 will be a “tearoff entry”, which is<br />

usually a dashed separa<strong>to</strong>r line. If the user selects this<br />

entry, Tkinter creates a small Toplevel with a copy of<br />

this menu.<br />

tearoffcomm<strong>and</strong> If specified, this callback is called when this menu is<br />

teared off.<br />

title Specifies the title of menu.<br />

The Menu widget defines the following methods:

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

Saved successfully!

Ooh no, something went wrong!