Probably one of the easiest way is to use TkHTML extension
(see http://www.hwaci.com/sw/tkhtml/index.html).
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 (na...@ai.kyutech.ac.jp)
On 6/16/05, Hidetoshi NAGAI <na...@ai.kyutech.ac.jp> wrote:
> From: sujeet kumar <suje...@gmail.com>
> Subject: How to make a browser in Ruby Tk
> Date: Thu, 16 Jun 2005 22:57:40 +0900
> Message-ID: <734fb92405061...@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/index.html).
> 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)
>
> ...
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 (na...@ai.kyutech.ac.jp)
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 (na...@ai.kyutech.ac.jp)
[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
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.
Then,
------------------------------------------------------------------
(bash)$ 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.5a2"
irb(main):003:0> Tk::AUTO_PATH.list
=> ["/usr/local/ActiveTcl8.5.0.0b3/lib/tcl8.5", "/usr/local/ActiveTcl8.5.0.0b3/lib", "/usr/local/lib", "/usr/local/ActiveTcl8.5.0.0b3/lib/tk8.5"]
irb(main):004:0> require 'tkextlib/tkHTML'
=> true
irb(main):005:0>
------------------------------------------------------------------
Please note that "require 'tkextlib/tkHTML'" returns true.
It shows that TkHTML extension is available.
Cannot you get the same result?
If you don't, please check conflict between ActiveTcl and other
versions of Tcl/Tk libraries.
If you succeed, please try
"LD_LIBRARY_PATH=/usr/local/ActiveTcl8.5.0.0b3/lib:$LD_LIBRARY_PATH
/usr/local/bin/ruby /usr/local/lib/ruby/1.8/tkextlib/pkg_checker.rb -v".
--
Hidetoshi NAGAI (na...@ai.kyutech.ac.jp)
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
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 (na...@ai.kyutech.ac.jp)
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 <na...@ai.kyutech.ac.jp> wrote:
Did you execute /sbin/ldconfig after modifying /etc/ld.so.conf?
# On my environment, that works properly.
> 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
Please check that tcltklib.so is really compiled.
> Then , LD_LIBRARY_PATH=/usr/local/ActiveTcl8.5.0.0b3/lib:$LD_LIBRARY_PATH
^^^^^^^^^
???
You installed ActiveTcl at "/usr/local/ActiveTcl", didn't you?
Is that typo? If not, it is no wonder to fail to find libraries.
As I wrote in my last mail, you must add "/usr/local/ActiveTcl/lib".
e.g.
(bash)$ LD_LIBRARY_PATH=/usr/local/ActiveTcl/lib /usr/local/bin/irb
> 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?
If you erased FC3's Tcl/Tk packages, probably all of them will not
work. Those are fillers of your disk. :-)
# If setting is proper, ActiveTcl can coexistent with FC3's Tcl/Tk.
--
Hidetoshi NAGAI (na...@ai.kyutech.ac.jp)
On 6/20/05, Hidetoshi NAGAI <na...@ai.kyutech.ac.jp> wrote: