Nictk 2.2.0
An easy to use pyton GUI
Dialog boxes

In tkinter there are some functions to open the standard system dialog boxes, grouped in some submodules which you must import if you want to use them. In Nictk (since version 2.1.1) I imported the function names with from ... import ..., so you can use them prepending only the Nictk prefix. For compatibility with older versions you can still call them with older prefixes (this will be dropped in future versions).

Nictk.showerror(message="File not found") # or
Nictk.mb.showerror(message="File not found") # DEPRECATED
Nictk.askopenfilename() # or
Nictk.fd.askopenfilename() # DEPRECATED
Nictk.askcolor() # or
Nictk.cc.askcolor() # DEPRECATED

For an example of their use see the file Dialogs.py.

Dialog boxes in tkinter.messagebox

All these functions share the same paradigm:

functionname(title=None, message=None, **options)

where:

  • title is the dialog box title;
  • message is the text in the body of the dialog box;
  • the options parameters allow the user to choose the dialog box icon, number and type of buttons and default button (but this is usually unneeded if you use a predefined function). For a reference see here.

Here is a list of them with their name in Nictk.

Function Notes Returns
Nictk.askokcancel Opens a dialog box with tho buttons "Ok", "Cancel". True for "Ok" and False for "Cancel".
Nictk.askquestion Opens a dialog box with two buttons "Yes", "No". "yes" or "no" (aliased by YES, NO).
Nictk.askretrycancel Opens a dialog box with two buttons "Retry", "Cancel". True for "Retry" and False for "Cancel".
Nictk.askyesno Same of askquestion. True for "Yes" and False for "No".
Nictk.askyesnocancel Opens a dialog box with three buttons "Yes", "No", "Cancel". True for "Yes", False for "No", None for "Cancel".
Nictk.showerror Opens a dialog box with an error icon and only the button "Ok". Always "ok" (aliased by OK).
Nictk.showinfo Opens a dialog box with an info icon and only the button "Ok". As above.
Nictk.showwarning Opens a dialog box with a warning icon and only the button "Ok". As above.

Dialog boxes in tkinter.filedialog

All these functions share the same paradigm:

functionname(**options)

For the options parameters see here.

Here is a list of them with their name in Nictk.

Function Notes Returns
Nictk.askopenfilename Opens the file dialog "Open file" where you can choose a file. The complete path of the chosen file, or an empty string if you press "Cancel".
Nictk.asksaveasfilename Opens the file dialog "Save as file" where you can choose a file. The complete path of the chosen file, or an empty string if you press "Cancel".
Nictk.askopenfilenames Opens the file dialog "Open file" where you can choose multiple files. A list with complete paths of the chosen files, or an empty list if you press "Cancel".
Nictk.askdirectory Opens the file dialog "Open file" where you can choose a directory. The complete path of the chosen directory, or an empty string if you press "Cancel".

Dialog boxes in tkinter.colorchooser

There is only one:

askcolor(color=None, **options)

where:

  • color is the initially chosen color;
  • for the options parameters see here.
Function Notes Returns
Nictk.askcolor Opens a color chooser file dialog. A duple, with in the first element three integers R, G, B, in the second a tkinter Color object, or (None, None) if you press "Cancel"