Ruby GTK 失败无显示(Python 还可以)

发布于 2024-09-03 04:37:32 字数 963 浏览 2 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情定在深秋 2024-09-10 04:37:32

是的你可以,设置Xvfb

Yes you can, setup Xvfb.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文