README.md 1.34 KB
Newer Older
sqweek's avatar
sqweek committed
1
2
3
4
5
6
7
8
9
10
# dialog
Simple cross-platform dialog API for go-lang

# examples
    ok := dialog.Message("%s", "Do you want to continue?").Title("Are you sure?").YesNo()

Creates a dialog box titled "Are you sure?", containing the message "Do you want to continue?",
a "Yes" button and a "No" button. Returns true iff the dialog could be displayed and the user
pressed the "Yes" button.

11
    filename, err := dialog.File().Filter("Mp3 audio file", "mp3").Load()
sqweek's avatar
sqweek committed
12
13
14
15
16

Creates a file selection dialog allowing the user to select a .mp3 file. The absolute path of
the file is returned, unless an error is encountered or the user cancels/closes the dialog.
In the latter case, `filename` will be the empty string and `err` will equal `dialog.Cancelled`.

17
    filename, err := dialog.File().Filter("XML files", "xml").Title("Export to XML").Save()
sqweek's avatar
sqweek committed
18
19
20
21

Asks the user for a filename to write data into. If the user selects a file which already exists,
an additional dialog is spawned to confirm they want to overwrite the existing file.

22
23
    directory, err := dialog.Directory().Title("Load images").Browse()

24
Asks the user for a directory.
25

sqweek's avatar
sqweek committed
26
# platform details
27
* OSX: uses Cocoa's NSAlert/NSSavePanel/NSOpenPanel clasess
sqweek's avatar
sqweek committed
28
29
* Win32: uses MessageBox/GetOpenFileName/GetSaveFileName (via package github.com/AllenDang/w32)
* Linux: uses Gtk's MessageDialog/FileChooserDialog (via package github.com/mattn/gtk)