Optionparser to gui automation?

I’m looking to support functionality like follows:

  1. You start a ruby program with commandline arguments (in a standard
    optionparser kind of way)…
  2. If you do not provide any, a GUI pops up, asking you for things
    that
    would otherwise be on the commandline.
  3. Ideally, this is automated with semi-sane defaults for the gui
    view.

I would expect that there might be some sort of optionparser extension
that
might do this but googling has not helped me out so far…

Does anybody know of anything like this?

mark

You’re probably looking for something like this:

ruby-doc.org/stdlib/libdoc/optparse/rdoc/

HTH,
Dana M.

What I’m after is something like a decorator on top of optionparser that
will create a gui for those who are averse to specifying commandline
arguments.

By way of example, boolean options might show up as checkboxes.

mark

On Mon, Mar 24, 2008 at 12:50 PM, Dana M.
[email protected]

Hi,

At Tue, 25 Mar 2008 02:07:54 +0900,
Mark N. wrote in [ruby-talk:295532]:

I’m looking to support functionality like follows:

  1. You start a ruby program with commandline arguments (in a standard
    optionparser kind of way)…
  2. If you do not provide any, a GUI pops up, asking you for things that
    would otherwise be on the commandline.
  3. Ideally, this is automated with semi-sane defaults for the gui view.

I would expect that there might be some sort of optionparser extension that
might do this but googling has not helped me out so far…

I had had similar idea at the time made it first, but haven’t
implemented nor heard about something like it.

Ah, I’m sorry, I misunderstood what part of the question you were not
aware of. I know there are Qt and GTK toolkits for Ruby, though I’ve
tried neither. I’m looking forward to playing with the Qt one though,
because Qt is a blast.

http://www.arachnoid.com/ruby/RubyGUIProject/

-Dana

On Mar 24, 7:07 pm, Mark N. [email protected] wrote:

might do this but googling has not helped me out so far…

Does anybody know of anything like this?

Hi,

A while ago, I had been trying to do something similar, but not
exactly. :slight_smile:

I’ve looked at this at a different angle: let’s say we have some
command-line utility with lots of options and we’d like to provide a
GUI. My idea was that as we can simply map GUI elements into command
line parameters, we can have a parser to read parameters from command
line and fill the GUI.

I’ve implemented a bit of this for my gtk-fortune project back while.
You might be interested to check out these:

http://gtk-fortune.rubyforge.org/svn/trunk/
http://gtk-fortune.rubyforge.org/svn/trunk/cmdgui

The relevant code is only in the trunk as I think it’s still not in a
shape for a release or separate project and I hadn’t touched it in
quite a while…

Please note, that in my approach I assumed that GUI is hand-made, not
generated, as this allows for “rich” options dialogs like “disable
that input field if this checkbox is cleared”, etc. Nonetheless, it
should work with a generated GUI as well. :wink:

Also, I’ve used my own limited command-line parser–it should be
possible to replace it with some widely used one.

Mark N. wrote:

I’m looking to support functionality like follows:

Haven’t heard of anything that automatically generates a GUI dialog from
command line options. But there are various libraries that make it easy
to generate dialogs from scripts. You tell it that you want the user to
enter a String with a default and so one.

There’s Dialog (http://hightek.org/dialog/) which is not exactly a GUI
but it’s a familiar interface. (Ruby wrapper here
http://rdialog.rubyforge.org/)

Or there’s Zenity (http://live.gnome.org/Zenity). If you are on Ubuntu
try typing:

$ zenity --entry

and see what happens. From Ruby you could call out to that through
%x{zenity --entry} and interpret the output.

Or Zerenity is a port of zenity to Ruby-Gnome2 so it is easily callable
from Ruby.
http://code.google.com/p/zerenity/

I haven’t tried these much, but there should be something there that you
could make work.

best,
Dan

On Mar 25, 9:27 pm, Alex S. [email protected] wrote:

I’ve implemented a bit of this for my gtk-fortune project back while.
You might be interested to check out these:

http://gtk-fortune.rubyforge.org/svn/trunk/
http://gtk-fortune.rubyforge.org/svn/trunk/cmdgui

Yeah, one more thing:

Without having to read the code, the following might be insightful:

@cmdgui = CmdGUI::Glade.new(@glade,
{ “-s” => “short_quotes_radiobutton”,
“-l” => “long_quotes_radiobutton”,
“-n” => [“custom_length_spinbutton”,

“custom_length_checkbutton”],
“-o” =>
“offensive_quotes_checkbutton”,
“-c” =>
“show_cookie_file_checkbutton” },
@cmdline)

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs