[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Looking for better Ruby/Tk references...

Chris Dagnon

12/21/2005 3:28:00 PM

... or better GUI APIs for Ruby.
(Primary questions at the bottom)


- Long Version/Background -
Hello all and sorry for the disruption, but I'm mid-stream of learning
Ruby and I have some GUIs I want to write. However Ruby/Tk... isn't as
easy as falling down a hill. The best part of it is that it comes in
the Ruby install for Windows XP which I downloaded. The second best
part is that the Pragmatic guide has a short chapter on it.

Using it is a different story. Yes, I have managed to make some GUIs -
my standard Tic-Tac-Toe GUI, a file explorer, and a basic text editor.
But I'm finding it very, very hard to get any more complex primarily
because I cannot find any definitive information on it. Certainly there
is the "Use Perl/Tk manuals by doing the following translations" key,
except that is incorrect for non-basic elements, if they even appear in
Ruby/Tk. TkOptionMenubutton isn't from Tk, and the 3 TkOption*'s don't
seem to fit the 2 Option*'s in Tk.

I've also gone through some other references like the MacDevCenter Tk
Primer - states that you need to start your option list with a '*' or it
doesn't work. However mine worked fine without it, which I hope means
that the API has matured since then and not what it could otherwise mean.

This page (email) gives a better overview of Ruby/Tk than most do, but
again lacks many of the specifics I need to get the API to work.
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/1386...

On a more philosophical note, I am still getting used to Ruby and having
to script things instead of write-and-compile things, and my question is:

Can Ruby be made explicit instead of implicit?

I can grant you that Java only seems explicit to me because:
a) I've spent enough time on the basics that I never have to think about
them anymore, and
b) that IDEs have had Ctrl+Space working for a long time for it, and
c) I can always fall back on the somewhat informative Javadoc at
java.sun.com.

So are there IDEs for Ruby which provide everything Eclipse provides
including the things which Ruby's scriptiveness requires, like
validating variable names are of the correct type and scope and defined
beforehand? Perhaps also including an IRB - minus the double
character-per-keypress like the SciTE(?).

I fought long enough with Swing and SWT to make my own basic enclosing
APIs so that if everything compiled, everything ran (usually even
correctly). With Ruby that isn't possible, but I'm curious if a better
paradigm could exist with Ruby and GUIs.




- Short Version -
My questions are:

0. Which version of Tcl/Tk does Ruby/Tk correspond to? Is there an
exact translation list showing which elements have Ruby/Tk counterparts,
or where to find implementations of them? (I haven't tried using
tkextlib yet)

1. Is there a definitive list of all valid key-value pairs for any or
all Tk elements? Explicitly listed with the method used to set them,
eg. .configure() or .command() etc. Hopefully also with one or more
examples of each and an explanation of what effects they are defined as
having (say, a Unit Text for each key-value pair?). If the only
resource are the Tcl/Tk man pages (where elements don't match 1-to-1 for
Ruby/Tk), have those been effective for others?

1b. A more definitive list of bind event name/combinations would be much
appreciated, as well as if .command() doesn't exist for an element
(having problems using it for TkOptionMenubutton), what can be used
instead on a change - or to bind to the associated TkVariable's change.

2. Has anyone compare/contrasted the existing GUI APIs for Ruby? Do any
of them have a Visual Studio? Or do any which can easily install on
Windows XP by a newbie have a Visual Design utility? I'm especially
interested in one which supports multiple monitors and a variety of
resolutions.

3. Is there an index page or GUI to definitively show what in the
ruby\tk subdirectories are runnable demos/samples and which are simply
included files?

4. Is there a Ruby/Tk homepage or Bugzilla? Several things have shown
incorrect behaviour, including TkOptionMenubutton where at times the
menu pops up completely separated from the menu or even the GUI itself.
I suppose that could be my settings' fault, however I'd still consider
that a bug if it was.


Thanks for any pointers,

-Chris


13 Answers

Justin Meyer

12/21/2005 6:45:00 PM

0

Hi Chris!

On Thu, 22 Dec 2005, Chris Dagnon wrote:

> ... or better GUI APIs for Ruby.
> (Primary questions at the bottom)

... well, without stepping into that minefield...

> again lacks many of the specifics I need to get the API to work.
> http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/1386...

... and without answering your other questions, is the following link of
any use to you?

http://www.jbrowse.com/text/ruby...

I'm no good for further details; I just happened to have that link
laying around :)

Cheers,

--
Justin


Chris Dagnon

12/21/2005 9:28:00 PM

0

> ... and without answering your other questions, is the following
> link of any use to you?
>
> http://www.jbrowse.com/text/ruby...

That is a much better reference than what I've found so far - gives both
an overview and some details, drill-downs for the different levels of
info and even a few implementation examples. Still not every detail I
need (missing TkOptionMenubutton and it's relationship to the whole),
and it is a lot to digest at once. But at least it is a lot :)

Thanks!

-Chris


Justin Meyer wrote:
> Hi Chris!
>
> On Thu, 22 Dec 2005, Chris Dagnon wrote:
>
>
>>... or better GUI APIs for Ruby.
>>(Primary questions at the bottom)
>
>
> ... well, without stepping into that minefield...
>
>
>>again lacks many of the specifics I need to get the API to work.
>>http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/1386...
>
>
> ... and without answering your other questions, is the following link of
> any use to you?
>
> http://www.jbrowse.com/text/ruby...
>
> I'm no good for further details; I just happened to have that link
> laying around :)
>
> Cheers,
>


Chris Dagnon

12/22/2005 1:24:00 AM

0

Now that I think of it, a better question is:

Ruby allows defaults to be stated for all parameters to a method.

Has/Can someone implement Ruby/Tk with *all* parameters (configure,
commands, bind's...) specifically stated with their defaults?


I hope,

-Chris


Chris Dagnon wrote:
>>... and without answering your other questions, is the following
>>link of any use to you?
>>
>>http://www.jbrowse.com/text/ruby...
>
>
> That is a much better reference than what I've found so far - gives both
> an overview and some details, drill-downs for the different levels of
> info and even a few implementation examples. Still not every detail I
> need (missing TkOptionMenubutton and it's relationship to the whole),
> and it is a lot to digest at once. But at least it is a lot :)
>
> Thanks!
>
> -Chris
>
>
> Justin Meyer wrote:
>
>>Hi Chris!
>>
>>On Thu, 22 Dec 2005, Chris Dagnon wrote:
>>
>>
>>
>>>... or better GUI APIs for Ruby.
>>>(Primary questions at the bottom)
>>
>>
>>... well, without stepping into that minefield...
>>
>>
>>
>>>again lacks many of the specifics I need to get the API to work.
>>>http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/1386...
>>
>>
>>... and without answering your other questions, is the following link of
>>any use to you?
>>
>>http://www.jbrowse.com/text/ruby...
>>
>>I'm no good for further details; I just happened to have that link
>>laying around :)
>>
>>Cheers,
>>


greg.kujawa

12/22/2005 2:24:00 PM

0

Chris Dagnon wrote:

> Has/Can someone implement Ruby/Tk with *all* parameters (configure,
> commands, bind's...) specifically stated with their defaults?

I'm not sure if this type of writeup currently exists. If you look
through the http://www.jbrowse.com/text/ruby... document you
still don't get enough information to get your project going? I had a
couple of projects that I used with Ruby/Tk and found this document to
help fill in the blanks pretty well. That and perhaps translating a
Perl/Tk book to Ruby's terms. I know these aren't ideal solutions but
they should get you maybe 90% of the way there...

greg.kujawa

12/22/2005 2:50:00 PM

0

Here is a good link that is a Tk reference -->
http://www.tcl.tk/man/tcl8.4/TkCmd/co.... Then taking into
considering how Ruby/Tk prefixes the widget names with a Tk and how
Ruby treats the various parameters in hash-like fashion you should get
an idea on how to manipulate things. For example:

myLabel=TkLabel.new(myTkRoot) {text 'myText'
font 'myFontNameAndSize'
}.grid(:column=>1, :row=>0)

Joe Van Dyk

12/23/2005 4:00:00 AM

0

On 12/22/05, gregarican <greg.kujawa@gmail.com> wrote:
> Here is a good link that is a Tk reference -->
> http://www.tcl.tk/man/tcl8.4/TkCmd/co.... Then taking into
> considering how Ruby/Tk prefixes the widget names with a Tk and how
> Ruby treats the various parameters in hash-like fashion you should get
> an idea on how to manipulate things. For example:
>
> myLabel=TkLabel.new(myTkRoot) {text 'myText'
> font 'myFontNameAndSize'
> }.grid(:column=>1, :row=>0)

I really prefer ruby-gnome2's API to tk's. It makes a whole lot more
sense to me (and the documentation is a lot better).

Gtk.init
window = Gtk::Window.new
label = Gtk::Label.new "my test"
window << label
window.show_all
Gtk.main_loop


greg.kujawa

12/23/2005 1:31:00 PM

0

Joe Van Dyk wrote:

> I really prefer ruby-gnome2's API to tk's. It makes a whole lot more
> sense to me (and the documentation is a lot better).

Me too. The fact that Tk comes bundled with the vanilla Ruby
installation (esp. in terms of the Windows One Click deal) makes it a
toolkit that folks hit the ground running with. But for me I feel that
GTK and Qt are a little more object oriented and are a better fit in
terms of Ruby. Plus like you said, the documentation is a lot better.
It's just a shame that in terms of Windows implementations the Qt
library really only works for Cygwin installs. The only way I got it to
work on non-Cygwin installs was by using a Qt binary fileset published
for Ruby 1.6.8...

tony summerfelt

12/23/2005 4:30:00 PM

0

Joe Van Dyk wrote on 12/22/2005 11:00 PM:

> I really prefer ruby-gnome2's API to tk's. It makes a whole lot more
> sense to me (and the documentation is a lot better).

i've been playing around with gtk the last couple of days. your
example DOES look cleaner...until you start getting into non-trivial
gui's...ruby/tk's stays about the same, but gtk's ramps WAY up.

and gtk doesn't play well with ruby2script, i'd rather not have an
end-user install gtk themselves ('cause you just know they're going to
get all the environment variables wrong).

while the documentation for gtk seems a lot better, it lacks useful
examples. i wanted to create a simple text editor similar to the one
found here: http://tinyurl... that example was too old for the
recent versions of ruby/gtk

i browsed the relevant documentation for hours (being new to gtk on
any platform) but coudln't find what i needed to change. granted i've
not done gui work in ruby before, but it shouldn't have been that hard
to crank out something as trivial as that.

--
http://home.cogeco.ca/~ts...
telnet://ventedspleen.dyndns.org



Joe Van Dyk

12/23/2005 5:23:00 PM

0

On 12/23/05, tony summerfelt <snowzone5@hotmail.com> wrote:
> Joe Van Dyk wrote on 12/22/2005 11:00 PM:
>
> > I really prefer ruby-gnome2's API to tk's. It makes a whole lot more
> > sense to me (and the documentation is a lot better).
>
> i've been playing around with gtk the last couple of days. your
> example DOES look cleaner...until you start getting into non-trivial
> gui's...ruby/tk's stays about the same, but gtk's ramps WAY up.
>
> and gtk doesn't play well with ruby2script, i'd rather not have an
> end-user install gtk themselves ('cause you just know they're going to
> get all the environment variables wrong).
>
> while the documentation for gtk seems a lot better, it lacks useful
> examples. i wanted to create a simple text editor similar to the one
> found here: http://tinyurl... that example was too old for the
> recent versions of ruby/gtk
>
> i browsed the relevant documentation for hours (being new to gtk on
> any platform) but coudln't find what i needed to change. granted i've
> not done gui work in ruby before, but it shouldn't have been that hard
> to crank out something as trivial as that.


http://ruby-gnome2.sourceforge.jp/hiki.cgi?Simple+T...


RubyTalk@gmail.com

1/12/2006 2:31:00 PM

0

I am working with tk to, and i find it hard to work with the examples i
find. I think the lack of good docs or examples holds me back from something
i would like to do. For example I wish i knew about the TkOptionMenubutton.
I created this code
this snippet gets the list of files on the hard drive then displays them in
the menu. u can go back and forth between folders. When you click a file it
adds it to the text box

[code]

require "tk"
def MakeMenu (dir)
a=Array.new
dirarray=Dir.entries(dir)
menu1 = TkMenu.new {
add 'command', {'label'=>"File", 'command'=>proc { }}
dirarray.each { |ax|
if File.file?(dir+"\\"+ax)
add 'command', {'label'=>ax, 'command'=>proc {
$Sendfile.value=$Sendfile.value+" "+dir.gsub(' ','|')+"\\"+ax}}
end
if File.directory?(dir+"\\"+ax) and ax !="." and
add 'command', {'label'=>ax, 'command'=>proc {MakeMenu(dir+"\\"+ax) }}
end
}

}
#pop up options
menu1.post TkWinfo.pointerx(root) ,TkWinfo.pointery(root)
end
root=TkRoot.new
usrname = TkVariable.new
v1 = TkVariable.new
$set_to_read =TkVariable.new
$email_array=Array.new
password = TkVariable.new
$Current_id=TkVariable.new
a=Array.new

radio_var = TkVariable.new('y')
$Voice_use= TkVariable.new(true)

TkFrame.new(root){
$Sendfile=TkText.new(self).pack "side"=>"top"
$Sendfile.width=50
$Sendfile.height=1
$options=TkButton.new(self) {text "files"
command {
MakeMenu("c:\\")
}
}.pack "side"=>"left"

pack}.grid "column"=>0,"row"=>3
TkFrame.new(root) {
}.grid "column"=>5, "row"=>5, "columnspan"=>5,"rowspan"=>5
Tk.mainloop

[code]

It is not as nice looking as a pull down menu, but its neat. I use it for
alot of my option menus.



On 12/21/05, Chris Dagnon <chris.dagnon@isthmusgroup.com> wrote:
>
> > ... and without answering your other questions, is the following
> > link of any use to you?
> >
> > http://www.jbrowse.com/text/ruby...
>
> That is a much better reference than what I've found so far - gives both
> an overview and some details, drill-downs for the different levels of
> info and even a few implementation examples. Still not every detail I
> need (missing TkOptionMenubutton and it's relationship to the whole),
> and it is a lot to digest at once. But at least it is a lot :)
>
> Thanks!
>
> -Chris
>
>
> Justin Meyer wrote:
> > Hi Chris!
> >
> > On Thu, 22 Dec 2005, Chris Dagnon wrote:
> >
> >
> >>... or better GUI APIs for Ruby.
> >>(Primary questions at the bottom)
> >
> >
> > ... well, without stepping into that minefield...
> >
> >
> >>again lacks many of the specifics I need to get the API to work.
> >>
> http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/1386...
> >
> >
> > ... and without answering your other questions, is the following link of
> > any use to you?
> >
> > http://www.jbrowse.com/text/ruby...
> >
> > I'm no good for further details; I just happened to have that link
> > laying around :)
> >
> > Cheers,
> >
>
>