Problems with using Ocra

I try to create EXE file by Ocra. I have Tk in my script:


require ‘tk’
require ‘tkextlib/tile’

root = TkRoot.new {title “Feet to Meters”}
content = Tk::Tile::Frame.new(root) {padding “3 3 12 12”}.grid( :sticky
=> ‘nsew’)
TkGrid.columnconfigure root, 0, :weight => 1; TkGrid.rowconfigure root,
0, :weight => 1

$feet = TkVariable.new; $meters = TkVariable.new
f = Tk::Tile::Entry.new(content) {width 7; textvariable $feet}.grid(
:column => 2, :row => 1, :sticky => ‘we’ )
Tk::Tile::Label.new(content) {textvariable $meters}.grid( :column => 2,
:row => 2, :sticky => ‘we’);
Tk::Tile::Button.new(content) {text ‘Calculate’; command
{calculate}}.grid( :column => 3, :row => 3, :sticky => ‘w’)

Tk::Tile::Label.new(content) {text ‘feet’}.grid( :column => 3, :row =>
1, :sticky => ‘w’)
Tk::Tile::Label.new(content) {text ‘is equivalent to’}.grid( :column =>
1, :row => 2, :sticky => ‘e’)
Tk::Tile::Label.new(content) {text ‘meters’}.grid( :column => 3, :row =>
2, :sticky => ‘w’)

TkWinfo.children(content).each {|w| TkGrid.configure w, :padx => 5,
:pady => 5}
f.focus
root.bind(“Return”) {calculate}

def calculate
begin
$meters.value = (0.3048*$feet*10000.0).round()/10000.0
rescue
$meters.value = ‘’
end
end

Tk.mainloop

-----------------------------------------------------------------------------And
that is what I’ve got in my console:

C:\Users\Anton\Desktop\Programs>ocra test.rb
=== Loading script to check dependencies
=== Attempting to trigger autoload of
#<Class:#Tk::Tile::TEntry:0x000000051bd438>::Pack
=== WARNING: #<Class:#Tk::Tile::TEntry:0x000000051bd438>::Pack was
defined autoloadable, but caused NameError
=== Attempting to trigger autoload of
#<Class:#Tk::Tile::TEntry:0x000000051bd438>::Place
=== WARNING: #<Class:#Tk::Tile::TEntry:0x000000051bd438>::Place was
defined autoloadable, but caused NameError
=== Attempting to trigger autoload of
#<Class:#Tk::Tile::TEntry:0x000000051bd438>::Canvas
=== Attempting to trigger autoload of
#<Class:#Tk::Tile::TEntry:0x000000051bd438>::CheckButton
=== Attempting to trigger autoload of
#<Class:#Tk::Tile::TEntry:0x000000051bd438>::LabelFrame
=== Attempting to trigger autoload of
#<Class:#Tk::Tile::TEntry:0x000000051bd438>::Listbox
=== Attempting to trigger autoload of
#<Class:#Tk::Tile::TEntry:0x000000051bd438>::Menu
=== Attempting to trigger autoload of
#<Class:#Tk::Tile::TEntry:0x000000051bd438>::Message
=== Attempting to trigger autoload of
#<Class:#Tk::Tile::TEntry:0x000000051bd438>::PanedWindow
=== Attempting to trigger autoload of
#<Class:#Tk::Tile::TEntry:0x000000051bd438>::Scale
=== Attempting to trigger autoload of
#<Class:#Tk::Tile::TEntry:0x000000051bd438>::Scrollbar
=== Attempting to trigger autoload of
#<Class:#Tk::Tile::TEntry:0x000000051bd438>::Spinbox
=== Attempting to trigger autoload of
#<Class:#Tk::Tile::TEntry:0x000000051bd438>::Text
=== Attempting to trigger autoload of
#<Class:#Tk::Tile::TEntry:0x000000051bd438>::Toplevel
=== Attempting to trigger autoload of
#<Class:#Tk::Tile::TEntry:0x000000051bd438>::Clock
=== Attempting to trigger autoload of
#<Class:#Tk::Tile::TEntry:0x000000051bd438>::OptionObj
=== Attempting to trigger autoload of
#<Class:#Tk::Tile::TEntry:0x000000051bd438>::Fontchooser
=== Attempting to trigger autoload of
#<Class:#Tk::Tile::TEntry:0x000000051bd438>::MacResource
C:/Ruby23-x64/lib/ruby/2.3.0/tk/macpkg.rb:42:in <module:MacResource>': RuntimeError (RuntimeError) from C:/Ruby23-x64/lib/ruby/2.3.0/tk/macpkg.rb:31:in<top
(required)>’
from
C:/Ruby23-x64/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in
require' from C:/Ruby23-x64/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:inrequire’
from
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ocra-1.3.6/bin/ocra:477:in
const_get' from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ocra-1.3.6/bin/ocra:477:inblock
(3 levels) in attempt_load_autoload’
from
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ocra-1.3.6/bin/ocra:471:in each' from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ocra-1.3.6/bin/ocra:471:inblock
(2 levels) in attempt_load_autoload’
from
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ocra-1.3.6/bin/ocra:469:in each' from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ocra-1.3.6/bin/ocra:469:inblock
in attempt_load_autoload’
from
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ocra-1.3.6/bin/ocra:463:in loop' from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ocra-1.3.6/bin/ocra:463:inattempt_load_autoload’
from
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ocra-1.3.6/bin/ocra:715:in
build_exe' from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/ocra-1.3.6/bin/ocra:1177:inblock in <top (required)>’


Can anyone please help me to solve this problem?

Have a look at the switches you can use with Ocra. I had to try several
times before it worked and I don’t have the code in front of me, but
this was the first suggestion I found when looking online:

ocra rubyfile.rb --windows C:\Ruby192\lib\tcltk\ --no-autoload
–add-all-core

Add in your own script & tk directory.

Joel P. wrote in post #1185262:

Have a look at the switches you can use with Ocra. I had to try several
times before it worked and I don’t have the code in front of me, but
this was the first suggestion I found when looking online:

ocra rubyfile.rb --windows C:\Ruby192\lib\tcltk\ --no-autoload
–add-all-core

Add in your own script & tk directory.
It worked! Thank you! It seems I’m not good in searching solutions :slight_smile:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs