[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

optionparser to gui automation?

Mark Noworolski

3/24/2008 5:08:00 PM

[Note: parts of this message were removed to make it a legal post.]

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

5 Answers

Mark Noworolski

3/24/2008 11:47:00 PM

0

[Note: parts of this message were removed to make it a legal post.]

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 Merrick <dana.merrick@trincoll.edu>
wrote:

> You're probably looking for something like this:
>
> ruby-doc.org/stdlib/libdoc/optparse/rdoc/
>
> HTH,
> Dana Merrick
>
> Mark Noworolski wrote:
> > 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
> >
>
>

Nobuyoshi Nakada

3/25/2008 6:47:00 AM

0

Hi,

At Tue, 25 Mar 2008 02:07:54 +0900,
Mark Noworolski 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.

--
Nobu Nakada

Daniel Lucraft

3/25/2008 12:39:00 PM

0

Mark Noworolski 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.o...) which is not exactly a GUI
but it's a familiar interface. (Ruby wrapper here
http://rdialog.ruby...)

Or there's Zenity (http://live.gnome....). 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...

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

best,
Dan
--
Posted via http://www.ruby-....

Alex Shulgin

3/25/2008 7:27:00 PM

0

On Mar 24, 7:07 pm, Mark Noworolski <jma...@gmail.com> wrote:
> [Note: parts of this message were removed to make it a legal post.]
>
> 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?

Hi,

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

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/...
http://gtk-fortune.rubyforge.org/...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. ;-)

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

--
Regards,
Alex

Alex Shulgin

3/25/2008 7:33:00 PM

0

On Mar 25, 9:27 pm, Alex Shulgin <alex.shul...@gmail.com> 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/...
> http://gtk-fortune.rubyforge.org/...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)

--
Alex