FWIW, it doesn't currently work with 1.2 - I got the following (after
changing all 'require fox' to 'require fox12') :
$ ruby foxGUIb.rbw
../FX/fxbase.rb:386: uninitialized constant Fox::FXMenubar (NameError)
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/loadpath_manager.rb:5:in `r
equire__'
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/loadpath_manager.rb:5:in `r
equire'
from ./__FX__.rb:6
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/loadpath_manager.rb:5:in `r
equire__'
from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/loadpath_manager.rb:5:in `r
equire'
from foxGUIb.rbw:12
Curt Hibbs wrote:
> If you have FXRuby 1.0.29 or earlier, you do a require "fox". If you have
> FXRuby 1.2.2, you must do a require "fox12". Perhaps this is the problem.
>
> Curt
Thanks for pointing this out. foxGUIb is currently based on FXRuby
1.0.29. I did never test it with FXRuby 1.2.2.
Porting to the new FXRuby version is one of the next big tasks for me.
If you have FXRuby 1.0.29 or earlier, you do a require "fox". If you have
FXRuby 1.2.2, you must do a require "fox12". Perhaps this is the problem.
Curt
Thanks for pointing this out. foxGUIb is currently based on FXRuby 1.0.29. I did never test it with FXRuby 1.2.2.
Porting to the new FXRuby version is one of the next big tasks for me.
- henon
Actually it's not that big a task. I went through the same migration
for the FreeRIDE application some time ago and, although FreeRIDE is
quite a large application, it only took more a few hours of work to
make the necessary changes.
And by the way, having foxGUIb ported to FOX 1.2 would be a good start
for a tighter integration with the FreeRIDE Ruby IDE. That would be really
cool!
If you have FXRuby 1.0.29 or earlier, you do a require "fox".
If you have
FXRuby 1.2.2, you must do a require "fox12". Perhaps this is
the problem.
That doesn't work with RubyGems! I've installed fxruby (1.2.2). Does
anyone have the same problem?
If your using the RubyGems version of FXRuby, then you also need to require
"rubygems" first (or start ruby with the "-rubygems" option).
Sure, I do that. I'm running RubyGems 0.8.4.
If I remove both "s.autorequire" and "s.require_paths" from it's gemspec, and add 'ext/fox12.so' to the "s.files" list, then it works! Seems to be a RubyGems bug!
Looks familiar. Had the same problem this week when playing with my own XML viewer (with REXML). To solve this one, change all FXMenubar constants to FXMenuBar (also change FXTreelist to FXTreeList).
Further, the docs for FXTreeList aren't right, so I guess Lyle still has a few more loose ends to tie up. [XTreeList(p, nvis, tgt=nil, sel=0...] Try to enter an integer for nvis, and get a type error--it only accepts 'nil' for the second parm, and an integer for seletor--but I can't get it to recognize the selector to pass to an 'onCmd' method.
···
--
Regards,
Mark Smith mailto:mas.lists[at]cox.net
A: Yes.
>Q: Are you sure?
>>A: Because it reverses the logical flow of conversation.
>>>Q: Why is top posting frowned upon?
From: tony summerfelt <snowzone5@hotmail.com>
Subject: Interactive Fox GUI Builder and Code Generator
Date: Mon, 10 Jan 2005 03:44:52 +0900
Message-ID: <uou2u0pb160a25lqo250jvggjvmiv4mkvb@4ax.com>
>Ruby/Tk can load Tcl/Tk script files.
>So, one of the easiest way is to extract the GUI part of your script
>and load it into Ruby/Tk.
i did not know that...has anybody done this and liked the results?
for me that's a good short term solution.
However, you must decide how to get information from your GUI.
The following is a sample of using Tcl/Tk's 'rolodex' demo.
Please attend that Ruby/Tk creates widget objects automatically
when refers the widgets.
# Of course, you can create a widget object for a widget
# (that already exists) by your method call.
# e.g. TkEntry.new(:widgetname=>'.frame.entry1', :without_creating=>true)
If you have FXRuby 1.0.29 or earlier, you do a require "fox".
If you have
FXRuby 1.2.2, you must do a require "fox12". Perhaps this is
the problem.
That doesn't work with RubyGems! I've installed fxruby (1.2.2). Does
anyone have the same problem?
If your using the RubyGems version of FXRuby, then you also need to require
"rubygems" first (or start ruby with the "-rubygems" option).
Sure, I do that. I'm running RubyGems 0.8.4.
If I remove both "s.autorequire" and "s.require_paths" from it's gemspec, and add 'ext/fox12.so' to the "s.files" list, then it works! Seems to be a RubyGems bug!
No sorry. It does not work. It loads the gem, but not the fox12.so.
Looks familiar. Had the same problem this week when playing with my own XML viewer (with REXML). To solve this one, change all FXMenubar constants to FXMenuBar (also change FXTreelist to FXTreeList).
ERROR -- FXTreeList is the same constant -- it was FXTooltip that needs to be FXToolTip [sorry]
···
--
Regards,
Mark Smith mailto:mas.lists[at]cox.net
A: Yes.
>Q: Are you sure?
>>A: Because it reverses the logical flow of conversation.
>>>Q: Why is top posting frowned upon?
However, you must decide how to get information from your GUI.
all i need to do is process tk buttons (which button was clicked) ,
and get the text from a text widget...
irb(main):001:0> Tk.load_tclscript('rolodex')
i just tried a loading a test.tcl via irb and it ran ok...
the following didn't work though, in it's own file:
require 'tk'
Tk.load_tclscript('test.tcl')
i get:
test.rb:3: undefined method `load_tclscript' for Tk:Module
(NoMethodError)
what's interesting is that a ruby application can have ruby or tcl as
a scripting language.... http://home.cogeco.ca/~tsummerfelt1
telnet://ventedspleen.dyndns.org
If I remove both "s.autorequire" and "s.require_paths" from it's
gemspec, and add 'ext/fox12.so' to the "s.files" list, then it works!
Seems to be a RubyGems bug!
No sorry. It does not work. It loads the gem, but not the fox12.so.
Michael,
Are you talking about the FxRuby gem? What platform are you on? If you
can send a quick snippet that demonstrates the failure, I'll look over any
rubygems issues.
···
--
-- Jim Weirich jim@weirichhouse.org http://onestepback.org
-----------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)
From: tony summerfelt <snowzone5@hotmail.com>
Subject: calling tcl/tk scripts from ruby
Date: Tue, 11 Jan 2005 04:41:55 +0900
Message-ID: <bvl5u09nj09e9e0ts06bafq1ns8qun7mhs@4ax.com>
i just tried a loading a test.tcl via irb and it ran ok...
the following didn't work though, in it's own file:
require 'tk'
Tk.load_tclscript('test.tcl')
i get:
test.rb:3: undefined method `load_tclscript' for Tk:Module
(NoMethodError)
Oh, sorry! That is one of many new features of Ruby1.8.2.
The definition of the method is very simple.
--------------------------------------------------------
def Tk.load_tclscript(file, enc=nil)
if enc
# TCL_VERSION >= 8.5
tk_call('source', '-encoding', enc, file)
else
tk_call('source', file)
end
end
--------------------------------------------------------
Please add this or call Tk.tk_call('source', 'test.tcl').
--
Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
If I remove both "s.autorequire" and "s.require_paths" from it's
gemspec, and add 'ext/fox12.so' to the "s.files" list, then it works!
Seems to be a RubyGems bug!
No sorry. It does not work. It loads the gem, but not the fox12.so.
Michael,
Are you talking about the FxRuby gem? What platform are you on? If you
can send a quick snippet that demonstrates the failure, I'll look over any
rubygems issues.
> irb
>>> require 'rubygems'
>>> require 'fox12'
LoadError: No such file to load -- fox12
from /home/mneumann/Programs/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:26:in `require'
from (irb):2
thanks...that worked...the gui exited immediately, so i'll have to
play around with interacting with the gui, but i like this idea of
creating the gui code in pure tcl/tk...
From: tony summerfelt <snowzone5@hotmail.com>
Subject: Re: calling tcl/tk scripts from ruby
Date: Tue, 11 Jan 2005 12:10:05 +0900
Message-ID: <2qg6u0tmuj2dvnf2or35lurevp074n6umj@4ax.com>
thanks...that worked...the gui exited immediately, so i'll have to
play around with interacting with the gui, but i like this idea of
creating the gui code in pure tcl/tk...
Did you call Tk.mainloop after loading Tcl script?
e.g.
--------------------------------
require 'tk'
Tk.tk_call('source', 'test.tcl')
Tk.mainloop
--------------------------------
--
Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
am i wasting my time working with this? each button would have an
associated -command {proc} attached to it that would ideally be passed
to the ruby program.
and i think i asked this before but does using tk of any form within
ruby exclude the use of regular ruby threading? http://home.cogeco.ca/~tsummerfelt1
telnet://ventedspleen.dyndns.org
···
On Tue, 11 Jan 2005 12:33:08 +0900, you wrote:
Did you call Tk.mainloop after loading Tcl script?
am i wasting my time working with this? each button would have an
associated -command {proc} attached to it that would ideally be passed
to the ruby program.
Hmm...
In the procedure, if you have values that should be passed to ruby,
the values must be able to accessed in global space, because a button
widget's command option doesn't return a value.
# If you don't have such values, your script will work properly
# without editing.
When the procedure set the values to global variables,
you can access the variables with TkVarAccess.new(varname).
And you can trace or wait the TkVarAccess object.
If you want to call the Tk procedure and additional Ruby operation,
you can wrap the Tk procedure by a Ruby's procedure.
# Then, you can get the return value of the Tk procedure.
For example,
( ... after loading your example ... )
b = TkButton.new(:widgetname=>'.b', :without_creating=>true)
cmd = b.command # get the current command option's value
b.command{ret = Tk.ip_eval(cmd); p ['ruby', ret]}
You can also use 'ruby' (or 'ruby_cmd' on Ruby-1.8.2) on the Tk.
tcltklib adds them to the Tk interpreter.
'ruby script' calls Ruby API: rb_eval_string(script).
'ruby_cmd receiver method ?arg ...?' calls 'receiver.method(arg, ...)'.
However, the receiver must be a module or a class or a constant or
a global variable.
Maybe, one of those ways helps you ...
--
Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)