Version 2 of Simple Tkhtml web page displayer

Updated 2002-02-14 17:23:53

Purpose: to provide Neil Madden's five line Tkhtml based web page displayer.

This app fetches a web page, formats it, and displays it in a tk scrollable widget. It currently does not handle redirecting URLs, makin the web pages active, or ease of changing fonts, etc.

Perhaps some variant of this would be a useful proc for tklib.


 package require Tkhtml;package require http;pack [scrollbar .vsb \
 -orient vertical -command {.html yview}] -side right -fill y;pack \
 [html .html -bg white -yscrollcommand {.vsb set}] -fill both -expand 1
 set t [http::geturl http://mini.net/tcl/976.html];.html parse \
 [http::data $t];http::cleanup $t

NEM - Redirecting URLs aren't too hard. Perhaps there should be an option in the http package though? http::config -followredirects 1. The HTTP codes which indicate a redirect are 301 and 302, so the following should do:

 set t [http::geturl http://wiki.tcl.tk]
 while {([http::ncode $t] == 301) || ([http::ncode $t] == 302)} {
     upvar #0 $t state
     array set meta $state(meta)
     set t [http::geturl $meta(Location)]
 }

Category Application, Tkhtml, http