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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

10. The Listbox widgetThe purpose of a listbox widget is to display a set of lines of text. Generally they areintended to allow the user to select one or more of a list of items. If you need somethingmore like a text editor, see the Text widget, below.To create a new listbox widget inside a root window or frame master:w = Listbox ( master, *options )This constructor returns the new listbox widget. Options:backgroundborderwidthcursorfont<strong>for</strong>egroundheighthighlightbackgroundhighlightcolorhighlightthicknessreliefselectbackgroundselectborderwidthselect<strong>for</strong>egroundselectmodeThe background color in the listbox. May be abbreviatedas bg.The width of the border around the listbox. Defaultis 2. May be abbreviated as bd.The cursor that appears when the mouse is over thelistbox.The font used <strong>for</strong> the text in the listbox. See Fonts,above.The color used <strong>for</strong> the text in the listbox. See Colors,above. May be abbreviated fg.Number of lines (not pixels!) shown in the listbox.Default is 10.Color of the focus highlight when the widget doesnot have focus.Color shown in the focus highlight when the widgethas the focus.Thickness of the focus highlight.Selects three-dimensional shading effects. The defaultis SUNKEN. May also be RAISED, GROOVE,RIDGE, or FLAT.The background color to use displaying selectedtext.The width of the border to use around selected text.The <strong>for</strong>eground color to use displaying selectedtext.Determines how many items can be selected, andhow mouse drags affect the selection:BROWSE: Normally, you can only select one line outof a listbox. If you click on an item and then drag toa different line, the selection will follow the mouse.This is the default.SINGLE: You can only select one line, and you can’tdrag the mouse—wherever you click button 1, thatline is selected.MULTIPLE: You can select any number of lines atonce. Clicking on any line toggles whether it isselected.EXTENDED: You can select any adjacent group oflines at once by clicking on the first line and draggingto the last line.New Mexico Tech Computer Center <strong>Tkinter</strong> <strong>reference</strong>: The Listbox widget Page 31

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

Saved successfully!

Ooh no, something went wrong!