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.

17. Toplevel: Top-level window methodsYou can get the top-level widget from any widget w using w.wm_toplevel().Toplevel ( options )Options include:backgroundborderwidthclass_The background color of the window. May be abbreviatedas bg.Border width in pixels. May be abbreviated as bd.You can give a Toplevel window a “class”name. Such names are matched against the optiondatabase, so your application can pick up theuser’s configuration p<strong>reference</strong>s (such as colors) byclass name. For example, you might design a seriesof popups called “screamers,” and set them allup with class_="Screamer". Then you can put aline in your option database like this:*Screamer*background:and then, if you use the .option_readfile()method to read your option database, all widgetswith that class name will default to a red background.This option is named class_ because in<strong>Python</strong> class is a reserved word.cursorThe cursor that appears when the mouse is in thiswindow.heightWindow height in pixels.relief One of: FLAT (the default), SUNKEN, RAISED,GROOVE, or RIDGE.widthWindow width in pixels.These methods are available <strong>for</strong> top-level windows:.aspect ( n min , d min , n max , d max )Constrain the root window’s width:length ratio to the range [n min =d min ; n max =d max ]..deiconify()If iconified, expand..geometry ( newGeometry=None )Set the window geometry. The argument has the <strong>for</strong>m "wxh ¦ x ¦ y"; if omitted, thecurrent geometry string is returned..iconify()Iconify the window..lift ( aboveThis=None )To raise this window to the top of the stacking order in the window manager, call thismethod with no arguments. You can also raise it to a position in the stacking order justabove another Toplevel window by passing that window as an argument.redNew Mexico Tech Computer Center <strong>Tkinter</strong> <strong>reference</strong>: Top-level window methods Page 60

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

Saved successfully!

Ooh no, something went wrong!