Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Ruby 1.9.1 + Tk problem

Reply
Thread Tools

Ruby 1.9.1 + Tk problem

 
 
Diego Virasoro
Guest
Posts: n/a
 
      04-06-2009
Hello,
I have a Ruby/Tk code that runs perfectly in 1.8.x but stalls in
1.9.1.

Doing some investigation it seems that even the very basic programs:
require 'tk'

(that's not a mistake... it's literally only the require line) ends up
freezing the program. Anyone has any idea on what could be the
problem?

I am running Mac Os X 10.4 (Tiger), on a G4 machine.

Thank you

Diego
 
Reply With Quote
 
 
 
 
Hidetoshi NAGAI
Guest
Posts: n/a
 
      04-06-2009
From: Diego Virasoro <(E-Mail Removed)>
Subject: Ruby 1.9.1 + Tk problem
Date: Mon, 6 Apr 2009 19:34:21 +0900
Message-ID: <(E-Mail Removed)>
> I have a Ruby/Tk code that runs perfectly in 1.8.x but stalls in
> 1.9.1.
>
> Doing some investigation it seems that even the very basic programs:
> require 'tk'
>
> (that's not a mistake... it's literally only the require line) ends up
> freezing the program. Anyone has any idea on what could be the
> problem?
>
> I am running Mac Os X 10.4 (Tiger), on a G4 machine.


I'm very sorry, but I cannot check troubles on Mac OSX.
I need main information (trial and error) to fix troubles.

First of all, does the following work fine?
---------------------------------------------------------------------
require 'tcltklib'
ip = TclTkIp.new
ip._invoke('button', '.b', '-text', 'TEST', '-command', 'puts OK')
ip._invoke('pack', '.b')
TclTkLib.mainloop
---------------------------------------------------------------------
--
Hidetoshi NAGAI ((E-Mail Removed))

 
Reply With Quote
 
 
 
 
Jun Young Kim
Guest
Posts: n/a
 
      04-07-2009
tested on linux (ruby 1.9.1, tk8.5.3, tcl8.5.3)

successful compilation..

but, the script you've suggested

require 'tcltklib'
ip =3D TclTkIp.new
ip._invoke('button', '.b', '-text', 'TEST', '-command', 'puts OK')
ip._invoke('pack', '.b')
TclTkLib.mainloop

generated the following error.

ruby test.rb
test.rb:1:in `require': no such file to load -- tcltklib (LoadError)
from test.rb:1:in `<main>'

is this different problems?

2009. 04. 07, =BF=C0=C0=FC 6:51, Hidetoshi NAGAI =C0=DB=BC=BA:

> From: Diego Virasoro <(E-Mail Removed)>
> Subject: Ruby 1.9.1 + Tk problem
> Date: Mon, 6 Apr 2009 19:34:21 +0900
> Message-ID: =

<(E-Mail Removed)=20
> >
>> I have a Ruby/Tk code that runs perfectly in 1.8.x but stalls in
>> 1.9.1.
>>
>> Doing some investigation it seems that even the very basic programs:
>> require 'tk'
>>
>> (that's not a mistake... it's literally only the require line) ends =20=


>> up
>> freezing the program. Anyone has any idea on what could be the
>> problem?
>>
>> I am running Mac Os X 10.4 (Tiger), on a G4 machine.

>
> I'm very sorry, but I cannot check troubles on Mac OSX.
> I need main information (trial and error) to fix troubles.
>
> First of all, does the following work fine?
> ---------------------------------------------------------------------
> require 'tcltklib'
> ip =3D TclTkIp.new
> ip._invoke('button', '.b', '-text', 'TEST', '-command', 'puts OK')
> ip._invoke('pack', '.b')
> TclTkLib.mainloop
> ---------------------------------------------------------------------
> --=20
> Hidetoshi NAGAI ((E-Mail Removed))
>
>



 
Reply With Quote
 
Hidetoshi NAGAI
Guest
Posts: n/a
 
      04-07-2009
From: Jun Young Kim <(E-Mail Removed)>
Subject: Re: Ruby 1.9.1 + Tk problem
Date: Tue, 7 Apr 2009 11:12:15 +0900
Message-ID: <(E-Mail Removed)>
> generated the following error.
>
> ruby test.rb
> test.rb:1:in `require': no such file to load -- tcltklib (LoadError)
> from test.rb:1:in `<main>'
>
> is this different problems?


Yes.
Probably, ext/tk/extconf.rb failed to find Tcl/Tk headers or libraries.
So, extconf.rb made an invalid Makefile, and tcltklib.c wasn't compiled.
Please read ext/tk/README.tcltklib and re-generate a proper Makefile.
--
Hidetoshi NAGAI ((E-Mail Removed))

 
Reply With Quote
 
Diego.Virasoro@gmail.com
Guest
Posts: n/a
 
      04-08-2009
> I'm very sorry, but I cannot check troubles on Mac OSX.
> I need main information (trial and error) to fix troubles.


Thanks for the effort then.

> First of all, does the following work fine?

Yep. It does.

Tell me what to test next.

Diego
 
Reply With Quote
 
Hidetoshi NAGAI
Guest
Posts: n/a
 
      04-08-2009
From: http://www.velocityreviews.com/forums/(E-Mail Removed)
Subject: Re: Ruby 1.9.1 + Tk problem
Date: Wed, 8 Apr 2009 23:45:08 +0900
Message-ID: <(E-Mail Removed)>
> > First of all, does the following work fine?

> Yep. It does.
>
> Tell me what to test next.


Well, could you try the following patch?

--- tk.rb.orig 2009-04-07 06:04:22.000000000 +0900
+++ tk.rb 2009-04-09 06:27:07.000000000 +0900
@@ -1130,30 +1130,30 @@
opts = ''
end

- if WITH_RUBY_VM ### check Ruby 1.9 !!!!!!!
- # *** NEED TO FIX ***
- ip = TclTkIp.new(name, opts)
- if ip._invoke_without_enc('tk', 'windowingsystem') == 'aqua' &&
- (TclTkLib.get_version <=> [8,4,TclTkLib::RELEASE_TYPE::FINAL,9]) > 0
- # *** KNOWN BUG ***
- # Main event loop thread of TkAqua (> Tk8.4.9) must be the main
- # application thread. So, ruby1.9 users must call Tk.mainloop on
- # the main application thread.
- RUN_EVENTLOOP_ON_MAIN_THREAD = true
- INTERP = ip
- else
- unless self.const_defined? :RUN_EVENTLOOP_ON_MAIN_THREAD
- RUN_EVENTLOOP_ON_MAIN_THREAD = false
- end
- if RUN_EVENTLOOP_ON_MAIN_THREAD
+ unless self.const_defined? :RUN_EVENTLOOP_ON_MAIN_THREAD
+ if WITH_RUBY_VM ### check Ruby 1.9 !!!!!!!
+ # *** NEED TO FIX ***
+ ip = TclTkIp.new(name, opts)
+ if ip._invoke_without_enc('tk', 'windowingsystem') == 'aqua' &&
+ (TclTkLib.get_version<=>[8,4,TclTkLib::RELEASE_TYPE::FINAL,9]) > 0
+ # *** KNOWN BUG ***
+ # Main event loop thread of TkAqua (> Tk8.4.9) must be the main
+ # application thread. So, ruby1.9 users must call Tk.mainloop on
+ # the main application thread.
+ RUN_EVENTLOOP_ON_MAIN_THREAD = true
INTERP = ip
else
- ip.delete
+ unless self.const_defined? :RUN_EVENTLOOP_ON_MAIN_THREAD
+ RUN_EVENTLOOP_ON_MAIN_THREAD = false
+ end
+ if RUN_EVENTLOOP_ON_MAIN_THREAD
+ INTERP = ip
+ else
+ ip.delete
+ end
end
- end
- ip = nil
- else
- unless self.const_defined? :RUN_EVENTLOOP_ON_MAIN_THREAD
+ ip = nil
+ else
RUN_EVENTLOOP_ON_MAIN_THREAD = false
end
end
@@ -1202,6 +1202,9 @@
INTERP_THREAD_STATUS = INTERP_THREAD[:status]
end

+ # WINDOWING_SYSTEM = TclTkLib::WINDOWING_SYSTEM
+ WINDOWING_SYSTEM = INTERP._invoke_without_enc('tk', 'windowingsystem')
+
def INTERP.__getip
self
end
@@ -1703,12 +1706,15 @@
TclTkLib.mainloop(check_root)

elsif TkCore::RUN_EVENTLOOP_ON_MAIN_THREAD
- # if TclTkLib::WINDOWING_SYSTEM == 'aqua' &&
- if TkCore::INTERP._invoke_without_enc('tk','windowing system')=='aqua' &&
- Thread.current != Thread.main &&
- (TclTkLib.get_version <=> [8,4,TclTkLib::RELEASE_TYPE::FINAL,9]) > 0
- raise RuntimeError,
- "eventloop on TkAqua ( > Tk8.4.9 ) works on the main thread only"
+ if Thread.current != Thread.main
+ msg = 'eventloop on '
+ if TkCore::WINDOWING_SYSTEM == 'aqua' &&
+ (TclTkLib.get_version<=>[8,4,TclTkLib::RELEASE_TYPE::FINAL,9]) > 0
+ msg << "TkAqua ( > Tk8.4.9 )"
+ else
+ msg << "your current environment (or setting)"
+ end
+ raise RuntimeError, msg << " works on the main thread only"
end
TclTkLib.mainloop(check_root)


--
Hidetoshi NAGAI ((E-Mail Removed))

 
Reply With Quote
 
Diego.Virasoro@gmail.com
Guest
Posts: n/a
 
      04-09-2009
I'll try as soon as I can (though I am a bit busy right now).

However I tried to read a bit of the tk.rb file... and noticed the
known bug about TkAqua. My Tk is version 8.4.7... could it be that
that too has the same bug? (you check for a version >8.4.9).

Thanks again.

Diego
 
Reply With Quote
 
Hidetoshi NAGAI
Guest
Posts: n/a
 
      04-09-2009
From: (E-Mail Removed)
Subject: Re: Ruby 1.9.1 + Tk problem
Date: Thu, 9 Apr 2009 22:25:04 +0900
Message-ID: <(E-Mail Removed)>
> However I tried to read a bit of the tk.rb file... and noticed the
> known bug about TkAqua. My Tk is version 8.4.7... could it be that
> that too has the same bug? (you check for a version >8.4.9).


May not be...
I thought that such kind of trouble depends on TkAqua's specification
with native threads.
If you use standard Tcl/Tk.framework libraries and you have no other
Tcl/Tk libraries on your MacOSX box, please tell me your configure
options when you compiled ruby (tcltklib).

However, I'm happy if you try the patch and report the result of the
following two test codes which are different at the first line only.
---------------------------------------------------------------
module TkCore; RUN_EVENTLOOP_ON_MAIN_THREAD=false; end
p TkCore::RUN_EVENTLOOP_ON_MAIN_THREAD
require 'tk'
p TkCore::RUN_EVENTLOOP_ON_MAIN_THREAD
p TkButton.new(:text=>'TEST',:command=>proc{p 'test'}).pack
Tk.mainloop
---------------------------------------------------------------
---------------------------------------------------------------
module TkCore; RUN_EVENTLOOP_ON_MAIN_THREAD=true; end
p TkCore::RUN_EVENTLOOP_ON_MAIN_THREAD
require 'tk'
p TkCore::RUN_EVENTLOOP_ON_MAIN_THREAD
p TkButton.new(:text=>'TEST',:command=>proc{p 'test'}).pack
Tk.mainloop
---------------------------------------------------------------
--
Hidetoshi NAGAI ((E-Mail Removed))

 
Reply With Quote
 
Jun Young Kim
Guest
Posts: n/a
 
      04-14-2009
this is a first example.
$> ruby test.rb
false
false
#<Tk::Button:0x000000012257a8 @path=3D".w00000">
"test" <-- when I click "TEST" button.
"test"
"test"

this is a second example.
$> ruby test.rb
true
true
#<Tk::Button:0x00000000be2918 @path=3D".w00000">
"test" <-- when I click "TEST" button.
"test"

2009. 04. 10, =BF=C0=C0=FC 6:22, Hidetoshi NAGAI =C0=DB=BC=BA:

> From: (E-Mail Removed)
> Subject: Re: Ruby 1.9.1 + Tk problem
> Date: Thu, 9 Apr 2009 22:25:04 +0900
> Message-ID: =

<(E-Mail Removed)=20
> >
>> However I tried to read a bit of the tk.rb file... and noticed the
>> known bug about TkAqua. My Tk is version 8.4.7... could it be that
>> that too has the same bug? (you check for a version >8.4.9).

>
> May not be...
> I thought that such kind of trouble depends on TkAqua's specification
> with native threads.
> If you use standard Tcl/Tk.framework libraries and you have no other
> Tcl/Tk libraries on your MacOSX box, please tell me your configure
> options when you compiled ruby (tcltklib).
>
> However, I'm happy if you try the patch and report the result of the
> following two test codes which are different at the first line only.
> ---------------------------------------------------------------
> module TkCore; RUN_EVENTLOOP_ON_MAIN_THREAD=3Dfalse; end
> p TkCore::RUN_EVENTLOOP_ON_MAIN_THREAD
> require 'tk'
> p TkCore::RUN_EVENTLOOP_ON_MAIN_THREAD
> p TkButton.new(:text=3D>'TEST',:command=3D>proc{p 'test'}).pack
> Tk.mainloop
> ---------------------------------------------------------------
> ---------------------------------------------------------------
> module TkCore; RUN_EVENTLOOP_ON_MAIN_THREAD=3Dtrue; end
> p TkCore::RUN_EVENTLOOP_ON_MAIN_THREAD
> require 'tk'
> p TkCore::RUN_EVENTLOOP_ON_MAIN_THREAD
> p TkButton.new(:text=3D>'TEST',:command=3D>proc{p 'test'}).pack
> Tk.mainloop
> ---------------------------------------------------------------
> --=20
> Hidetoshi NAGAI ((E-Mail Removed))
>
>



 
Reply With Quote
 
Hidetoshi NAGAI
Guest
Posts: n/a
 
      04-16-2009
From: Jun Young Kim <(E-Mail Removed)>
Subject: Re: Ruby 1.9.1 + Tk problem
Date: Tue, 14 Apr 2009 16:37:26 +0900
Message-ID: <(E-Mail Removed)>
> this is a first example.

(snip)
> this is a second example.


Thank you for your report.

Probably, your test environment is

> tested on linux (ruby 1.9.1, tk8.5.3, tcl8.5.3)


(based on [ruby-talk: 333180]).

I think that the trouble doesn't occur on linux.
I reconfirmed that by your report.
Thank you, again.

But now, we investigate the trouble on MacOS X
(or Diego's environment ).
I have no MacOS X environment.
So, I need many information or advices to fix the problem.
--
Hidetoshi NAGAI ((E-Mail Removed))

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ruby extension (C++) on OS X [ruby 1.8.2] and Google-Sketchup [ruby 1.8.5] Nicholas Ruby 3 01-28-2007 01:48 AM
The Ruby Edge - Digg for Ruby and Ruby On Rails roschler Ruby 0 10-15-2006 11:35 PM
ruby-talk, comp.lang.ruby, ruby-talk-google Phrogz Ruby 4 09-06-2006 06:43 PM
#!/usr/bin/ruby , #!/usr/bin/ruby -w , #!/usr/bin/ruby -T?, #!/usr/bin/ruby -T1... anne001 Ruby 1 04-23-2006 03:02 PM
[ANN] ruby-freedb, ruby-serialport, ruby-mp3info moved to Rubyforge guillaume.pierronnet@ratp.fr Ruby 0 08-31-2003 11:57 PM



Advertisments