Forum: Ruby Looking for better Ruby/Tk references...

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
2958660cbb27954a8b6acd6c797cb1f8?d=identicon&s=25 Chris Dagnon (Guest)
on 2005-12-21 16:28
(Received via mailing list)
... 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/...

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
698aa5ff88e0466785af6fd29cdcea3b?d=identicon&s=25 Justin Meyer (Guest)
on 2005-12-21 19:44
(Received via mailing list)
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/...

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

http://www.jbrowse.com/text/rubytk_en.html

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

Cheers,
2958660cbb27954a8b6acd6c797cb1f8?d=identicon&s=25 Chris Dagnon (Guest)
on 2005-12-21 22:29
(Received via mailing list)
> ... and without answering your other questions, is the following
> link of any use to you?
>
> http://www.jbrowse.com/text/rubytk_en.html

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
2958660cbb27954a8b6acd6c797cb1f8?d=identicon&s=25 Chris Dagnon (Guest)
on 2005-12-22 02:27
(Received via mailing list)
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
33ec7e55a251c1be8d6febfd929aebbe?d=identicon&s=25 Greg Kujawa (gregarican)
on 2005-12-22 15:29
(Received via mailing list)
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/rubytk_en.html 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...
33ec7e55a251c1be8d6febfd929aebbe?d=identicon&s=25 Greg Kujawa (gregarican)
on 2005-12-22 15:54
(Received via mailing list)
Here is a good link that is a Tk reference -->
http://www.tcl.tk/man/tcl8.4/TkCmd/contents.htm. 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)
38a8230ed3d5c685558b4f0aad3fc74b?d=identicon&s=25 Joe Van Dyk (Guest)
on 2005-12-23 05:01
(Received via mailing list)
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/contents.htm. 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
33ec7e55a251c1be8d6febfd929aebbe?d=identicon&s=25 Greg Kujawa (gregarican)
on 2005-12-23 14:37
(Received via mailing list)
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...
3a0d61d465c296f7f291b5bd09c90a4a?d=identicon&s=25 tony summerfelt (Guest)
on 2005-12-23 17:32
(Received via mailing list)
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.com/cmbrl 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.
38a8230ed3d5c685558b4f0aad3fc74b?d=identicon&s=25 Joe Van Dyk (Guest)
on 2005-12-23 18:26
(Received via mailing list)
On 12/23/05, tony summerfelt <snowzone5@hotmail.com> wrote:
> end-user install gtk themselves ('cause you just know they're going to
> to crank out something as trivial as that.
http://ruby-gnome2.sourceforge.jp/hiki.cgi?Simple+...
Dedb38b3571b323b77bc9b221e940172?d=identicon&s=25 ruby talk (Guest)
on 2006-01-12 15:32
(Received via mailing list)
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.
E4f967492dbd03c526cc9b397e68021d?d=identicon&s=25 Hidetoshi NAGAI (Guest)
on 2006-01-12 18:07
(Received via mailing list)
From: ruby talk <rubytalk@gmail.com>
Subject: Re: Looking for better Ruby/Tk references...
Date: Thu, 12 Jan 2006 23:31:29 +0900
Message-ID:
<25094bf70601120631j7fcd4f26uab43e3b534912f03@mail.gmail.com>
> 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

Did you see the sample "ext/tk/sample/tkcombobox.rb" on
the Ruby source tree?
It may be useful in such case.
Dedb38b3571b323b77bc9b221e940172?d=identicon&s=25 ruby talk (Guest)
on 2006-01-12 23:11
(Received via mailing list)
My example does not do anything so i probably skipped over it. Its like
the
C:\ruby\samples\tk\tkextlib examples.

Becker
Ef48af8b07b976160c860ddec9aea55f?d=identicon&s=25 Cam (Guest)
on 2006-01-13 01:39
(Received via mailing list)
Hi,

On 12/21/05, Chris Dagnon <chris.dagnon@isthmusgroup.com> wrote:
> 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.

Gtk can be used w/ glade (it works wonderfully for me).  I'm not sure
if glade is available for windows or not.  I'm assuming that Qt
Designer also works w/ ruby-qt, although I have never tried it myself.

Cameron Matheson
This topic is locked and can not be replied to.