0
獲取文本我已經開始學習的GTK的繩索在Ruby中,我已經建立了這個非常簡單的程序:當我按下button
如何從一個GTK :: Entry控件紅寶石
require 'gtk2'
include Gtk
Gtk.init
window = Window.new
window.show
window.set_title "// Edit //"
window.signal_connect "destroy" do
Gtk.main_quit
end
box = VBox.new 10
text = Entry.new
text.set_text "Enter your name"
box.pack_start text
button = Button.new "Go!"
button.signal_connect "clicked" do
puts "Hello "+text.get_text()+"!"
end
box.pack_start button
window.add box
window.show_all
Gtk.main
然而,該程序輸出錯誤這樣說:
test.rb:21:in `block in <main>': undefined method `get_text' for # <Gtk::Entry:0x20be2d8 ptr=0x13831d0>
Did you mean? set_text
from test.rb:28:in `main'
from test.rb:28:in `<main>'
在這種情況下,我怎麼找回在GTK輸入構件的文本?提前致謝。