[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

is GUI a weak point?

greg.rb

4/4/2006 8:20:00 PM

Ruby seems pretty eash to code and understand. However, as a
non-professional programmer, I find GUI the hardest part so far.
GTK didn't work out of the box on windows. It is too bad because it
looked like it would be one of the better GUI choices. I guess I will
have to try FOX.
Any suggestions?

Are there any good examples of getting tk widget data to ruby?

Here is a simple example where I try to build an interface for the user
to pick information which will then be sent to ruby to process.

#example:

require 'tk'

cash_locs=['NONE','NY1','NY2','NJ1','ETC.']

root = TkRoot.new() { title "PICK LOCATION" }
bar = TkScrollbar.new(root).pack('side'=>'right', 'fill'=>'y')
fromLoc = TkVariable.new
list = TkListbox.new(root){}
list.pack('side'=>'left', 'fill'=>'both', 'expand'=>true)
list.yscrollbar(bar)

cash_locs.each { |loc|
list.insert('end', loc)
}

button = TkButton.new(root) {
text 'OK'
command proc {fromLoc.value=list.curselection(),TkRoot.new.destroy}
}
button.pack()
TkButton.new(nil, 'text'=>'Quit',
'command'=>proc{TkRoot.new.destroy}).pack('fill'=>'x')

Tk.mainloop()

puts 'USER PICKED: '+cash_locs[fromLoc.value.to_i]

4 Answers

bpettichord

4/5/2006 5:19:00 AM

0

These days most people use the web for their GUI's. Have you considered
this? It doesn't have to be a web app per se. Ruby has lots of good
options in this area.

Michal Suchanek

4/5/2006 8:24:00 AM

0

On 4/4/06, greg.rb <ghalsey@yahoo.com> wrote:> Ruby seems pretty eash to code and understand. However, as a> non-professional programmer, I find GUI the hardest part so far.Generally, gui is the hard part of software that has to communicatewith the user. It takes a lot of work to get at least some gui withthe most importatnt options somewhere, and even more difficult to makeone that is easy to use.Some people find gui builders helpful. They allow you to designdialogs, menus, etc, and just load them ito your application. iircqtruby supports such thing.Creating dialogs on the fly is more versatile. You can add differentcontrols when your application is in different states. But then youshould look for toolkit with ruby bindings that makes constructing thelayout easy.For example, the tk toolkit only provides very primitive ways ofarranging elements. I am not sure if the ruby library provides somemore complex layouts. But with tk alone it may be quite hard tocreate a dialog with different kinds of elements that won't make theusers run away :)ThanksMichal

Hidetoshi NAGAI

4/5/2006 9:21:00 AM

0

greg.rb

4/5/2006 4:36:00 PM

0

thank you for showing me how to clean up the code.