# GUI for commandline programs

**URL:** <https://www.ruby-forum.com/t/gui-for-commandline-programs/197149>\
**Category:** Ruby\
**Created:** [September 3, 2010, 10:11am UTC](https://www.ruby-forum.com/t/gui-for-commandline-programs/197149 "2010-09-03T10:11:42Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Handy\_G](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/3ab097/32.png) [@Handy\_G](https://www.ruby-forum.com/u/Handy_G)\
**Post date:** [September 3, 2010, 10:11am UTC](https://www.ruby-forum.com/t/gui-for-commandline-programs/197149/1 "2010-09-03T10:11:42Z")

</div>

I’m looking for a simple, easy to learn, low weight GUI for use in Ruby  
programs that mainly use the command line but where a bit of GUI might  
be  
in order.

To give a clearer idea, let me show some examples:

1. Going to a youtube user that has multiple playlists, parsing the  
playlist then opening a GUI with a list of the playlists so you can  
chose  
which to download.

2. At a point in the program, you need to specify a folder to store your  
data in, so you want to pop open a folder save dialog box, then continue  
with your basic commandline program.

3. A loop in a program input a file, parses the input and creates a  
(directed acyclic) graph from it. There is a bug someplace between the  
parser and the graph generator. You put a form at the beginning showing  
input data some intermediate variables, and drawing the graph as it  
evolves to visualize what is going wrong.

I hope from these three examples that the things I am looking for in a  
GUI toolkit clear. The GUI elements are incidental to the main program,  
the main program is a commandline program and for some reason or other a  
part of the program is made simpler with a bit of GUI. This however is  
only the case if the GUI is itself simple. Spending a lot of time  
setting up an application loop and a GUI justs mucks things up in this  
case. Also, in each case the GUI portion is started and stopped several  
times in one run of a program.

Suggestions?

---

<div class="post-metadata">

**Author:** ![Handy\_G](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/3ab097/32.png) [@Handy\_G](https://www.ruby-forum.com/u/Handy_G)\
**Post date:** [September 3, 2010, 10:20am UTC](https://www.ruby-forum.com/t/gui-for-commandline-programs/197149/2 "2010-09-03T10:20:28Z")

</div>

Sorry for double posting, I have absolutely no idea how that happened.

PS This is on linux.

---

<div class="post-metadata">

**Author:** ![Handy\_G](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/3ab097/32.png) [@Handy\_G](https://www.ruby-forum.com/u/Handy_G)\
**Post date:** [September 3, 2010, 11:12am UTC](https://www.ruby-forum.com/t/gui-for-commandline-programs/197149/3 "2010-09-03T11:12:11Z")

</div>

Handy G. wrote:

> Suggestions?

Depends how portable you want it. Under Ubuntu you could get away with:

# Text dialog

if system(‘whiptail’,’–title’,‘AARGH’,’–yesno’,‘Delete all your  
files?’,‘7’,‘40’)  
raise “Ha ha!”  
end

# GTK+ dialog

if system(‘zenity’,’–question’,’–text’,‘Delete all your files?’)  
raise “Gotcha”  
end

“dialog” is another, older package for text-based dialogs.

---

<div class="post-metadata">

**Author:** ![Handy\_G](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/3ab097/32.png) [@Handy\_G](https://www.ruby-forum.com/u/Handy_G)\
**Post date:** [September 3, 2010, 10:25am UTC](https://www.ruby-forum.com/t/gui-for-commandline-programs/197149/4 "2010-09-03T10:25:28Z")

</div>

Handy G. wrote:

> I’m looking for a simple, easy to learn, low weight GUI for use in Ruby  
> programs that mainly use the command line but where a bit of GUI might  
> be  
> in order.
> 
> To give a clearer idea, let me show some examples:
> 
> 1. Going to a youtube user that has multiple playlists, parsing the  
> playlist then opening a GUI with a list of the playlists so you can  
> chose  
> which to download.
> 
> 2. At a point in the program, you need to specify a folder to store your  
> data in, so you want to pop open a folder save dialog box, then continue  
> with your basic commandline program.
> 
> 3. A loop in a program input a file, parses the input and creates a  
> (directed acyclic) graph from it. There is a bug someplace between the  
> parser and the graph generator. You put a form at the beginning showing  
> input data some intermediate variables, and drawing the graph as it  
> evolves to visualize what is going wrong.
> 
> I hope from these three examples that the things I am looking for in a  
> GUI toolkit clear. The GUI elements are incidental to the main program,  
> the main program is a commandline program and for some reason or other a  
> part of the program is made simpler with a bit of GUI. This however is  
> only the case if the GUI is itself simple. Spending a lot of time  
> setting up an application loop and a GUI justs mucks things up in this  
> case. Also, in each case the GUI portion is started and stopped several  
> times in one run of a program.
> 
> Suggestions?

I have used fxruby & foxGUIb successfully for a wee while.  
FoxGUIb for the GUI (and it uses fxruby).

Also I’ve used Shoes.

So I can recommend either for you’re solution.

rgds,

Dave.

---

<div class="post-metadata">

**Author:** ![Handy\_G](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/3ab097/32.png) [@Handy\_G](https://www.ruby-forum.com/u/Handy_G)\
**Post date:** [September 3, 2010, 11:20am UTC](https://www.ruby-forum.com/t/gui-for-commandline-programs/197149/5 "2010-09-03T11:20:00Z")

</div>

I should add, that will handle your case (1) and (2) happily, but not  
(3).

The granddaddy of all these is Tk. I think it should be OK if you want  
to draw some stuff, run the main loop while you wait for user feedback,  
then break out of the main loop to carry on doing normal stuff. I don’t  
think you’re constrained to a single “main loop”.

---

<div class="post-metadata">

**Author:** ![Handy\_G](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/3ab097/32.png) [@Handy\_G](https://www.ruby-forum.com/u/Handy_G)\
**Post date:** [September 3, 2010, 5:38pm UTC](https://www.ruby-forum.com/t/gui-for-commandline-programs/197149/6 "2010-09-03T17:38:30Z")

</div>

> I’m looking for a simple, easy to learn, low weight GUI for use in Ruby  
> programs that mainly use the command line but where a bit of GUI might  
> be  
> in order.

If you want easy cross platform I might suggest something jruby-like.

anyway here’s a list:  
[http://wiki.github.com/rdp/ruby\_tutorials\_core/ruby-gui-toolkit-comparison](http://wiki.github.com/rdp/ruby_tutorials_core/ruby-gui-toolkit-comparison)

Enjoy!  
-r

---

<div class="post-metadata">

**Author:** ![Handy\_G](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/3ab097/32.png) [@Handy\_G](https://www.ruby-forum.com/u/Handy_G)\
**Post date:** [September 3, 2010, 5:31pm UTC](https://www.ruby-forum.com/t/gui-for-commandline-programs/197149/7 "2010-09-03T17:31:23Z")

</div>

Dave,

Friday, September 3, 2010, 2:31:12 AM, you wrote:

DL\> Handy G. wrote:

> > I’m looking for a simple, easy to learn, low weight GUI for use in Ruby  
> > programs that mainly use the command line but where a bit of GUI might  
> > be  
> > in order.

> > To give a clearer idea, let me show some examples:

> > 1. Going to a youtube user that has multiple playlists, parsing the  
> > playlist then opening a GUI with a list of the playlists so you can  
> > chose  
> > which to download.

> > 1. At a point in the program, you need to specify a folder to store your  
> > data in, so you want to pop open a folder save dialog box, then continue  
> > with your basic commandline program.

> > 1. A loop in a program input a file, parses the input and creates a  
> > (directed acyclic) graph from it. There is a bug someplace between the  
> > parser and the graph generator. You put a form at the beginning showing  
> > input data some intermediate variables, and drawing the graph as it  
> > evolves to visualize what is going wrong.

> > I hope from these three examples that the things I am looking for in a  
> > GUI toolkit clear. The GUI elements are incidental to the main program,  
> > the main program is a commandline program and for some reason or other a  
> > part of the program is made simpler with a bit of GUI. This however is  
> > only the case if the GUI is itself simple. Spending a lot of time  
> > setting up an application loop and a GUI justs mucks things up in this  
> > case. Also, in each case the GUI portion is started and stopped several  
> > times in one run of a program.

> > Suggestions?

DL\> I have used fxruby & foxGUIb successfully for a wee while.  
DL\> FoxGUIb for the GUI (and it uses fxruby).

DL\> Also I’ve used Shoes.

DL\> So I can recommend either for you’re solution.

I use FxRuby for exactly that purpose and I like it a lot.

Sadly, it has reached end-of-life and neither the underlying FOX C++  
library or FXRuby that uses it seem to be supported.

---

<div class="post-metadata">

**Author:** ![Handy\_G](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/3ab097/32.png) [@Handy\_G](https://www.ruby-forum.com/u/Handy_G)\
**Post date:** [September 6, 2010, 4:39pm UTC](https://www.ruby-forum.com/t/gui-for-commandline-programs/197149/8 "2010-09-06T16:39:31Z")

</div>

On Fri, 03 Sep 2010 04:20:18 -0500, Brian C. wrote:

> I should add, that will handle your case (1) and (2) happily, but not  
> (3).
> 
> The granddaddy of all these is Tk. I think it should be OK if you want  
> to draw some stuff, run the main loop while you wait for user feedback,  
> then break out of the main loop to carry on doing normal stuff. I don’t  
> think you’re constrained to a single “main loop”.

I have never used Tk, though I have encountered it often. It was  
actually  
Tk that I ws thinking of when I wrote the post originally, but I’m  
under  
the impression that there are several major shortcomings with Tk (  
people  
with more practical experience of Tk please feel free to correct my  
impressions ).

Tk itself is falling into disfavor, so it may not be viable for much  
longer.

The Ruby bindings for TK are crude and iffy.

The documentation for the Ruby bindings of Tk is very poor.

The Ruby bindings for TK are not very “Ruby-like”.

---

<div class="post-metadata">

**Author:** ![Handy\_G](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/3ab097/32.png) [@Handy\_G](https://www.ruby-forum.com/u/Handy_G)\
**Post date:** [September 6, 2010, 4:39pm UTC](https://www.ruby-forum.com/t/gui-for-commandline-programs/197149/9 "2010-09-06T16:39:55Z")

</div>

As a shoes maintainer, I’m a bit biased. But since Shoes is more of an  
app toolkit than ‘toss a gui on something’, it might not be right for  
you in its current incarnation.

I’ve been playing around with QtRuby lately, and it’s pretty solid.
