tags:

views:

120

answers:

1

Ok, well I'm really pushing the bounds as to what shoes is for here, so I don't expect any miracles: is there a way to optionally run a shoes app without a gui?

The reason I'd like to do this is I'm creating a tool for use by "non computer people", as well as "computer people", who would rather just run the program as a command line tool, maybe even on systems without X/gtk installed. (I work as a multidisciplinary researcher, and shoes is great for focusing on tools and not fiddling with gui design all day.)

Here's some example code:

if(ARGV[1] == "nogui")
  puts "running computation on #{ARGV[2]}";
  exit();
end

Shoes.app(:width => 200, :height => 100) do
  @button = button("Quit").click() {
    exit();
    }
end

which works except I get a

Gtk-CRITICAL **: gtk_main_quit: assertion `main_loops != NULL' failed

error.

+1  A: 

I haven't tried it, but I don't know that Shoes will even happily start on a system without X. You're probably better off creating a shell script that chooses which version to start. Something like this:

#!/usr/bin/sh
NOGUI=0
if [ $# -gt 0 ]; then
  NOGUI=$1
fi
if [ $NOGUI = nogui ]; then
    shift
    echo "Running in command-line mode..."
    ruby command-line.rb "$@"
else
    echo "Starting Shoes..."
    shoes shoes.rb "$@"
fi

If the first argument is nogui, the remaining arguments are sent to the Ruby version, otherwise all arguments (including the first) are sent to Shoes.

Now you just need to separate the actual performance logic out so that it can be imported into both versions.

Pesto
Yeah, that's always an option, but then I don't have all the packaging niceties of shoes. Ruby, as well as the gems my program relies on would be install requirements. I've looked at rubyscript2exe, but I'm hoping shoes can do it better (and I'm hoping to not have to deal with multiple packaging solutions ;-) )I guess it's not so bad to require X and gtk libs, so long as the shoes app doesn't actually try and pop up a window; ie as long as it doesn't choke over an ssh connection I'd be happy.
Shawn