Ruby GTK 失败无显示(Python 还可以)
Ruby GTK 应用程序似乎无法在非图形环境中运行。而 python 应用程序可以。
过于简化的示例(即使没有 gtk 主循环),演示了这种行为:
gtktest.py:
#! /usr/bin/python
import gtk
print('the end')
gtktest.rb:
#! /usr/bin/ruby
require "gtk2"
puts('the end')
X window 环境:
$ ./gtktest.py
the end
$ ./gtktest.rb
the end
非 X 环境:
$ ./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
如您所见,python 版本成功运行,但出现警告,ruby 版本立即失败 关于gtk导入 (python 甚至可以与 gtk 主循环一起使用,VTE 终端进行一些文本处理)
是否有人意识到这些 ruby gtk 应用程序在非 X 中运行的可能性?
环境:debian scrap、python-gtk2、libgtk2-ruby
it seems that Ruby GTK apps are unable to run in nongraphical environment.. while python apps are able to.
oversimplified examples (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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的你可以,设置Xvfb。
Yes you can, setup Xvfb.