我最近想在我的Fedora 15盒子上安裝GTK的Ruby綁定。我使用yum
(ruby-gtk2
,ruby-gtk2-devel
,所有這些)安裝了所有的軟件包,並且在嘗試在Ruby中執行簡單的Hello World GUI應用程序時出現NameError錯誤。下面的代碼:Fedora上的ruby gtk安裝問題
require 'gtk'
window = Gtk::Window.new(Gtk::WINDOW_TOPLEVEL)
button = Gtk::Button.new("Hello World")
window.set_title("Hello Ruby")
window.border_width(10)
# Connect the button to a callback.
button.signal_connect('clicked') { puts "Hello Ruby" }
# Connect the signals 'delete_event' and 'destroy'
window.signal_connect('delete_event') {
puts "delete_event received"
false
}
window.signal_connect('destroy') {
puts "destroy event received"
Gtk.main_quit
}
window.add button
window.show_all
Gtk.main
in'window = Gtk :: Window.new' ... – tekknolagi
我仍然得到這個'gtk.rb:3:未初始化的常量Gtk :: WINDOW_TOPLEVEL(NameError)'不幸 – tekknolagi