[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

How to make a browser in Ruby Tk

sujeet kumar

6/16/2005 1:58:00 PM

Hi
I want to make a web browser in Ruby Tk. I used "net/http" to connect
to net. url is to be given in Tk entry. I am getting data from url
using "response = http.get(url)" . when i printed "response.body" it
gives the HTML source of the given Url. Now I want to display the
content in Ruby Frame. How can i print this ( data of url) in Ruby
Frame.
Please Help
thanks
sujeet


12 Answers

Hidetoshi NAGAI

6/16/2005 2:43:00 PM

0

sujeet kumar

6/16/2005 10:24:00 PM

0

When I run Ruby's source archive ("ext/tk/sample/tkextlib/tkHTML/hv.rb").
I got error
/usr/local/lib/ruby/1.8/tk/package.rb:86:in `require': TkPackage can't
find package Tkhtml (RuntimeError)
from /usr/local/lib/ruby/1.8/tkextlib/tkHTML/htmlwidget.rb:15
from /usr/local/lib/ruby/1.8/tkextlib/tkHTML.rb:13:in `require'
from /usr/local/lib/ruby/1.8/tkextlib/tkHTML.rb:13
from hv.rb:10:in `require'
from hv.rb:10
When i run the program in example given by you it also gives same error.
I want to display HTML text in Ruby widget as the HTML file displays
in web browser.
bye
sujeet


On 6/16/05, Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp> wrote:
> From: sujeet kumar <sujeetkr@gmail.com>
> Subject: How to make a browser in Ruby Tk
> Date: Thu, 16 Jun 2005 22:57:40 +0900
> Message-ID: <734fb92405061606571300ad7d@mail.gmail.com>
> > I want to make a web browser in Ruby Tk. I used "net/http" to connect
> > to net. url is to be given in Tk entry. I am getting data from url
> > using "response = http.get(url)" . when i printed "response.body" it
> > gives the HTML source of the given Url. Now I want to display the
> > content in Ruby Frame. How can i print this ( data of url) in Ruby
> > Frame.
>
> Probably one of the easiest way is to use TkHTML extension
> (see http://www.hwaci.com/sw/tkhtml/...).
> If you install the extension on your Tcl/Tk environment
> (for example, you use ActiveTcl binary package) and use
> the Tcl/Tk's library on your Ruby/Tk, please try a browser
> example by Ruby/Tk + TkHTML. That is included in Ruby's
> source archive ("ext/tk/sample/tkextlib/tkHTML/hv.rb").
> If the HTML text which you want to browse is a simple one,
> the following may be enough to show the formatted document.
> --------------------------------------------------------------
> require 'tk'
> require 'tkextlib/tkHTML'
>
> ... read a HTML-doc, and set it to the variable 'doc' ...
>
> hv = Tk::HTML_Widget.new.pack
> hv.parse(doc)
>
> ...
> --------------------------------------------------------------
> --
> Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
>
>


Hidetoshi NAGAI

6/17/2005 1:05:00 AM

0

sujeet kumar

6/19/2005 5:42:00 AM

0

Hi,
I am new to ruby. How to install the extension onTcl/Tk
environment and use the Tcl/Tk's library on Ruby/Tk ? My OS is fc3
and I installed everything of the option on fc3 cd. My ruby version is
"ruby 1.8.2 (2004-12-25) [i686-linux]". I tried to install from
http://www.hwaci.com/sw/tkhtml/... link but it doesn't work.
ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.2-previ... is
also not working.
What packages do i need for installing the extension? I don't know
about Tcl . How to check it is properly installed? It would be
helpfull if you send me some suitable link for these.
Thanks
sujeet

On 6/17/05, Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp> wrote:
> From: sujeet kumar <sujeetkr@gmail.com>
> Subject: Re: How to make a browser in Ruby Tk
> Date: Fri, 17 Jun 2005 07:23:37 +0900
> Message-ID: <734fb9240506161523725ce0ba@mail.gmail.com>
> > When I run Ruby's source archive ("ext/tk/sample/tkextlib/tkHTML/hv.rb").
> > I got error
>
> I wrote
> > If you install the extension on your Tcl/Tk environment
> > (for example, you use ActiveTcl binary package) and use
> > the Tcl/Tk's library on your Ruby/Tk,
>
> The error which you got shows that Tcl/Tk's TkHTML extension is not
> installed (or not ready to use) on your environment.
>
> # Please read "<ruby library>/tkextlib/SUPPORT_STATUS".
> --
> Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
>
>


Hidetoshi NAGAI

6/19/2005 3:15:00 PM

0

sujeet kumar

6/19/2005 6:41:00 PM

0

Hi
I installed ActiveTcl8.5.0.0b3.121397-linux-ix86.tar.gz in
/usr/local/ActiveTcl.
Now how to " add ActiveTcl's library directory to your library path"
I tried to use

[bash]$ D_LIBRARY_PATH=/usr/local/ActiveTcl/lib:$LD_LIBRARY_PATH \
ruby your-Ruby/Tk-script
it gives "ruby: No such file or directory -- your-Ruby/Tk-script (LoadError)"
how can i find the path of "ruby your-Ruby/Tk-script"? Is it
"/home/sujeet/Soft/ruby-1.8.2/ext/tk" or it is in /usr directory or
else.

[bash]$ _LIBRARY_PATH=/usr/local/ActiveTcl/lib:$LD_LIBRARY_PATH irb
gives "irb(main):001:0> "
what to do next?

or how to use TCLLIBPATH ?
'Tk::AUTO_PATH.value' or 'Tk::AUTO_PATH.list' gives
bash: Tk::AUTO_PATH.value: command not found
bash: Tk::AUTO_PATH.list: command not found

After this in ./configure --with-tcl-dir=/usr/local/ActiveTcl/ > --with-tk-dir=/usr/local/ActiveTcl/ > --with-tcllib=tclstub8.4 > --with-tklib=tkstub8.4 > --enable-tcltk-stubs )
step what is tclstub8.4 ? should i replace it with tclstub8.5 as my
package is ActiveTcl8.5.0.0b3.121397-linux-ix86.tar.gz.

Rest steps are clear. This will be a great help for me .
Thanks
sujeet
On 6/19/05, Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp> wrote:
> From: sujeet kumar <sujeetkr@gmail.com>
> Subject: Re: How to make a browser in Ruby Tk
> Date: Sun, 19 Jun 2005 14:42:09 +0900
> Message-ID: <734fb924050618224250c7f7f9@mail.gmail.com>
> > I am new to ruby. How to install the extension onTcl/Tk
> > environment and use the Tcl/Tk's library on Ruby/Tk ? My OS is fc3
> > and I installed everything of the option on fc3 cd. My ruby version is
> > "ruby 1.8.2 (2004-12-25) [i686-linux]". I tried to install from
> > http://www.hwaci.com/sw/tkhtml/... link but it doesn't work.
>
> I don't know existence of RPM pakage of tkHTML extension for FC3.
> If you have development packages of Tcl/Tk and want install tkHTML
> from source files, you'll be able to find the compile steps in
> COMPILE.txt included in the tkHTML source archive.
>
> If you don't mind to use RPM packages, maybe to use the ActiveTcl
> binary package is one of the easiest way to make some extensions
> available on your Ruby/Tk.
> Then,
>
> * get an ActiveTcl binary package.
> (e.g. ActiveTcl8.4.10.0.147113-linux-ix86.tar.gz)
>
> * extract the package.
> (e.g. tar xvzf ActiveTcl8.4.10.0.147113-linux-ix86.tar.gz)
>
> * cd to the extracted directory and run ./install.sh.
> (e.g. cd ActiveTcl8.4.10.0.147113-linux-ix86; sh ./install.sh).
>
> Assume that ActiveTcl is installed at /usr/local/ActiveTcl.
>
> * Please read 'ext/tcltklib/README.ActiveTcl'(Ruby-1.8)
> 'ext/tk/README.ActiveTcl'(Ruby-1.9) .
>
> * add ActiveTcl's library directory to your library path.
>
> * extract Ruby source archive and cd to the generated directory.
>
> * run ./configure with options which indicates ActiveTcl libraries.
> (e.g. ./configure --with-tcl-dir=/usr/local/ActiveTcl/ > --with-tk-dir=/usr/local/ActiveTcl/ > --with-tcllib=tclstub8.4 > --with-tklib=tkstub8.4 > --enable-tcltk-stubs )
>
> * make & make install
>
> > What packages do i need for installing the extension? I don't know
> > about Tcl . How to check it is properly installed?
>
> On Tcl/Tk, if succeed "package require <package name>",
> probably the package is properly installed.
> If you want to check whether an extension is ready to use
> on Ruby/Tk, please run "<ruby library>/tkextlib/pkg_checker.rb".
> It possibly help you to know what kind of extensions are available
> on your Ruby/Tk.
> When an extension is available on Tcl/Tk but not available on
> Ruby/Tk, possibly, the reason of the difference is that
> (1) Ruby/Tk use different Tcl/Tk libraries from tested Tcl/Tk, or
> (2) Ruby/Tk don't know the library path of the extension.
> If (1), maybe remove old(?) library and recompile "tcltklib.so".
> If (2), maybe you have to add initialize steps (e.g. add library
> path of the extension to AUTO_PATH) to "setup.rb" on the Ruby/Tk's
> wrapper library directory for the extension.
> --
> Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
>
>


Hidetoshi NAGAI

6/20/2005 2:18:00 AM

0

sujeet kumar

6/20/2005 7:51:00 AM

0

Hi,
This is summary of what i did.
I got ActiveTcl8.5.121397-linux-ix86.tar.gz.
1)I used :
tar xvzf ActiveTcl8.5.0.0b3.121397-linux-ix86.tar.gz
2)cd ActiveTcl8.5.0.0b3.121397-linux-ix86.tar.gz
3)sh ./install.sh
Now, ActiveTcl is installed at /usr/local/ActiveTcl
4)add ActiveTcl's library directory to your library path
i used :
export PATH="/usr/local/ActiveTcl/bin:$PATH"
3) i installed ruby
tar xvzf ruby-1.8.2.tar.gz
4)cd ruby-1.8.2
5)./configure --with-tcl-dir=/usr/local/ActiveTcl/ --with-tk-dir=/usr/local/ActiveTcl/ --with-tcllib=tclstub8.5 --with-tklib=tkstub8.5 --enable-tcltk-stubs
6)make
7)make install
8) LD_LIBRARY_PATH=/usr/local/ActiveTcl8.5.0.0b3/lib:$LD_LIBRARY_PATH
/usr/local/bin/irb
irb(main):001:0> require 'tk'
=> true
irb(main):002:0> Tk::TK_PATCHLEVEL
=> "8.4.7"
irb(main):003:0> Tk::AUTO_PATH.list
=> ["/usr/share/tcl8.4", "/usr/share", "/usr/local/lib", "/usr/lib",
"/usr/share/tk8.4"]
irb(main):004:0> require 'tkextlib/tkHTML'
RuntimeError: TkPackage can't find package Tkhtml
from /usr/local/lib/ruby/1.8/tk/package.rb:86:in `require'
from /usr/local/lib/ruby/1.8/tkextlib/tkHTML/htmlwidget.rb:15
from /usr/local/lib/ruby/1.8/tkextlib/tkHTML.rb:13:in `require'
from /usr/local/lib/ruby/1.8/tkextlib/tkHTML.rb:13
from (irb):4:in `require'
from (irb):4
9)since i installed ActiveTcl8.5.0.0b3.121397-linux-ix86
but Tk::TK_PATCHLEVEL, gives "8.4.7"
Is this mean I have ActiveTcl"8.4.7" installed?

Also,Tk::AUTO_PATH.list
doesnot give "/usr/local/ActiveTcl/"

What sould I do?
How to uninstall ActiveTcl"8.4.7"
How to add Path of "/usr/local/ActiveTcl/" in k::AUTO_PATH.list

Thanks
sujeet

On 6/20/05, Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp> wrote:
> From: sujeet kumar <sujeetkr@gmail.com>
> Subject: Re: How to make a browser in Ruby Tk
> Date: Mon, 20 Jun 2005 03:40:43 +0900
> Message-ID: <734fb924050619114028ad69ef@mail.gmail.com>
> > I installed ActiveTcl8.5.0.0b3.121397-linux-ix86.tar.gz in
> > /usr/local/ActiveTcl.
> > Now how to " add ActiveTcl's library directory to your library path"
> > I tried to use
> (snip)
> > step what is tclstub8.4 ? should i replace it with tclstub8.5 as my
> > package is ActiveTcl8.5.0.0b3.121397-linux-ix86.tar.gz.
>
> Hmmm....
> I tried on my environment (distribution:: Vine Linux).
> ActiveTcl 8.5.0.0b3 was installed at /usr/local/ActiveTcl8.5.0.0b3,
> and Ruby configured with ActiveTcl8.5.0.0b3 is installed under /usr/local

Hidetoshi NAGAI

6/20/2005 8:24:00 AM

0

sujeet kumar

6/20/2005 1:24:00 PM

0

hi, Firstly i add
/usr/local/ActiveTcl/lib to /etc/ld.so.conf on top
But it didn't work. Then I
i uninstall Tcl package of fc3.
i used " rpm -qa | grep tcl"
rpm -e --nodeps tcl-devel-8.4.7-2
rpm -e --nodeps tk-8.4.7-2
rpm -e --nodeps tcl-8.4.7-2

After this I reinstall ActiveTcl is installed at /usr/local/ActiveTcl
and set path.

Then i used tar xvzf ruby-1.8.2.tar.gz
cd ruby-1.8.2
/configure --with-tcl-dir=/usr/local/ActiveTcl/ --with-tk-dir=/usr/local/ActiveTcl/ --with-tcllib=tclstub8.5 --with-tklib=tkstub8.5 --enable-tcltk-stubs

make
make install
Then , LD_LIBRARY_PATH=/usr/local/ActiveTcl8.5.0.0b3/lib:$LD_LIBRARY_PATH
=/usr/local/bin/irb
irb(main):001:0> require 'tk'
LoadError: libtk8.4.so: cannot open shared object file: No such file
or directory - /usr/local/lib/ruby/1.8/i686-linux/tcltklib.so
from /usr/local/lib/ruby/1.8/i686-linux/tcltklib.so
from /usr/local/lib/ruby/1.8/tk.rb:7
from (irb):1:in `require'
from (irb):1
irb(main):002:0> Tk::TK_PATCHLEVEL
NameError: uninitialized constant Tk
from (irb):2
irb(main):003:0> Tk::AUTO_PATH.list
NameError: uninitialized constant Tk
from (irb):3
irb(main):004:0> require 'tkextlib/tkHTML'
NameError: uninitialized constant TkPackage
from /usr/local/lib/ruby/1.8/tkextlib/tkHTML/htmlwidget.rb:15
from /usr/local/lib/ruby/1.8/tkextlib/tkHTML.rb:13:in `require'
from /usr/local/lib/ruby/1.8/tkextlib/tkHTML.rb:13
from (irb):4:in `require'
from (irb):4
what should I do?
I want to install it any way. For this i can uninstall and reinstall
all things.Just tell me what to do.?
presently
rpm -qa | grep tcl
gives
tclx-8.3.5-4 db4-tcl-4.2.52-6 tcl-html-8.4.7-2
postgresql-tcl-7.4.6-1.FC3.1
tclx-devel-8.3.5-4
ruby-tcltk-1.8.1-7
tclx-doc-8.3.5-4

Should I erase all the above?
I think problem is that Ruby is not taking the path of Tcl/Tk
extension correctly.
bye
sujeet





On 6/20/05, Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp> wrote:
> From: sujeet kumar <sujeetkr@gmail.com>
> Subject: Re: How to make a browser in Ruby Tk
> Date: Mon, 20 Jun 2005 16:51:07 +0900
> Message-ID: <734fb92405062000511ea75167@mail.gmail.com>
> > 3)sh ./install.sh
> > Now, ActiveTcl is installed at /usr/local/ActiveTcl
> (snip)
> > 8) LD_LIBRARY_PATH=/usr/local/ActiveTcl8.5.0.0b3/lib:$LD_LIBRARY_PATH /usr/local/bin/irb
>
> That is a wrong path.
> You installed ActiveTcl to "/usr/local/ActiveTcl".
> So, you have to use
> LD_LIBRARY_PATH=/usr/local/ActiveTcl/lib:$LD_LIBRARY_PATH /usr/local/bin/irb
>
> > 9)since i installed ActiveTcl8.5.0.0b3.121397-linux-ix86
> > but Tk::TK_PATCHLEVEL, gives "8.4.7"
> > Is this mean I have ActiveTcl"8.4.7" installed?
>
> Probably, that is FC3's Tcl/Tk packages.
>
> > What sould I do?
>
> If you fail to load ActiveTcl's libraries instead of FC3's
> libraries (even if you use the right LD_LIBRARY_PATH),
> you maybe have to remove FC3's Tcl/Tk packages or add
> /usr/local/ActiveTcl/lib to /etc/ld.so.conf with
> higher priority than FC3's library path.
> --
> Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
>
>