Reading GTKEntry text values?

I have built a sample text entry GUI using glade. I am using a GTKEntry
box and want to enter some text and write it out to the screen.

What method do I call to get this text?

I have the GUI displayed on the screen, I enter the text into the Entry
box but dont know how to retrieve this text so I may use “puts” to write
it to the screen.

thanks.

NoSpam wrote:

I have built a sample text entry GUI using glade. I am using a GTKEntry
box and want to enter some text and write it out to the screen.

What method do I call to get this text?

I have the GUI displayed on the screen, I enter the text into the Entry
box but dont know how to retrieve this text so I may use “puts” to write
it to the screen.

thanks.

Try puts entry_widget.get_text
where entry widget is your widget.

···


Jacek Podkanski

In DPgJ9.14$5w2.13982@newsfep2-gui, Jacek Podkanski wrote:

NoSpam wrote:

I have built a sample text entry GUI using glade. I am using a GTKEntry
box and want to enter some text and write it out to the screen.

What method do I call to get this text?

I have the GUI displayed on the screen, I enter the text into the Entry
box but dont know how to retrieve this text so I may use “puts” to
write it to the screen.

thanks.

Try puts entry_widget.get_text
where entry widget is your widget.

Thanks for the input, now my next problem!

I have been trying to use Glade (Linux) to design a GUI with Ruby. I have
made the GUI, which is no more than a simple text entry widget and a
“quit” button. I have got the “quit” button to work as intended, I enter
text into the “text Entry” widget and now I would like to retrieve the
inputted text.

I have it working if I don’t use Glade by using your method stated above.

How do I call this method using Glade(?) and Ruby?

< code follows >

#!/usr/bin/ruby

require ‘gtk’
require ‘lglade’

class Test
def initialize
@glade = GladeXML.new(“project7.glade”) {|handler| method(handler)}
end

def on_entry1_activate
	puts ### entered text ###
end

def on_button1_clicked
	Gtk.main_quit
end

end

sample = Test.new

Gtk.main