我不断从我的代码中收到“未初始化 GLib::Object”错误。
这是代码:
class MainWindow < Gtk::Window
def initialize
title = "I'm The Title Of An Application! Yay!"
border_width = 10
set_size_request(600, 300)
signal_connect("destroy") { Gtk.main_quit }
@vbox = Gtk::VBox.new(false, 10)
add(@vbox)
show_all
end
end
main_window = MainWindow.new
有了这个,我得到了错误
in `set_size_request': uninitialize GLib::Object
所以我把那段代码移到了课堂之外,如下所示:
main_window = MainWindow.new
main_window.set_size_request(600, 300)
然后我得到:
in `signal_connect': uninitialize GLib::Object
所以我改变了它,所以我的班级并使用'set_resize_request'将'signal_connect'方法移动到班级之外,如下所示:
main_window = MainWindow.new
main_window.set_size_request(600, 300)
main_window.signal_connect("destroy") { Gtk.main_quit }
它给了我:
in `add': uninitialize GLib::Object
瓜!我又换了...
main_window = MainWindow.new
main_window.set_size_request(600, 300)
main_window.signal_connect("destroy") { Gtk.main_quit }
main_window.add(@vbox)
现在这个?!
in `show_all': uninitialize GLib::Object
所以,再一次,我从类中删除该方法并将其放在类之外
main_window = MainWindow.new
main_window.set_size_request(600, 300)
main_window.signal_connect("destroy") { Gtk.main_quit }
main_window.add(@vbox)
main_window.show_all
也许......也许这次它会起作用,所以我希望最好并再次运行代码......
in `set_size_request': uninitialize GLib::Object
什么?!这里发生了什么?