Tiny file dialogs v3.8.8 Nim bindings.
Example
import std/os import tinydialogs beep() notifyPopup("Message", "You just received a message from Beef", Info) echo messageBox("Hey", "Do you want to receive more notifications?", YesNo, Question, Yes) echo inputBox("Name", "Please enter your password :]", "") echo saveFileDialog("Save the file", getCurrentDir() / "\0", ["*.txt", "*.text"], "Text file") # "\0" for an emtpy file echo openFileDialog("Open the file", getCurrentDir() / "\0", ["*.txt", "*.text"], "Text file") echo openMultipleFilesDialog("Open the files", getCurrentDir() / "\0") # No fiilter = Any file echo selectFolderDialog("Open the directory of the file", getCurrentDir()) echo colorChooser("Choose a color") echo colorChooser("Choose a color", "#000000") # Hex echo colorChooser("Choose a color", [0u8, 0u8, 0u8]) # RGB
Types
DialogType = enum Ok = "ok", OkCancel = "okcancel", YesNo = "yesno", YesNoCancel = "yesnocancel"
- Source Edit
Procs
proc colorChooser(title = ""; defaultHexRGB = ""): tuple[hex: string, rgb: array[3, byte]] {....raises: [], tags: [], forbids: [].}
- Returns ("", [0u8, 0u8, 0u8]) when no color is selected. Source Edit
proc colorChooser(title: string; defaultRGB: array[3, byte]): tuple[hex: string, rgb: array[3, byte]] {....raises: [], tags: [], forbids: [].}
- Returns ("", [0u8, 0u8, 0u8]) when no color is selected. Source Edit
proc messageBox(title, message: string; dialogType: DialogType; iconType: IconType; defaultButton: Button): Button {....raises: [], tags: [], forbids: [].}
- message may contain \n\t. Returns the clicked Button. Source Edit
proc notifyPopup(title, message: string; iconType: IconType) {....raises: [], tags: [], forbids: [].}
- message may contain \n\t. Source Edit
proc openFileDialog(title, defaultPath: string; filterPatterns: openArray[string] = []; singleFilterDescription = ""): string {....raises: [], tags: [], forbids: [].}
-
Returns the selected file (or an empty string when cancelled).
For an empty defaultPath use a trailing slash as in dir/ (or using std/os "dir" / "\0").
Example of filterPatterns: ["*.txt", "*.text"].
singleFilterDescriptor is the text to show instead of filterPatterns. Note: tinyfiledialogs at the moment only supports one filter.
Source Edit proc openMultipleFilesDialog(title, defaultPath: string; filterPatterns: openArray[string] = []; singleFilterDescription = ""): seq[string] {. ...raises: [], tags: [], forbids: [].}
-
Returns the selected files (or empty string when cancelled).
For an empty defaultPath use a trailing slash as in dir/ (or using std/os "dir" / "\0").
Example of filterPatterns: ["*.txt", "*.text"].
singleFilterDescriptor is the text to show instead of filterPatterns. Note: tinyfiledialogs at the moment only supports one filter.
Source Edit proc saveFileDialog(title, defaultPath: string; filterPatterns: openArray[string] = []; singleFilterDescription = ""): string {....raises: [], tags: [], forbids: [].}
-
Returns the selected file (or an empty string when cancelled).
For an empty defaultPath use a trailing slash as in dir/ (or using std/os "dir" / "\0").
Example of filterPatterns: ["*.txt", "*.text"].
singleFilterDescriptor is the text to show instead of filterPatterns. Note: tinyfiledialogs at the moment only supports one filter.
Source Edit proc selectFolderDialog(title, defaultPath: string): string {....raises: [], tags: [], forbids: [].}
- Returns the selected folder (or empty when cancelled). Source Edit
Exports
-
tinyfd_needs, tinyfd_colorChooser, tinyfd_verbose, tinyfd_messageBox, tinyfd_setGlobalInt, tinyfd_getGlobalChar, tinyfd_getGlobalInt, tinyfd_response, tinyfd_forceConsole, tinyfd_assumeGraphicDisplay, tinyfd_allowCursesDialogs, tinyfd_saveFileDialog, tinyfd_beep, tinyfd_version, tinyfd_selectFolderDialog, tinyfd_openFileDialog, tinyfd_inputBox, tinyfd_notifyPopup, tinyfd_silent