Categorygithub.com/ncruces/zenity
modulepackage
0.10.14
Repository: https://github.com/ncruces/zenity.git
Documentation: pkg.go.dev

# README

Zenity dialogs for Golang, Windows and macOS

Go Reference Go Report Go Coverage Mentioned in Awesome Go

This repo includes:

  • a cross-platform Go package providing Zenity-like dialogs (simple dialogs that interact graphically with the user)
  • a “port” of the zenity command to both Windows and macOS based on that library.

Implemented dialogs:

Behavior on Windows, macOS and other Unixes might differ slightly. Some of that is intended (reflecting platform differences), other bits are unfortunate limitations.

Installing

The Go package:

go get github.com/ncruces/zenity@latest

The zenity command on macOS/WSL using Homebrew 🍺:

brew install ncruces/tap/zenity

The zenity command on Windows using Scoop 🍨:

scoop install https://ncruces.github.io/scoop/zenity.json

The zenity command on macOS/Windows, if you have Go:

go install github.com/ncruces/zenity/cmd/zenity@latest

Or download the latest release.

Using

For the Go package, consult the documentation and examples.

The zenity command does its best to be compatible with the GNOME version.
Consult the documentation and man page of that command.

Why?

Benefits of the Go package:

  • no cgo (see benefits, mostly cross-compilation)
  • no main loop (or any other threading or initialization requirements)
  • cancelation through context
  • on Windows:
    • no additional dependencies
      • Explorer shell not required
      • works in Server Core
    • Unicode support
    • High DPI (no manifest required)
    • Visual Styles (no manifest required)
    • WSL/Cygwin/MSYS2 support
  • on macOS:
    • only dependency is osascript
  • on other Unixes:
    • wraps either one of zenity, matedialog, qarma

Zenity wrappers

Zenity wrappers for languages other than Go can benefit from our zenity command. On Unix (Linux, FreeBSD, etc) they can use the original tool, and on Windows/macOS they may use the command from this repo for portability.

Examples:

Credits

I'd like to thank all contributors, but @gen2brain in particular for dlgs, which was instrumental to the Windows port of zenity.

# Packages

# Functions

Attach returns an Option to set the parent window to attach to.
AutoClose returns an Option to dismiss the dialog when 100% has been reached.
Calendar displays the calendar dialog.
CancelLabel returns an Option to set the label of the Cancel button.
CheckList returns an Option to show check boxes (Unix only).
ClassHint returns an Option to set the program name and class as used by the window manager (Unix only).
Color returns an Option to set the color.
ConfirmCreate returns an Option to confirm file selection if the file does not yet exist (Windows only).
ConfirmOverwrite returns an Option to confirm file selection if the file already exists.
Context returns an Option to set a Context that can dismiss the dialog.
DefaultCancel returns an Option to give the Cancel button focus by default.
DefaultDate returns an Option to set the date.
DefaultItems returns an Option to set the items to initially select (Windows and macOS only).
Directory returns an Option to activate directory-only selection.
DisallowEmpty returns an Option to not allow zero items to be selected (Windows and macOS only).
Display returns an Option to set the X display to use (Unix only).
Ellipsize returns an Option to enable ellipsizing in the dialog text (Unix only).
Entry
Entry displays the text entry dialog.
EntryText
EntryText returns an Option to set the entry text.
Error displays the error dialog.
ExtraButton returns an Option to add one extra button.
Filename returns an Option to set the filename.
Height returns an Option to set the dialog height (Unix only).
HideText returns an Option to hide the entry text.
Icon returns an Option to set the dialog icon.
Info displays the info dialog.
IsAvailable reports whether dependencies of the package are installed.
List displays the list dialog.
ListItems displays the list dialog.
ListMultiple displays the list dialog, allowing multiple items to be selected.
ListMultipleItems displays the list dialog, allowing multiple items to be selected.
MaxValue returns an Option to set the maximum value.
MidSearch returns an Option to change list search to find text in the middle, not on the beginning (Unix only).
Modal returns an Option to set the modal hint.
NoCancel returns an Option to hide the Cancel button (Windows and Unix only).
Notify displays a notification.
NoWrap returns an Option to disable text wrapping (Unix only).
OKLabel returns an Option to set the label of the OK button.
Password displays the password dialog.
Progress displays the progress indication dialog.
Pulsate returns an Option to pulsate the progress bar.
Question displays the question dialog.
RadioList returns an Option to show radio boxes (Unix only).
SelectColor displays the color selection dialog.
SelectFile displays the file selection dialog.
SelectFileMultiple displays the multiple file selection dialog.
SelectFileSave displays the save file selection dialog.
ShowHidden returns an Option to show hidden files (Windows and macOS only).
ShowPalette returns an Option to show the palette.
TimeRemaining returns an Option to estimate when progress will reach 100% (Unix only).
Title returns an Option to set the dialog title.
Username returns an Option to display the username.
Warning displays the warning dialog.
Width returns an Option to set the dialog width (Unix only).
WindowIcon returns an Option to set the window icon.

# Constants

ErrCanceled is returned when the cancel button is pressed, or window functions are used to close the dialog.
ErrExtraButton is returned when the extra button is pressed.
The stock dialog icons.
ErrUnsupported is returned when a combination of options is not supported.
The stock dialog icons.
The stock dialog icons.
The stock dialog icons.
The stock dialog icons.
The stock dialog icons.

# Structs

FileFilter is an Option that sets a filename filter.

# Interfaces

An Option is an argument passed to dialog functions to customize their behavior.
ProgressDialog allows you to interact with the progress indication dialog.

# Type aliases

DialogIcon is an Option that sets the dialog icon.
FileFilters is an Option that sets multiple filename filters.