tkinter.tix
--- Tkの拡張ウィジェット¶
ソースコード: Lib/tkinter/tix.py
バージョン 3.6 で非推奨: この Tk 拡張は保守されておらず、新しいコードでは使うべきではありません。
その代わりに tkinter.ttk
を使ってください。
tkinter.tix
(Tk Interface Extension) モジュールは豊富な追加ウィジェットを提供します。標準 Tk ライブラリには多くの有用なウィジェットがありますが、決して完全ではありません。 tkinter.tix
ライブラリは、HList
、 ComboBox
、 Control
(別名SpinBox) および各種のスクロール可能なウィジェットなど、標準 Tk にはないが、一般的に必要とされるウィジェットの大部分を提供します。 tkinter.tix
には、class:NoteBook 、 FileEntry
、 PanedWindow
など、一般的に幅広い用途に役に立つたくさんのウィジェットも含まれています。それらは40以上あります。
これら多くの新しいウィジェットと使うと、より便利でより直感的なユーザインターフェースを作成し、新しい相互作用テクニックをアプリケーションに導入することができます。アプリケーションとユーザに特有の要求に合うように、最も適切なアプリケーションウィジェットを選んでアプリケーションを設計できます。
参考
- Tix Homepage
Tix
のホームページ。ここには追加ドキュメントとダウンロードへのリンクがあります。- Tix Man Pages
manページと参考資料のオンライン版。
- Tix Programming Guide
プログラマ用参考資料のオンライン版。
- Tix Development Applications
Tix と Tkinter プログラムの開発のための Tix アプリケーション。 Tideアプリケーションは Tk または Tkinter に基づいて動作します。また、リモートで Tix/Tk/Tkinter アプリケーションを変更やデバッグするためのインスペクタ TixInspect が含まれます。
Tixを使う¶
- class tkinter.tix.Tk(screenName=None, baseName=None, className='Tix')¶
主にアプリケーションのメインウィンドウを表すTixのトップレベルウィジェット。Tcl インタープリタが関連付けられます。
tkinter.tix
モジュールのクラスはtkinter
モジュールのクラスをサブクラス化します。前者は後者をインポートするので、モジュールを一つインポートするだけでtkinter.tix
を Tkinter と一緒に使うことができます。一般的に、tkinter.tix
をインポートし、トップレベルでのtkinter.Tk
への呼び出しはtix.Tk
に置き換えるだけで済みます。次に例を示します:from tkinter import tix from tkinter.constants import * root = tix.Tk()
tkinter.tix
を使うためには、通常 Tk ウィジェットのインストールと平行して、Tix ウィジェットをインストールしなければなりません。インストールをテストするために、次のことを試してください:
from tkinter import tix
root = tix.Tk()
root.tk.eval('package require Tix')
Tixウィジェット¶
Tix
introduces over 40 widget classes to the tkinter
repertoire.
基本ウィジェット¶
- class tkinter.tix.Balloon¶
A Balloon that pops up over a widget to provide help. When the user moves the cursor inside a widget to which a Balloon widget has been bound, a small pop-up window with a descriptive message will be shown on the screen.
- class tkinter.tix.ButtonBox¶
The ButtonBox widget creates a box of buttons, such as is commonly used for
Ok Cancel
.
- class tkinter.tix.ComboBox¶
The ComboBox widget is similar to the combo box control in MS Windows. The user can select a choice by either typing in the entry subwidget or selecting from the listbox subwidget.
- class tkinter.tix.Control¶
The Control widget is also known as the
SpinBox
widget. The user can adjust the value by pressing the two arrow buttons or by entering the value directly into the entry. The new value will be checked against the user-defined upper and lower limits.
- class tkinter.tix.LabelEntry¶
The LabelEntry widget packages an entry widget and a label into one mega widget. It can be used to simplify the creation of "entry-form" type of interface.
- class tkinter.tix.LabelFrame¶
The LabelFrame widget packages a frame widget and a label into one mega widget. To create widgets inside a LabelFrame widget, one creates the new widgets relative to the
frame
subwidget and manage them inside theframe
subwidget.
- class tkinter.tix.Meter¶
The Meter widget can be used to show the progress of a background job which may take a long time to execute.
- class tkinter.tix.OptionMenu¶
The OptionMenu creates a menu button of options.
- class tkinter.tix.PopupMenu¶
The PopupMenu widget can be used as a replacement of the
tk_popup
command. The advantage of theTix
PopupMenu
widget is it requires less application code to manipulate.
- class tkinter.tix.Select¶
The Select widget is a container of button subwidgets. It can be used to provide radio-box or check-box style of selection options for the user.
- class tkinter.tix.StdButtonBox¶
The StdButtonBox widget is a group of standard buttons for Motif-like dialog boxes.
ファイルセレクタ¶
- class tkinter.tix.DirList¶
The DirList widget displays a list view of a directory, its previous directories and its sub-directories. The user can choose one of the directories displayed in the list or change to another directory.
- class tkinter.tix.DirTree¶
The DirTree widget displays a tree view of a directory, its previous directories and its sub-directories. The user can choose one of the directories displayed in the list or change to another directory.
- class tkinter.tix.DirSelectDialog¶
The DirSelectDialog widget presents the directories in the file system in a dialog window. The user can use this dialog window to navigate through the file system to select the desired directory.
- class tkinter.tix.DirSelectBox¶
DirSelectBox
は標準 Motif(TM) ディレクトリ選択ボックスに似ています。ユーザがディレクトリを選択するために一般的に使われます。DirSelectBox は主に最近 ComboBox ウィジェットに選択されたディレクトリを保存し、すばやく再選択できるようにします。
- class tkinter.tix.ExFileSelectBox¶
The ExFileSelectBox widget is usually embedded in a tixExFileSelectDialog widget. It provides a convenient method for the user to select files. The style of the
ExFileSelectBox
widget is very similar to the standard file dialog on MS Windows 3.1.
- class tkinter.tix.FileSelectBox¶
The FileSelectBox is similar to the standard Motif(TM) file-selection box. It is generally used for the user to choose a file. FileSelectBox stores the files mostly recently selected into a
ComboBox
widget so that they can be quickly selected again.
階層的リストボックス¶
- class tkinter.tix.HList¶
The HList widget can be used to display any data that have a hierarchical structure, for example, file system directory trees. The list entries are indented and connected by branch lines according to their places in the hierarchy.
表的リストボックス¶
- class tkinter.tix.TList¶
The TList widget can 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. The main differences are (1) theTList
widget can display the list entries in a two dimensional format and (2) you can use graphical images as well as multiple colors and fonts for the list entries.
管理ウィジェット¶
- class tkinter.tix.PanedWindow¶
The PanedWindow widget allows the user to interactively manipulate the sizes of several panes. The panes can be arranged either vertically or horizontally. The user changes the sizes of the panes by dragging the resize handle between two panes.
- class tkinter.tix.ListNoteBook¶
The ListNoteBook widget is very similar to the
TixNoteBook
widget: it can be used to display many windows in a limited space using a notebook metaphor. The notebook is divided into a stack of pages (windows). At one time only one of these pages can be shown. The user can navigate through these pages by choosing the name of the desired page in thehlist
subwidget.
- class tkinter.tix.NoteBook¶
The NoteBook widget can be used to display many windows in a limited space using a notebook metaphor. The notebook is divided into a stack of pages. At one time only one of these pages can be shown. The user can navigate through these pages by choosing the visual "tabs" at the top of the NoteBook widget.
画像タイプ¶
tkinter.tix
モジュールは次のものを追加します:
pixmap capabilities to all
tkinter.tix
andtkinter
widgets to create color images from XPM files.Compound image types 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 to display a bitmap and a text string simultaneously in a Tk
Button
widget.
その他のウィジェット¶
ジオメトリマネジャを作る¶
加えて、 tkinter.tix
は次のものを提供することで tkinter
を補強します:
Tixコマンド¶
- class tkinter.tix.tixCommand¶
The tix commands provide access to miscellaneous elements of
Tix
's internal state and theTix
application context. Most of the information manipulated by these methods pertains to the application as a whole, or to a screen or display, rather than to a particular window.現在の設定を見るための一般的な方法は:
from tkinter import tix root = tix.Tk() print(root.tix_configure())
- tixCommand.tix_configure(cnf=None, **kw)¶
Tix アプリケーション・コンテキストの設定オプションを問い合わせたり、変更したりします。オプションが指定されなければ、利用可能なオプションすべてのディクショナリを返します。オプションが値なしで指定された場合は、メソッドは指定されたオプションを説明するリストを返します(このリストはオプションが指定されていない場合に返される値に含まれている、指定されたオプションに対応するサブリストと同一です)。一つ以上のオプション-値のペアが指定された場合は、メソッドは与えられたオプションが与えられた値を持つように変更します。この場合は、メソッドは空文字列を返します。オプションは設定オプションのどれでも構いません。
- tixCommand.tix_cget(option)¶
option によって与えられた設定オプションの現在の値を返します。オプションは設定オプションのどれでも構いません。
- tixCommand.tix_getbitmap(name)¶
ビットマップディレクトリの一つの中の
name.xpm
またはname
と言う名前のビットマップファイルの場所を見つけ出します (tix_addbitmapdir()
メソッドを参照してください)。tix_getbitmap()
を使うことで、アプリケーションにビットマップファイルのパス名をハードコーディングすることを避けることができます。成功すれば、文字@
を先頭に付けたビットマップファイルの完全なパス名を返します。戻り値をTkとTixウィジェットのbitmap
オプションを設定するために使うことができます。
- tixCommand.tix_addbitmapdir(directory)¶
Tix は
tix_getimage()
とtix_getbitmap()
メソッドが画像ファイルを検索する検索先ディレクトリのリストを保持しています。標準ビットマップディレクトリは$TIX_LIBRARY/bitmaps
です。tix_addbitmapdir()
メソッドは directory をこのリストに追加します。そのメソッドを使うことによって、tix_getimage()
またはtix_getbitmap()
メソッドを使ってアプリケーションの画像ファイルも見つけることができます。
- tixCommand.tix_filedialog([dlgclass])¶
このアプリケーションからの異なる呼び出しの間で共有される可能性があるファイル選択ダイアログを返します。最初に呼ばれた時に、このメソッドはファイル選択ダイアログ・ウィジェットを作成します。このダイアログはその後のすべての
tix_filedialog()
への呼び出しで返されます。オプションの dlgclass パラメータは、要求されているファイル選択ダイアログ・ウィジェットの型を指定するために文字列として渡されます。指定可能なオプションはtix
、FileSelectDialog
あるいはtixExFileSelectDialog
です。
- tixCommand.tix_getimage(self, name)¶
ビットマップディレクトリの一つの中の
name.xpm
、name.xbm
またはname.ppm
という名前の画像ファイルの場所を見つけ出します(上のtix_addbitmapdir()
メソッドを参照してください)。同じ名前(だが異なる拡張子)のファイルが一つ以上ある場合は、画像のタイプがXディスプレイの深さに応じて選択されます。xbm画像はモノクロディスプレイの場合に選択され、カラー画像はカラーディスプレイの場合に選択されます。tix_getimage()
を使うことによって、アプリケーションに画像ファイルのパス名をハードコーディングすることを避けられます。成功すれば、このメソッドは新たに作成した画像の名前を返し、Tk と Tix ウィジェットのimage
オプションを設定するためにそれを使うことができます。
- tixCommand.tix_option_get(name)¶
Tixのスキーム・メカニズムによって保持されているオプションを得ます。
- tixCommand.tix_resetoptions(newScheme, newFontSet[, newScmPrio])¶
Tix アプリケーションのスキームとフォントセットをそれぞれ newScheme と newFontSet に再設定します。この設定は、この呼び出し後に作成されたウィジェットだけに影響します。そのため、Tix アプリケーションのどのウィジェットを作成する前にも resetoptions メソッドを呼び出すのが良い方法です。
オプション・パラメータ newScmPrio を、Tix スキームによって設定される Tk オプションの優先度レベルを再設定するために与えることができます。
Tk が X オプションデータベースを扱う方法のため、Tix がインポートされ初期化された後に、カラースキームとフォントセットを
tix_config()
メソッドを使って再設定することはできません。したがって、tix_resetoptions()
メソッドを代わりに使わなければならないのです。