dlgs

package module
v0.0.0-...-40c7787 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2022 License: BSD-2-Clause Imports: 9 Imported by: 76 modules, 83 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

dlgs

TravisCI Build Status AppVeyor Build Status GoDoc Go Report Card

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

NOTE: This repository is archived and will not be maintained anymore. See https://github.com/ncruces/zenity for cgo-free dialogs, also check https://github.com/gen2brain/iup-go for full-blown UI.

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)
}

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)
}

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)
}

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)
}

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)
}

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)
}

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)
}

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)
}

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)
}

func MessageBox

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

MessageBox displays message box and ok button without icon.

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)
}

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)
}

func Warning

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

Warning displays warning dialog.

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

Types

This section is empty.

Jump to

Keyboard shortcuts

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