The
Tix
(Tk Interface Extension) module provides an additional rich setof widgets. Although the standard Tk library has many useful widgets, they arefar from complete. The Tix
library provides most of the commonly neededwidgets that are missing from standard Tk: HList
, ComboBox
,Control
(a.k.a. SpinBox) and an assortment of scrollable widgets.Tix
also includes many more widgets that are generally useful in a widerange 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.
Note
With PyQt5, you need to have a good understanding of basic Python, but I'll try to make this as easy as possible. In this article, I'll walk you through using the Qt Designer to create a simple dialog, convert the designed UI to Python, and execute the code. If you haven't already installed Python 3.
Tix
has been renamed to tkinter.tix
in Python 3. The2to3 tool will automatically adapt imports when converting yoursources to Python 3.See also
The home page for
Tix
. This includes links to additional documentationand downloads.On-line version of the man pages and reference material.
![Python File Dialog Tutorial Roblox Python File Dialog Tutorial Roblox](/uploads/1/2/5/8/125870656/857459613.gif)
On-line version of the programmer’s reference material.
Tix applications for development of Tix and Tkinter programs. Tide applicationswork under Tk or Tkinter, and include TixInspect, an inspector toremotely modify and debug Tix/Tk/Tkinter applications.
24.3.1. Using Tix¶
Tix.
Tix
(screenName[, baseName[, className]])¶Toplevel widget of Tix which represents mostly the main window of anapplication. It has an associated Tcl interpreter.
Classes in the
Tix
module subclasses the classes in the Tkinter
module. The former imports the latter, so to use Tix
with Tkinter, allyou need to do is to import one module. In general, you can just importTix
, and replace the toplevel call to Tkinter.Tk
withTix.Tk
:To use
Tix
, you must have the Tix
widgets installed, usuallyalongside your installation of the Tk widgets. To test your installation, trythe following:If this fails, you have a Tk installation problem which must be resolved beforeproceeding. Use the environment variable
TIX_LIBRARY
to point to theinstalled Tix
library directory, and make sure you have the dynamicobject library (tix8183.dll
or libtix8183.so
) in the samedirectory that contains your Tk dynamic object library (tk8183.dll
orlibtk8183.so
). The directory with the dynamic object library should alsohave a file called pkgIndex.tcl
(case sensitive), which contains theline:24.3.2. Tix Widgets¶
Tixintroduces over 40 widget classes to the
Tkinter
repertoire. There is ademo of all the Tix
widgets in the Demo/tix
directory of thestandard distribution.24.3.2.1. Basic Widgets¶
Tix.
Balloon
¶A Balloon 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.
Tix.
ButtonBox
¶The ButtonBoxwidget creates a box of buttons, such as is commonly used for
OkCancel
.Tix.
ComboBox
¶The ComboBoxwidget 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.
Tix.
Control
¶The Controlwidget 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.Tix.
LabelEntry
¶The LabelEntrywidget packages an entry widget and a label into one mega widget. It canbe used to simplify the creation of “entry-form” type of interface.
Tix.
LabelFrame
¶The LabelFramewidget 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 the frame
subwidget.Tix.
Meter
¶The Meter widgetcan be used to show the progress of a background job which may take a long timeto execute.
Tix.
OptionMenu
¶The OptionMenucreates a menu button of options.
Tix.
PopupMenu
¶The PopupMenuwidget can be used as a replacement of the
tk_popup
command. The advantageof the Tix
PopupMenu
widget is it requires less application codeto manipulate.Tix.
Select
¶The Select widgetis a container of button subwidgets. It can be used to provide radio-box orcheck-box style of selection options for the user.
Tix.
StdButtonBox
¶The StdButtonBoxwidget is a group of standard buttons for Motif-like dialog boxes.
24.3.2.2. File Selectors¶
Tix.
DirList
¶The DirListwidget 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.
Tix.
DirTree
¶The DirTreewidget 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.
Tix.
DirSelectDialog
¶The DirSelectDialogwidget 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.
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.Tix.
ExFileSelectBox
¶The ExFileSelectBoxwidget 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.Tix.
FileSelectBox
¶The FileSelectBoxis 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.Tix.
FileEntry
¶The FileEntrywidget can be used to input a filename. The user can type in the filenamemanually. Alternatively, the user can press the button widget that sits next tothe entry, which will bring up a file selection dialog.
24.3.2.3. Hierarchical ListBox¶
Tix.
HList
¶The HList 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.
Tix.
CheckList
¶The CheckListwidget displays a list of items to be selected by the user. CheckList actssimilarly to the Tk checkbutton or radiobutton widgets, except it is capable ofhandling many more items than checkbuttons or radiobuttons.
Tix.
Tree
¶The Tree widgetcan be used to display hierarchical data in a tree form. The user can adjust theview of the tree by opening or closing parts of the tree.
24.3.2.4. Tabular ListBox¶
Tix.
TList
¶The TList 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) the TList
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.24.3.2.5. Manager Widgets¶
Tix.
PanedWindow
¶The PanedWindowwidget 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.
Tix.
ListNoteBook
¶The ListNoteBookwidget 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 the hlist
subwidget.Tix.
NoteBook
¶The NoteBookwidget 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.
24.3.2.6. Image Types¶
The
Tix
module adds:- pixmapcapabilities to all
Tix
andTkinter
widgets to create color imagesfrom 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.
24.3.2.7. Miscellaneous Widgets¶
Tix.
InputOnly
¶The InputOnlywidgets are to accept inputs from the user, which can be done with the
bind
command (Unix only).24.3.2.8. Form Geometry Manager¶
In addition,
Tix
augments Tkinter
by providing:Tix.
Form
¶The Form geometrymanager based on attachment rules for all Tk widgets.
24.3.3. Tix Commands¶
Tix.
tixCommand
¶The tix 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:
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 by option. Optionmay be any of the configuration options.
tixCommand.
tix_getbitmap
(name)¶Locates a bitmap file of the name
name.xpm
or name
in one of the bitmapdirectories (see the tix_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 the bitmap
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
. The tix_addbitmapdir()
methodadds directory into this list. By using this method, the image files of anapplications can also be located using the tix_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 are tix
, FileSelectDialog
or tixExFileSelectDialog
.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 using tix_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 the image
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 to newScheme 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 parameter newScmPrio 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, the tix_resetoptions()
method must be used.