[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Dumb newbie question

Ike

4/30/2006 1:13:00 PM

Been reading about Ruby for hours here, and have a very dumb question that
has to do with the creation of a GUI for applications. How does one do it? I
mean, say, how do you create a texbox, then assign the value of that textbox
to a String?

And would it be the same for Rails as a standalone?

I know that sounds stupid but the tutorials I have read and examples I have
seen have little to do with the GUI creation or interaction.

Thanks for the help, Ike


2 Answers

Tim Hunter

4/30/2006 1:38:00 PM

0

Ike wrote:
> Been reading about Ruby for hours here, and have a very dumb question that
> has to do with the creation of a GUI for applications. How does one do it? I
> mean, say, how do you create a texbox, then assign the value of that textbox
> to a String?
>
> And would it be the same for Rails as a standalone?
>
> I know that sounds stupid but the tutorials I have read and examples I have
> seen have little to do with the GUI creation or interaction.
>
> Thanks for the help, Ike
>
>
There are a number of GUI toolkits for Ruby. Each has its own pros and
cons. Here's a good starting point:
http://www.rubygarden.org/ruby?ComparingG....

Try googling "ruby gui" for more info.

For web-based applications such as those developed with Rails the
browser provides the interface and no extra GUI toolkit is required.

Jeff Schwab

4/30/2006 2:51:00 PM

0

Ike wrote:
> Been reading about Ruby for hours here, and have a very dumb question that
> has to do with the creation of a GUI for applications. How does one do it? I
> mean, say, how do you create a texbox, then assign the value of that textbox
> to a String?
>
> And would it be the same for Rails as a standalone?

That's not a stupid question.

For stand-alone applications, the simplest way is probably to use Tk.
For example:

require 'tk'
root = TkRoot.new() { title "Text Entry" }
text = TkVariable.new()
entry = TkEntry.new(root)
entry.textvariable(text)
entry.bind("Return") { puts text.value }
# Print the text when the user hits the Enter key.
entry.pack()
Tk.mainloop()

As Tim Hunter has pointed out, there are plenty of other GUI toolkits
available besides Tk.

If your application is running on a server, and you expect your users to
access it via web browsers, you will want to generate HTML forms instead
of directly invoking a GUI toolkit. I'm afraid I don't know much about
how Rails works to give you Rails-specific details. Your best bet is to
ask some Rails experts the best ways to create and use HTML forms.