Reputation: 6027
I want create a simple graphical (Qt, Gtk, ...) dialog, concretly a simple print dialog, as a "frontend" to lpr, in bash. What I want? How many pages per page, printing interval. It's (at least) two options.
What is the best util(s) to solve this problem?
Upvotes: 15
Views: 30210
Reputation: 69
I know this is an old thread, but I strive to give my 2 cents. There is also guish you could try, though experimental.
Upvotes: 1
Reputation: 1848
If you wish to create a pure-Bash graphical dialogue then ctypes
has an example of GTK+ dialogue generation. In theory it should be able to call any GUI library installed or shipped alongside the script. As of October 2020 it looks to be actively maintained.
Upvotes: 1
Reputation: 23
matedialog
(AKA mate-dialog
) uses GTK+. It may also be the only script GUI dialog tool available under Cygwin.
Upvotes: 1
Reputation: 31498
Whiptail is a dialog
replacement using newt instead of ncurses. It
provides a method for displaying several different types of dialogue boxes
from shell scripts. This allows a script developer to interact with
the user in a much friendlier manner.
Upvotes: 3
Reputation: 101
You could use gdialog
in gnome/ubuntu
. I can't find xdialog
anymore in 14.10. The answer from @sehe works with it just change dialog for gdialog
.
Upvotes: 0
Reputation: 6027
I've searched what dialog creators are. I found yad and with this I can set my desired options:
yad --skip-taskbar --center --title="Print dialog" {--image,--window-icon}=/usr/share/icons/Tango/72x72/devices/printer1.png --form --item-separator=, --field="Pages per sheet":CB 1,2,4,6,8 --field="Pages"
And when I choose "2 pages per sheet" and pages "1-12" and after click OK
the output will 2|1-12|
.
This is what I desired. Zenity or Xdialog can do similar?
Upvotes: 6
Reputation: 392893
There is
Other implementations are reported to exist:
If you use gpm
, you can even use the mouse in a console environment. It requires a tty, so it will work over ssh, screen, xterm etc. but not when piping/redirecting.
Both sport more or less the same interface so you can switch depending on whether an X display is available
Here is a dialog script that displays a simple YES/NO box:
#!/bin/bash
DIALOG=${DIALOG=dialog}
$DIALOG --title " My first dialog" --clear \
--yesno "Hello , this is my first dialog program" 10 30
case $? in
0)
echo "Yes chosen.";;
1)
echo "No chosen.";;
255)
echo "ESC pressed.";;
esac
Replacing dialog
by xdialog
:
Upvotes: 26