Jeff Schwab
4/30/2006 2:51:00 PM
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.