开发者

Ruby GTK fails without display (Python is OK)

it seems that Ruby GTK apps are unable to run in nongraphical environment.. while python apps are able to.

oversimplified e开发者_JS百科xamples (even without the gtk main loop), demonstrating this behavior:

gtktest.py:

#! /usr/bin/python
import gtk
print('the end')

gtktest.rb:

#! /usr/bin/ruby
require "gtk2"
puts('the end')

X window environment:

$ ./gtktest.py
the end
$ ./gtktest.rb
the end

non X environment:

$ ./gtktest.py
/usr/lib/pymodules/python2.5/gtk-2.0/gtk/__init__.py:57: GtkWarning: could not open display
  warnings.warn(str(e), _gtk.Warning)
the end

$ ./gtktest.rb
/usr/lib/ruby/1.8/gtk2.rb:12:in `init': Cannot open display:   (Gtk::InitError)
    from /usr/lib/ruby/1.8/gtk2.rb:12
    from ./gtktest.rb:2:in `require'
    from ./gtktest.rb:2

as you can see, python version runs succesfully with a warning, ruby one fails immediately on gtk importing (python one works even with a gtk main loop, with VTE terminal doing some text processing)

is someone aware of a possibility do have those ruby gtk apps running in non-X ?

environment: debian squeeze, python-gtk2, libgtk2-ruby


Yes you can, setup Xvfb.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜