tinyfiledialogs

Native dialog library for Windows, macOS, GTK+, Qt, console & more. SSH supported via automatic switch to console mode or X11 forwarding.

8 functions:

  • beep
  • notify popup (tray)
  • message & question
  • input & password
  • save file
  • open file(s)
  • select folder
  • color picker

Each function is documented with examples. The dialogs can be forced into console mode. Supports UTF-8 (except Windows console).

Windows XP to 10:

  • native code & vbs create the graphic dialogs
  • enhanced console mode can use dialog.exe from http://andrear.altervista.org/home/cdialog.php
  • basic console input

Unix (using command line calls):

  • applescript, kdialog, zenity
  • python (2 or 3) + tkinter + python-dbus (optional)
  • whiptail, dialog (opens a console if needed)
  • basic console input

The same executable can run across desktops & distributions.

Notes

  • This is not for Android nor iOS.
  • The code is betterC compatible, originally pure C89.
  • Windows is fully supported from XP to 10 (maybe even older versions).
  • OSX supported from 10.4 to latest (maybe even older versions).
  • On Windows, it links against comdlg32.lib, ole32.lib, and user32.lib.
  • Set TINYFD_NOLIB version if you don't want to include the code creating graphic dialogs. Then you won't need to link against those libs.
  • On Unix, it tries command line calls. They are already available on most (if not all) desktops.
  • In the absence of those it will use gdialog, gxmessage or whiptail with a textinputbox.
  • If nothing is found, it switches to basic console input, and opens a console if needed (requires xterm + bash).
  • On OSX, the package dialog can be installed via http://macappstore.org/dialog or https://www.macports.org/
  • On Windows, for enhanced console mode, dialog.exe should be copied somewhere on your executable path. It can be found at the bottom of the following page: http://andrear.altervista.org/home/cdialog.php
  • If dialog is missing, it will switch to basic console input.
  • Mutiple selects are not allowed in console mode.
  • Avoid using " and ' in titles and messages.
  • String memory is preallocated statically for all the returned values.
  • Use platform-specific path separators: \ on Windows, / on Unix.
  • If you pass only a path instead of path + filename, make sure it ends with a separator.
  • File and path names are tested before return, they are valid.
  • You can query the type of dialog that will be used, see tinyfd_response.

Thanks for contributions, bug corrections & thorough testing to:

  • Don Heyse http://ldglite.sf.net for bug corrections & thorough testing!
  • Paul Rouget

Members

Aliases

c_str
alias c_str = const(char*)
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.

Functions

tinyfd_beep
void tinyfd_beep()

No params, no return value, just beep

tinyfd_colorChooser
c_str tinyfd_colorChooser(c_str title, c_str defaultHexRGB, ubyte[3] defaultRGB, ubyte[3] resultRGB)
tinyfd_inputBox
c_str tinyfd_inputBox(c_str title, c_str message, c_str defaultInput)
tinyfd_messageBox
int tinyfd_messageBox(c_str title, c_str message, c_str dialogType, c_str iconType, int defaultButton)
tinyfd_notifyPopup
int tinyfd_notifyPopup(c_str title, c_str message, c_str iconType)
tinyfd_openFileDialog
c_str tinyfd_openFileDialog(c_str title, c_str defaultPathAndFile, TFD_Filter[] filters, bool allowMultipleSelects)
tinyfd_saveFileDialog
c_str tinyfd_saveFileDialog(c_str title, c_str defaultPathAndFile, TFD_Filter[] filters)
tinyfd_selectFolderDialog
c_str tinyfd_selectFolderDialog(c_str title, c_str defaultPath)

Static variables

tinyfd_forceConsole
bool tinyfd_forceConsole;
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
tinyfd_forceConsole
bool tinyfd_forceConsole;
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
tinyfd_forceConsole
bool tinyfd_forceConsole;
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
tinyfd_needs
char[] tinyfd_needs;

Info about requirements for a platform

tinyfd_needs
char[] tinyfd_needs;
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
tinyfd_response
char[1024] tinyfd_response;

If you pass "tinyfd_query" as title, the functions will not display the dialogs but will return 0 for console mode, 1 for graphic mode. tinyfd_response is then filled with the retain solution. possible values for tinyfd_response are (all lowercase), for graphic mode: windows applescript kdialog zenity zenity3 matedialog qarma python2-tkinter python3-tkinter python-dbus perl-dbus gxmessage gmessage xmessage xdialog gdialog, for console mode: dialog whiptail basicinput no_solution

tinyfd_silent
bool tinyfd_silent;

On unix, hide errors and warnings from called dialog; default is true

tinyfd_verbose
bool tinyfd_verbose;

On unix, prints the command line calls; default is false

tinyfd_version
char[8] tinyfd_version;

Contains tinyfd current version number

Structs

TFD_Filter
struct TFD_Filter

Single filter, used in open/save file dialogs

Meta