Documentation ¶
Overview ¶
Package dlgs is a cross-platform library for displaying dialogs and input boxes.
Index ¶
- Variables
- func Color(title, defaultColorHex string) (color.Color, bool, error)
- func Date(title, text string, defaultDate time.Time) (time.Time, bool, error)
- func Entry(title, text, defaultText string) (string, bool, error)
- func Error(title, text string) (bool, error)
- func File(title, filter string, directory bool) (string, bool, error)
- func FileMulti(title, filter string) ([]string, bool, error)
- func Info(title, text string) (bool, error)
- func List(title, text string, items []string) (string, bool, error)
- func ListMulti(title, text string, items []string) ([]string, bool, error)
- func MessageBox(title, text string) (bool, error)
- func Password(title, text string) (string, bool, error)
- func Question(title, text string, defaultCancel bool) (bool, error)
- func Warning(title, text string) (bool, error)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUnsupported is returned when operating system is not supported. ErrUnsupported = errors.New("dlgs: unsupported operating system: " + runtime.GOOS) // ErrNotImplemented is returned when function is not implemented. ErrNotImplemented = errors.New("dlgs: function not implemented for " + runtime.GOOS) )
Functions ¶
func Color ¶
Color displays a color selection dialog, returning the selected color and a bool for success.
Example ¶
_, _, err := Color("Pick color", "#BEBEBE") if err != nil { panic(err) }
Output:
func Date ¶
Date displays a calendar dialog, returning the date and a bool for success.
Example ¶
_, _, err := Date("Date", "Date of traveling:", time.Now()) if err != nil { panic(err) }
Output:
func Entry ¶
Entry displays input dialog, returning the entered value and a bool for success.
Example ¶
_, _, err := Entry("Entry", "Enter something here, anything:", "default text") if err != nil { panic(err) }
Output:
func Error ¶
Error displays error dialog.
Example ¶
_, err := Error("Error", "Cannot divide by zero.") if err != nil { panic(err) }
Output:
func File ¶
File displays a file dialog, returning the selected file or directory, a bool for success, and an error if it was unable to display the dialog. Filter is a string that determines which extensions should be displayed for the dialog. Separate multiple file extensions by spaces and use "*.extension" format for cross-platform compatibility, e.g. "*.png *.jpg". A blank string for the filter will display all file types.
Example ¶
_, _, err := File("Select file", "", false) if err != nil { panic(err) }
Output:
func FileMulti ¶
FileMulti displays a file dialog that allows for selecting multiple files. It returns the selected files, a bool for success, and an error if it was unable to display the dialog. Filter is a string that determines which files should be available for selection in the dialog. Separate multiple file extensions by spaces and use "*.extension" format for cross-platform compatibility, e.g. "*.png *.jpg". A blank string for the filter will display all file types.
Example ¶
_, _, err := FileMulti("Select files", "") if err != nil { panic(err) }
Output:
func Info ¶
Info displays information dialog.
Example ¶
_, err := Info("Info", "Lorem ipsum dolor sit amet.") if err != nil { panic(err) }
Output:
func List ¶
List displays a list dialog, returning the selected value and a bool for success.
Example ¶
_, _, err := List("List", "Select item from list:", []string{"Bug", "New Feature", "Improvement"}) if err != nil { panic(err) }
Output:
func ListMulti ¶
ListMulti displays a multiple list dialog, returning the selected values and a bool for success.
Example ¶
_, _, err := ListMulti("ListMulti", "Select languages from list:", []string{"PHP", "Go", "Python", "Bash"}) if err != nil { panic(err) }
Output:
func MessageBox ¶
MessageBox displays message box and ok button without icon.
func Password ¶
Password displays a dialog, returning the entered value and a bool for success.
Example ¶
_, _, err := Password("Password", "Enter your API key:") if err != nil { panic(err) }
Output:
Types ¶
This section is empty.