[ANN] foxGUIb - Interactive Fox GUI Builder and Code Generator

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

This is with the latest one-click installer.

martin

···

"henon (meinrad recheis)" <meinrad.recheis__nospam__@gmx.at> wrote:

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.

henon (meinrad recheis) wrote:

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.
- 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.

The best thing to is to go through Lyle Johnson's excellent document
step by step and apply the changes as described. (see
http://www.knology.net/~lyle/fox/1.2/WhatsNew.html-toc.html\)

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!

Laurent

i did not know that...has anybody done this and liked the results?

for me that's a good short term solution.
http://home.cogeco.ca/~tsummerfelt1
telnet://ventedspleen.dyndns.org

···

On Mon, 10 Jan 2005 00:30:18 +0900, you wrote:

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.

Curt Hibbs wrote:

Michael Neumann wrote:

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.

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!

Regards,

   Michael

Martin DeMello said the following on 1/5/2005 2:28 PM:

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.

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

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?

Hi,

···

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)

----------------------------------------------------------
$ /usr/local/bin/irb -r tk
irb(main):001:0> Tk.load_tclscript('rolodex')
=> ""
irb(main):002:0> Thread.new{Tk.mainloop}
=> #<Thread:0x40308768 sleep>
irb(main):003:0> TkWinfo.children(Tk.root)
=> [#<TkFrame:0x402f08c0 @path=".frame", @colormap=nil, @classname="Frame", @visual=nil, @db_class=TkFrame, @container=nil>, #<TkFrame:0x402ed9f4 @path=".buttons", @colormap=nil, @classname="Frame", @visual=nil, @db_class=TkFrame, @container=nil>, #<TkFrame:0x402ed3f0 @path=".menu", @colormap=nil, @classname="Frame", @visual=nil, @db_class=TkFrame, @container=nil>]
irb(main):004:0> TkWinfo.children(Tk.root).size
=> 3
irb(main):005:0> f = TkWinfo.children(Tk.root)[0]
=> #<TkFrame:0x402f08c0 @path=".frame", @colormap=nil, @classname="Frame", @visual=nil, @db_class=TkFrame, @container=nil>
irb(main):006:0> TkWinfo.children(f)
=> [#<TkLabel:0x402e496c @path=".frame.label1">, #<TkEntry:0x4021f600 @path=".frame.entry1">, #<TkLabel:0x4021d51c @path=".frame.label2">, #<TkEntry:0x4021b578 @path=".frame.entry2">, #<TkLabel:0x40219750 @path=".frame.label3">, #<TkEntry:0x4021810c @path=".frame.entry3">, #<TkLabel:0x40217a90 @path=".frame.label4">, #<TkEntry:0x402174dc @path=".frame.entry4">, #<TkLabel:0x40216d20 @path=".frame.label5">, #<TkEntry:0x40215a38 @path=".frame.entry5">, #<TkLabel:0x402147a0 @path=".frame.label6">, #<TkEntry:0x402128b0 @path=".frame.entry6">, #<TkLabel:0x40211140 @path=".frame.label7">, #<TkEntry:0x4020fc3c @path=".frame.entry7">]
irb(main):007:0> TkWinfo.children(f)[1].insert(:end, 'asdf')
=> #<TkEntry:0x4021f600 @path=".frame.entry1">
irb(main):008:0> e = TkWinfo.children(f)[1]
=> #<TkEntry:0x4021f600 @path=".frame.entry1">
irb(main):009:0> e.insert(:end, 'qwer')
=> #<TkEntry:0x4021f600 @path=".frame.entry1">
irb(main):010:0> e.value
=> "asdfqwer"
irb(main):011:0>
----------------------------------------------------------
--
Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)

Michael Neumann wrote:

Curt Hibbs wrote:

Michael Neumann wrote:

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.

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.

Regards,

   Michael

Mark Smith said the following on 1/5/2005 6:11 PM:

$ 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

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

···

On Tue, 11 Jan 2005 00:49:46 +0900, you wrote:

Michael Neumann said:

That doesn't work with RubyGems! [...]

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)

Hi,

···

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)

Jim Weirich wrote:

Michael Neumann said:

That doesn't work with RubyGems! [...]

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.

Platform: DragonFlyBSD (FreeBSD 4.x).

> ruby -v
ruby 1.8.2 (2004-12-22) [i386-dragonfly1.1]
> gem --version
0.8.4
> gem list
fxruby (1.2.2)
...

> 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

That's all I can tell for now.

Regards,

   Michael

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...

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

···

On Tue, 11 Jan 2005 11:23:07 +0900, you wrote:

Please add this or call Tk.tk_call('source', 'test.tcl').

Hi,

···

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)

smacks head...yeah, got it...

there's a bit of a logistics problem. usuall tk callbacks are defined
within the creation of the widget...

for example:

button .b -text "Quit" -command {proc_quit}
pack .b

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?

Hi,

···

From: tony summerfelt <snowzone5@hotmail.com>
Subject: Re: calling tcl/tk scripts from ruby
Date: Tue, 11 Jan 2005 13:20:27 +0900
Message-ID: <alk6u0d4s5jkadb0gqjkfb4c383ebcv66f@4ax.com>

there's a bit of a logistics problem. usuall tk callbacks are defined
within the creation of the widget...

for example:

button .b -text "Quit" -command {proc_quit}
pack .b

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)