Simple cross-platform dialog API for go-lang
Branch: master
Clone or download
Latest commit 302ed2f Mar 21, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
cocoa osx: implement directory browse dialog Jan 25, 2018
example dlgs: implement info message dialog Oct 7, 2017
LICENSE Add ISC license. Jan 25, 2018
README.md
dlgs.go Added directory dialog for Windows. Jan 25, 2018
dlgs_darwin.go osx: implement directory browse dialog Jan 25, 2018
dlgs_linux.go linux: use gtk3 instead of 2 Feb 9, 2019
dlgs_windows.go win32: fix compile error on 64-bit hosts Jan 19, 2019
go.mod gomod: fix AllenDang/w32 to TheTitanrain/w32 Jan 19, 2019
go.sum gomod: fix AllenDang/w32 to TheTitanrain/w32 Jan 19, 2019
util.go dialog: simple cross-platform dialog API Oct 22, 2015

README.md

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.

filename, err := dialog.File().Filter("Mp3 audio file", "mp3").Load()

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.

filename, err := dialog.File().Filter("XML files", "xml").Title("Export to XML").Save()

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.

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

Asks the user for a directory.

platform details

  • OSX: uses Cocoa's NSAlert/NSSavePanel/NSOpenPanel classes
  • Win32: uses MessageBox/GetOpenFileName/GetSaveFileName (via package github.com/AllenDang/w32)
  • Linux: uses Gtk's MessageDialog/FileChooserDialog (via package github.com/mattn/gtk)

build

go mod download
go build