tkinter.tix
— Extension widgets for Tk¶
Source code:Lib/tkinter/tix.py
Αποσύρθηκε στην έκδοση 3.6:This Tk extension is unmaintained and should not be used in new code. Usetkinter.ttk
instead.
Thetkinter.tix
(Tk Interface Extension) module provides an additionalrich set of widgets. Although the standard Tk library has many useful widgets,they are far from complete. Thetkinter.tix
library provides most of thecommonly needed widgets that are missing from standard Tk:HList
,ComboBox
,Control
(a.k.a. SpinBox) and an assortment ofscrollable widgets.tkinter.tix
also includes many more widgets that are generally useful ina wide range of applications:NoteBook
,FileEntry
,PanedWindow
, etc; there are more than 40 of them.
With all these new widgets, you can introduce new interaction techniques intoapplications, creating more useful and more intuitive user interfaces. You candesign your application by choosing the most appropriate widgets to match thespecial needs of your application and users.
Δείτε επίσης
- Tix Homepage
The home page for
Tix
. This includes links to additional documentationand downloads.- Tix Man Pages
On-line version of the man pages and reference material.
- Tix Programming Guide
On-line version of the programmer’s reference material.
- Tix Development Applications
Tix applications for development of Tix and Tkinter programs. Tide applicationswork under Tk or Tkinter, and includeTixInspect, an inspector toremotely modify and debug Tix/Tk/Tkinter applications.
Using Tix¶
- classtkinter.tix.Tk(screenName=None,baseName=None,className='Tix')¶
Toplevel widget of Tix which represents mostly the main window of anapplication. It has an associated Tcl interpreter.
Classes in the
tkinter.tix
module subclasses the classes in thetkinter
. The former imports the latter, so to usetkinter.tix
with Tkinter, all you need to do is to import one module. In general, youcan just importtkinter.tix
, and replace the toplevel call totkinter.Tk
withtix.Tk
:fromtkinterimporttixfromtkinter.constantsimport*root=tix.Tk()
To usetkinter.tix
, you must have the Tix widgets installed, usuallyalongside your installation of the Tk widgets. To test your installation, trythe following:
fromtkinterimporttixroot=tix.Tk()root.tk.eval('package require Tix')
Tix Widgets¶
Tixintroduces over 40 widget classes to thetkinter
repertoire.
Basic Widgets¶
- classtkinter.tix.Balloon¶
ABalloon thatpops up over a widget to provide help. When the user moves the cursor inside awidget to which a Balloon widget has been bound, a small pop-up window with adescriptive message will be shown on the screen.
- classtkinter.tix.ButtonBox¶
TheButtonBoxwidget creates a box of buttons, such as is commonly used for
OkCancel
.
- classtkinter.tix.ComboBox¶
TheComboBoxwidget is similar to the combo box control in MS Windows. The user can select achoice by either typing in the entry subwidget or selecting from the listboxsubwidget.
- classtkinter.tix.Control¶
TheControlwidget is also known as the
SpinBox
widget. The user can adjust thevalue by pressing the two arrow buttons or by entering the value directly intothe entry. The new value will be checked against the user-defined upper andlower limits.
- classtkinter.tix.LabelEntry¶
TheLabelEntrywidget packages an entry widget and a label into one mega widget. It canbe used to simplify the creation of «entry-form» type of interface.
- classtkinter.tix.LabelFrame¶
TheLabelFramewidget packages a frame widget and a label into one mega widget. To createwidgets inside a LabelFrame widget, one creates the new widgets relative to the
frame
subwidget and manage them inside theframe
subwidget.
- classtkinter.tix.Meter¶
TheMeter widgetcan be used to show the progress of a background job which may take a long timeto execute.
- classtkinter.tix.OptionMenu¶
TheOptionMenucreates a menu button of options.
- classtkinter.tix.PopupMenu¶
ThePopupMenuwidget can be used as a replacement of the
tk_popup
command. The advantageof theTix
PopupMenu
widget is it requires less application codeto manipulate.
- classtkinter.tix.Select¶
TheSelect widgetis a container of button subwidgets. It can be used to provide radio-box orcheck-box style of selection options for the user.
- classtkinter.tix.StdButtonBox¶
TheStdButtonBoxwidget is a group of standard buttons for Motif-like dialog boxes.
File Selectors¶
- classtkinter.tix.DirList¶
TheDirListwidget displays a list view of a directory, its previous directories and itssub-directories. The user can choose one of the directories displayed in thelist or change to another directory.
- classtkinter.tix.DirTree¶
TheDirTreewidget displays a tree view of a directory, its previous directories and itssub-directories. The user can choose one of the directories displayed in thelist or change to another directory.
- classtkinter.tix.DirSelectDialog¶
TheDirSelectDialogwidget presents the directories in the file system in a dialog window. The usercan use this dialog window to navigate through the file system to select thedesired directory.
- classtkinter.tix.DirSelectBox¶
The
DirSelectBox
is similar to the standard Motif(TM)directory-selection box. It is generally used for the user to choose adirectory. DirSelectBox stores the directories mostly recently selected intoa ComboBox widget so that they can be quickly selected again.
- classtkinter.tix.ExFileSelectBox¶
TheExFileSelectBoxwidget is usually embedded in a tixExFileSelectDialog widget. It provides aconvenient method for the user to select files. The style of the
ExFileSelectBox
widget is very similar to the standard file dialog onMS Windows 3.1.
- classtkinter.tix.FileSelectBox¶
TheFileSelectBoxis similar to the standard Motif(TM) file-selection box. It is generally usedfor the user to choose a file. FileSelectBox stores the files mostly recentlyselected into a
ComboBox
widget so that they can be quickly selectedagain.
Hierarchical ListBox¶
- classtkinter.tix.HList¶
TheHList widgetcan be used to display any data that have a hierarchical structure, for example,file system directory trees. The list entries are indented and connected bybranch lines according to their places in the hierarchy.
Tabular ListBox¶
- classtkinter.tix.TList¶
TheTList widgetcan be used to display data in a tabular format. The list entries of a
TList
widget are similar to the entries in the Tk listbox widget. Themain differences are (1) theTList
widget can display the list entriesin a two dimensional format and (2) you can use graphical images as well asmultiple colors and fonts for the list entries.
Manager Widgets¶
- classtkinter.tix.PanedWindow¶
ThePanedWindowwidget allows the user to interactively manipulate the sizes of several panes.The panes can be arranged either vertically or horizontally. The user changesthe sizes of the panes by dragging the resize handle between two panes.
- classtkinter.tix.ListNoteBook¶
TheListNoteBookwidget is very similar to the
TixNoteBook
widget: it can be used todisplay many windows in a limited space using a notebook metaphor. The notebookis divided into a stack of pages (windows). At one time only one of these pagescan be shown. The user can navigate through these pages by choosing the name ofthe desired page in thehlist
subwidget.
- classtkinter.tix.NoteBook¶
TheNoteBookwidget can be used to display many windows in a limited space using a notebookmetaphor. The notebook is divided into a stack of pages. At one time only one ofthese pages can be shown. The user can navigate through these pages by choosingthe visual «tabs» at the top of the NoteBook widget.
Image Types¶
Thetkinter.tix
module adds:
pixmapcapabilities to all
tkinter.tix
andtkinter
widgets to createcolor images from XPM files.Compound imagetypes can be used to create images that consists of multiple horizontal lines;each line is composed of a series of items (texts, bitmaps, images or spaces)arranged from left to right. For example, a compound image can be used todisplay a bitmap and a text string simultaneously in a Tk
Button
widget.
Miscellaneous Widgets¶
Form Geometry Manager¶
In addition,tkinter.tix
augmentstkinter
by providing:
Tix Commands¶
- classtkinter.tix.tixCommand¶
Thetix commands provideaccess to miscellaneous elements of
Tix
’s internal state and theTix
application context. Most of the information manipulated by thesemethods pertains to the application as a whole, or to a screen or display,rather than to a particular window.To view the current settings, the common usage is:
fromtkinterimporttixroot=tix.Tk()print(root.tix_configure())
- tixCommand.tix_configure(cnf=None,**kw)¶
Query or modify the configuration options of the Tix application context. If nooption is specified, returns a dictionary all of the available options. Ifoption is specified with no value, then the method returns a list describing theone named option (this list will be identical to the corresponding sublist ofthe value returned if no option is specified). If one or more option-valuepairs are specified, then the method modifies the given option(s) to have thegiven value(s); in this case the method returns an empty string. Option may beany of the configuration options.
- tixCommand.tix_cget(option)¶
Returns the current value of the configuration option given byoption. Optionmay be any of the configuration options.
- tixCommand.tix_getbitmap(name)¶
Locates a bitmap file of the name
name.xpm
orname
in one of the bitmapdirectories (see thetix_addbitmapdir()
method). By usingtix_getbitmap()
, you can avoid hard coding the pathnames of the bitmapfiles in your application. When successful, it returns the complete pathname ofthe bitmap file, prefixed with the character@
. The returned value can beused to configure thebitmap
option of the Tk and Tix widgets.
- tixCommand.tix_addbitmapdir(directory)¶
Tix maintains a list of directories under which the
tix_getimage()
andtix_getbitmap()
methods will search for image files. The standard bitmapdirectory is$TIX_LIBRARY/bitmaps
. Thetix_addbitmapdir()
methodaddsdirectory into this list. By using this method, the image files of anapplications can also be located using thetix_getimage()
ortix_getbitmap()
method.
- tixCommand.tix_filedialog([dlgclass])¶
Returns the file selection dialog that may be shared among different calls fromthis application. This method will create a file selection dialog widget whenit is called the first time. This dialog will be returned by all subsequentcalls to
tix_filedialog()
. An optional dlgclass parameter can be passedas a string to specified what type of file selection dialog widget is desired.Possible options aretix
,FileSelectDialog
ortixExFileSelectDialog
.
- tixCommand.tix_getimage(self,name)¶
Locates an image file of the name
name.xpm
,name.xbm
orname.ppm
in one of the bitmap directories (see thetix_addbitmapdir()
method above). If more than one file with the same name(but different extensions) exist, then the image type is chosen according to thedepth of the X display: xbm images are chosen on monochrome displays and colorimages are chosen on color displays. By usingtix_getimage()
, you canavoid hard coding the pathnames of the image files in your application. Whensuccessful, this method returns the name of the newly created image, which canbe used to configure theimage
option of the Tk and Tix widgets.
- tixCommand.tix_option_get(name)¶
Gets the options maintained by the Tix scheme mechanism.
- tixCommand.tix_resetoptions(newScheme,newFontSet[,newScmPrio])¶
Resets the scheme and fontset of the Tix application tonewScheme andnewFontSet, respectively. This affects only those widgets created after thiscall. Therefore, it is best to call the resetoptions method before the creationof any widgets in a Tix application.
The optional parameternewScmPrio can be given to reset the priority level ofthe Tk options set by the Tix schemes.
Because of the way Tk handles the X option database, after Tix has been hasimported and inited, it is not possible to reset the color schemes and font setsusing the
tix_config()
method. Instead, thetix_resetoptions()
method must be used.