dlgs

package module
v0.0.0-...-1203fc6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2020 License: BSD-2-Clause Imports: 9 Imported by: 0

README

dlgs

TravisCI Build Status AppVeyor Build Status GoDoc Go Report Card

dlgs is a cross-platform library for displaying dialogs and input boxes.

Installation

go get -u github.com/gen2brain/dlgs

Documentation

Documentation on GoDoc.

Examples

item, _, err := dlgs.List("List", "Select item from list:", []string{"Bug", "New Feature", "Improvement"})
if err != nil {
    panic(err)
}
passwd, _, err := dlgs.Password("Password", "Enter your API key:")
if err != nil {
    panic(err)
}
yes, err := dlgs.Question("Question", "Are you sure you want to format this media?", true)
if err != nil {
    panic(err)
}

More

For cross-platform notifications and alerts see beeep.

Documentation

Overview

Package dlgs is a cross-platform library for displaying dialogs and input boxes.

Index

Examples

Constants

This section is empty.

Variables

View Source
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

func Color(title, defaultColorHex string) (color.Color, bool, error)

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

func Date(title, text string, defaultDate time.Time) (time.Time, bool, error)

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

func Entry(title, text, defaultText string) (string, bool, error)

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

func Error(title, text string) (bool, error)

Error displays error dialog.

Example
_, err := Error("Error", "Cannot divide by zero.")
if err != nil {
	panic(err)
}
Output:

func File

func File(title, filter string, directory bool) (string, bool, error)

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

func FileMulti(title, filter string) ([]string, bool, error)

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

func Info(title, text string) (bool, error)

Info displays information dialog.

Example
_, err := Info("Info", "Lorem ipsum dolor sit amet.")
if err != nil {
	panic(err)
}
Output:

func List

func List(title, text string, items []string) (string, bool, error)

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

func ListMulti(title, text string, items []string) ([]string, bool, error)

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 Password

func Password(title, text string) (string, bool, error)

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:

func Question

func Question(title, text string, defaultCancel bool) (bool, error)

Question displays question dialog.

Example
_, err := Question("Question", "Are you sure you want to format this media?", true)
if err != nil {
	panic(err)
}
Output:

func Warning

func Warning(title, text string) (bool, error)

Warning displays warning dialog.

Example
_, err := Warning("Warning", "Incomplete information!")
if err != nil {
	panic(err)
}
Output:

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL