[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

[Tk] program file name problem

email55555 email55555

12/23/2004 6:50:00 PM

A sample Tk program likes:

require 'tk'
TkLabel.new(:text=>'Hello').pack
Tk.mainloop

Save it to a file named as "tk" or "tk.rb" do not have any problem to run it.
However, save it to a file like "button.rb" or "scale.rb",
when run it, you will get trouble.

I know that it is not a good idea to save Tk program to button.rb or
scale.rb ... etc. But I would like to understand:

(1) What's going wrong ? File name collision with Tk lib ?
( require 'tk' will load no correct files ?)

(2) So, what are names need to be avoid to use ?
All files name under <ruby_home> / lib / ruby / 1.8 / tk are reserved
file names when using tk library ?
If I am using tkextlib, I must avoid using file names under the
tkextlib folder too ?

Thank you.


4 Answers

Hidetoshi NAGAI

12/24/2004 3:58:00 AM

0

email55555 email55555

12/24/2004 4:20:00 PM

0

>I saved your script as "label.rb" and "button.rb".
>But, unfortunately, I couldn't re-generate your trouble.
>Of course, if the script is saved as "tk/label.rb" on the directory
>which has higher priority than the Ruby/Tk system directory,
>it will have to generate troubles.
>Please check your $LOAD_PATH and $LOADED_FEATURES.

Save it under any directory (folder) as you like on the name 'button.rb'
Of couse, it has no problem to run it, but try move your mouse cursor
to the generate Tk window.

Then you will get this error message window:
Error: unknown option "-state"
[OK] [Skip Messages] [Details>>]

Click on detail, here is the detail error message:
unknown option "-state"
unknown option "-state"
while executing
"$w cget -state"
(procedure "tk::ButtonEnter" line 3)
invoked from within
"tk::ButtonEnter ."
(command bound to event)

I am using now Tcl/Tk 8.4, and still have this problem.
Again, save to 'button.rb' or 'scale.rb' and no problem to run it,
but move the mouse cursor to the main window (ex. move to the "Hello" label )
then this error dialog message araise...

Thank you.


email55555 email55555

12/24/2004 11:23:00 PM

0

Retest this problem on Linux platform...
Linux platform does not have this problem.
So, it seems this problem only happen on M$ window platform ( I am
using one-click install binary distribution ).


Hidetoshi NAGAI

12/25/2004 1:15:00 AM

0