[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Run TCL in ruby

Michael Hale

1/12/2005 3:07:00 PM

Is there a simple way to run TCL code from ruby? Basically I have a
shared TCL library and I want to call the functions it has from Ruby
not from TCL.

Thanks, Michael



6 Answers

tony summerfelt

1/12/2005 5:12:00 PM

0

On Thu, 13 Jan 2005 00:06:47 +0900, you wrote:

>Is there a simple way to run TCL code from ruby?

from the examples posted here it's relatively simple, but
communicating with between ruby and tcl seems to be a
nightmare :/


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



Yukihiro Matsumoto

1/12/2005 11:26:00 PM

0

Hi,

In message "Re: Run TCL in ruby"
on Thu, 13 Jan 2005 02:11:55 +0900, tony summerfelt <snowzone5@hotmail.com> writes:

|>Is there a simple way to run TCL code from ruby?
|
|from the examples posted here it's relatively simple, but
|communicating with between ruby and tcl seems to be a
|nightmare :/

The tcltklib extension, which comes with the standard distribution,
invokes Tcl interpreter directly without any inter-process
communication.

matz.
require "tcltklib"

def test
ip1 = TclTkIp.new()

puts ip1._eval("button .lab -text exit -command \"destroy .\"").inspect
puts ip1._eval("pack .lab").inspect

puts ip1._eval(%q+puts [ruby {print "print by ruby\n"; "puts by tcl/tk"}]+).inspect
TclTkLib.mainloop
end

test


Hidetoshi NAGAI

1/13/2005 2:38:00 AM

0

tony summerfelt

1/13/2005 3:23:00 AM

0

On Thu, 13 Jan 2005 08:25:39 +0900, you wrote:

>invokes Tcl interpreter directly without any inter-process
>communication.

> puts ip1._eval("button .lab -text exit -command \"destroy .\"").inspect

it's the interprocess communication i would like :) in your example
above i would like the -command to execute ruby method/code

although i really like the syntax:

Tk.tk_call('source', 'gui.tcl')

gui.tcl contains the entire interface for the program, but i would
like the -command associated with each button to execute ruby code,
not tcl code...i also need to get all the text from a tcl text
widget...

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



Hidetoshi NAGAI

1/13/2005 4:08:00 AM

0

tony summerfelt

1/13/2005 6:06:00 PM

0

On Thu, 13 Jan 2005 13:07:44 +0900, you wrote:

>If you know the widget path on the tcl script and don't need to use
>the Tcl code associated -command option, those are very easy.

ok :)

> txt = TkText.new(:widgetname=>'.baz.txt', :without_creating=>true)

i got this far from the code you posted previously


> def show_text(txt)
> p txt.value
> end

> b = TkButton.new(:widgetname=>'.foo.bar.btn', :without_creating=>true)
> b.command(proc{ show_text(txt) }) # or b.command{ show_text(txt) }

> Tk.mainloop

this is pretty much exactly what i wanted. much simpler than the code
you posted earlier...

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