15

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?

0

7 Answers 7

26

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

enter image description here

Replacing dialog by xdialog:

enter image description here

Sign up to request clarification or add additional context in comments.

8 Comments

See also zenity and kdialog.
@choroba - ooh my knowledge was dated; I don't use this very often :) Adding those
I know about these, but I don't know how can I put more than one item to dialog box, e.g. a yesno and an inputbox and a fselect. Or is this impossible?
@uzsolt: if you'd be so kind as to click on those links - every single one (edit except perhaps dialog) of them contains 'advanced' examples. However, if you really wanted to do 'complicated' dialgos, I suggest you a. use builtin guis from lpr and cups b. write in python/perl/etc
@sehe I've checked Xdialog's homepage before I've asked this question but I didn't found "advanced" examples. Now checked again, zenity and kdialog too but again not found. Or am I blind? :)
|
6

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"

Dialog

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?

Comments

3

Whiptail displays user-friendly dialog boxes from shell scripts

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.

whiptail example

Comments

1

matedialog (AKA mate-dialog) uses GTK+. It may also be the only script GUI dialog tool available under Cygwin.

Comments

1

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.

1 Comment

That looks interesting, I’ll also give several of the other suggestions on this page a try.
1

I know this is an old thread, but I strive to give my 2 cents. There is also guish you could try, though experimental.

Comments

0

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.

1 Comment

apt-get install xdialog

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.