16

I'm porting some simple X windows/bash scripts to Mac OSX, but I cannot find a build of Zenity (a Gnome app for basic GUI dialogs) for OSX. Is there some other command line driven dialog utility I can use? Basic operations: notification dialog

  • List item
  • (i.e. basic title, text, icon, OK button)
  • error notification
  • yes/no or ok/cancel prompts
  • select 1 or n items from a list
  • input text string

I don't (yet) know AppleScript (but it seems pretty verbose for the file maintenance tasks I'm interested in).

  • Cocoadialog does not have support for --username and --password like zenity does. Just a note! – Sindhu S Oct 13 '14 at 20:27
  • brew install zenity – user2707001 Nov 8 '17 at 20:43
12

Check out cocoaDialog:

cocoaDialog is an OS X application that allows the use of common GUI controls such as file selectors, text input, progress bars, yes/no confirmations and more with a command-line application. It requires no knowledge of Cocoa, and is ideal for use in shell and Perl scripts (or Ruby, or Python, or... etc).

It's a pretty simple concept — pass arguments to the executable to create a dialog, and it returns a result string. There are some good examples as well as documentation.

  • 1
    @mklement0 cocoaDialog as of November 2017 is back in active development: github.com/cocoadialog/cocoadialog – Rudolf Olah Nov 8 '17 at 14:45
  • The damn thing has no documentation, only sources on github. Donnow how to install it. – DimiDak Mar 27 '19 at 21:38
4

Homebrew provides the zenity package. It uses the MacOS X11 server (emulation) Xquartz.

Makes it easier to have cross-OS implementations, but it is not native MacOS X gui.

  • For those who are interested, zenity is available on x11 tap. Run brew install homebrew/x11/zenity to install it. – Subin Sebastian Jan 4 '16 at 12:14
2

Try also Pashua.

Pashua is a tool for creating native Aqua dialog windows from programming languages that have none or only limi­ted support for graphic user inter­faces on Mac OS X. Currently, it supports Apple­Script, Perl, PHP, Python, Groovy, Rexx, Ruby, shell scripts and Tcl—and if your favourite language is not included in this list: writing the glue code for communicating with Pashua is pretty simple.

  • +1; Pashua is powerful, but the API style is different from Zenity's in that instead of separate command-line arguments (multi-line) configuration strings describing the desired GUI must be passed. Probably takes longer to get started. – mklement0 Apr 14 '14 at 17:08
1

There is a zenity compatible implemention called qarma, written in qt, which can be compiled on mac os

https://github.com/luebking/qarma/issues/15

1

On your terminal

  brew install zenity && zenity --info --text "You did it!"

:)

0

It's been years, and this is a work in progress, but I'm working on a zenity “port” to both macOS and Windows.

You can get it here:
https://github.com/ncruces/zenity/releases

Read more:
https://github.com/ncruces/zenity

On macOS the only dependency is osascript (with JXA, because JavaScript is easier to work with than AppleScript).

On Windows there are no dependencies, not even the Explorer shell (which means it will work on Server Core).

0

MacOS comes with Tcl/Tk built-in. Mac's python comes with the Tkinter layer to use it, but you can also use it in the shell and X11.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .