optionparser to gui automation?

M

Mark Noworolski

[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
 
M

Mark Noworolski

[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
 
N

Nobuyoshi Nakada

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.
 
D

Daniel Lucraft

Mark said:
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
 
A

Alex Shulgin

[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/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. ;-)

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

Alex Shulgin

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top