Tkinter dialogs
***************


"tkinter.simpledialog" --- 標準 Tkinter 入力ダイアログ
======================================================

**ソースコード:** Lib/tkinter/simpledialog.py

======================================================================

"tkinter.simpledialog" モジュールは、ユーザーに値を入力させる単純なモ
ーダルダイアログを作成するための便利なクラスや関数を含んでいます。

tkinter.simpledialog.askfloat(title, prompt, *, initialvalue=None, minvalue=None, maxvalue=None, parent=None)
tkinter.simpledialog.askinteger(title, prompt, *, initialvalue=None, minvalue=None, maxvalue=None, parent=None)
tkinter.simpledialog.askstring(title, prompt, *, initialvalue=None, show=None, parent=None)

   Prompt the user to enter a value of the desired type and return it,
   or "None" if the dialog is cancelled.

   *title* is the dialog title and *prompt* the message shown above
   the entry. *initialvalue* is the value initially placed in the
   entry. *parent* is the window over which the dialog is shown.
   "askinteger()" and "askfloat()" also accept *minvalue* and
   *maxvalue*, which bound the accepted value. "askstring()" also
   accepts *show*, a character used to mask the entered text, for
   example "'*'" to hide a password.

class tkinter.simpledialog.Dialog(parent, title=None)

   The base class for custom dialogs. Instantiating it shows the
   dialog modally and returns once the user closes it; the entered
   value is then available in the "result" attribute.

   result

      The value produced by "apply()", or "None" if the dialog was
      cancelled.

   body(master)

      このメソッドをオーバーライドしてダイアログのインターフェースを構
      築し、初期フォーカスを持たせるウィジェットを返してください。

   buttonbox()

      デフォルト動作はOKとCancelボタンを追加します。カスタムのボタンレ
      イアウトが必要であればオーバーライドします。

   validate()

      Validate the data entered by the user. Return true if it is
      valid, in which case the dialog proceeds to "apply()"; return
      false to keep the dialog open. The default implementation always
      returns true; override it to check the input.

   apply()

      Process the data entered by the user, for example by storing it
      in the "result" attribute. Called after "validate()" succeeds
      and just before the dialog is destroyed. The default
      implementation does nothing; override it to act on or store the
      result.

   destroy()

      Destroy the dialog window, clearing the reference to the widget
      that had the initial focus.

class tkinter.simpledialog.SimpleDialog(master, text='', buttons=[], default=None, cancel=None, title=None, class_=None)

   A simple modal dialog that displays the message *text* above a row
   of push buttons whose labels are given by *buttons*, and returns
   the index of the button the user presses. *default* is the index of
   the button activated by the Return key, *cancel* the index returned
   when the window is closed through the window manager, *title* the
   window title, and *class_* the Tk class name of the window.

   go()

      Display the dialog, wait until the user presses a button or
      closes the window, and return the index of the chosen button.


"tkinter.filedialog" --- ファイル選択ダイアログ
===============================================

**ソースコード:** Lib/tkinter/filedialog.py

======================================================================

The "tkinter.filedialog" module provides classes and factory functions
for creating file/directory selection windows.


Native load/save dialogs
------------------------

下記のクラスは、振る舞いをカスタマイズできる設定オプション付きの、ネイ
ティブルック＆フィールと統合したファイルダイアログを提供します。以下の
キーワード引数は、下記で列挙するクラスや関数に適用できます。

      *parent* - ダイアログをその上に表示するウィンドウ

      *title* - ウィンドウのタイトル

      *initialdir* - 最初に表示するディレクトリ

      *initialfile* - ダイアログを表示した際に選択するファイル

      *filetypes* - (ラベル, パターン) のタプルからなるシーケンスで、'*' ワイルドカードが利用できます

      *defaultextension* - ファイルに追加するデフォルトの拡張子 (保存ダイアログ向け)

      *multiple* - 真の場合、複数要素の選択を許可します

**静的なファクトリ関数**

The below functions when called create a modal, native look-and-feel
dialog, wait for the user's selection, and return it. The exact return
value depends on the function (see below); when the dialog is
cancelled it is an empty string, an empty tuple or "None". The precise
type of this empty value may vary between platforms and Tk versions,
so test the result for truth rather than comparing it with a specific
value.

tkinter.filedialog.askopenfile(mode='r', **options)
tkinter.filedialog.askopenfiles(mode='r', **options)

   Create an "Open" dialog. "askopenfile()" returns the opened file
   object, or "None" if the dialog is cancelled. "askopenfiles()"
   returns a list of the opened file objects, or an empty tuple if
   cancelled. The files are opened in mode *mode* (read-only "'r'" by
   default).

tkinter.filedialog.asksaveasfile(mode='w', **options)

   Create a "SaveAs" dialog and return the opened file object, or
   "None" if the dialog is cancelled. The file is opened in mode
   *mode* ("'w'" by default).

tkinter.filedialog.askopenfilename(**options)
tkinter.filedialog.askopenfilenames(**options)

   Create an "Open" dialog. "askopenfilename()" returns the selected
   filename as a string, or an empty string if the dialog is
   cancelled. "askopenfilenames()" returns a tuple of the selected
   filenames, or an empty tuple if cancelled.

tkinter.filedialog.asksaveasfilename(**options)

   Create a "SaveAs" dialog and return the selected filename as a
   string, or an empty string if the dialog is cancelled.

tkinter.filedialog.askdirectory(**options)

   Prompt the user to select a directory, and return its path as a
   string, or an empty string if the dialog is cancelled. Additional
   keyword option: *mustexist* - if true, the user may only select an
   existing directory (false by default).

class tkinter.filedialog.Open(master=None, **options)
class tkinter.filedialog.SaveAs(master=None, **options)
class tkinter.filedialog.Directory(master=None, **options)

   The above three classes provide native dialog windows for loading
   and saving files and for selecting a directory.

**便利なクラス**

以下のクラスは、ファイルやディレクトリのウィンドウを一から作るために使
います。 プラットフォームのネイティブのルックアンドフィールは再現しま
せん。

注釈:

  イベント処理や動作をカスタマイズするには、*FileDialog* クラスをサブ
  クラス化してください。

class tkinter.filedialog.FileDialog(master, title=None)

   基本的なファイル選択ダイアログを作ります。

   cancel_command(event=None)

      ダイアログウィンドウの終了を開始します。

   dirs_double_event(event)

      ディレクトリのダブルクリックイベントのハンドラー。

   dirs_select_event(event)

      ディレクトリのクリックイベントのハンドラー。

   files_double_event(event)

      ファイルのダブルクリックイベントのハンドラー。

   files_select_event(event)

      ファイルのシングルクリックイベントのハンドラー。

   filter_command(event=None)

      ディレクトリでファイルを絞り込みます。

   get_filter()

      現在使っているファイルフィルターを取得します。

   get_selection()

      現在選択されている項目を取得します。

   go(dir_or_file=os.curdir, pattern='*', default='', key=None)

      ダイアログを表示し、イベントループを開始します。

   ok_event(event)

      現在の選択を返してダイアログを終了します。

   ok_command()

      Called when the user confirms the current selection. The base
      implementation accepts the selection and closes the dialog;
      "LoadFileDialog" and "SaveFileDialog" override it to check the
      selection first.

   quit(how=None)

      ダイアログを終了し、ファイル名があれば返します。

   set_filter(dir, pat)

      ファイルフィルターを設定します。

   set_selection(file)

      現在のファイルの選択を *file* に更新します。

class tkinter.filedialog.LoadFileDialog(master, title=None)

   既存のファイルを選択するダイアログウィンドウを作る FileDialog のサ
   ブクラスです。

   ok_command()

      ファイルが指定されていて、選択が既存のファイルを指していることを
      確認します。

class tkinter.filedialog.SaveFileDialog(master, title=None)

   保存先のファイルを選択するダイアログウィンドウを作る FileDialog の
   サブクラスです。

   ok_command()

      選択がディレクトリではなく、有効なファイルを指しているかを確認し
      ます。 既存のファイルを選択した場合は確認を求めます。


"tkinter.commondialog" --- Dialog window templates
==================================================

**ソースコード:** Lib/tkinter/commondialog.py

======================================================================

The "tkinter.commondialog" module provides the "Dialog" class that is
the base class for dialogs defined in other supporting modules.

class tkinter.commondialog.Dialog(master=None, **options)

   show(**options)

      Dialog ウィンドウを表示します。


"tkinter.dialog" --- Classic Tk dialog boxes
============================================

**Source code:** Lib/tkinter/dialog.py

======================================================================

The "tkinter.dialog" module provides a simple modal dialog box built
on the classic (non-themed) Tk widgets.

tkinter.dialog.DIALOG_ICON

   The name of a bitmap ("'questhead'") suitable for use as the
   *bitmap* of a "Dialog".

class tkinter.dialog.Dialog(master=None, cnf={}, **kw)

   Display a modal dialog box built from the classic (non-themed) Tk
   widgets and wait for the user to press one of its buttons. The
   options, given through *cnf* or as keyword arguments, are all
   required: *title* (the window title), *text* (the message),
   *bitmap* (the name of a bitmap icon, such as "DIALOG_ICON"),
   *default* (the index of the default button) and *strings* (the
   sequence of button labels). After construction, the "num" attribute
   holds the index of the button the user pressed.

   destroy()

      Do nothing. The dialog window is destroyed automatically before
      the constructor returns, so there is nothing left for this
      method to do.

参考: "tkinter.messagebox" モジュール、ファイルを読み書きする
