Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Html rendering with Tk::HyperText

by zentara (Archbishop)
on Jun 15, 2014 at 22:06 UTC ( [id://1089971]=note: print w/replies, xml ) Need Help??


in reply to Html rendering with Tk::HyperText

I found this usage right in the modules pod. It seems your insert should be a loadstring, and you may have to provide full html, not just fragments. Also your use of insert() after MainLoop is useless. Maybe you want it before MainLoop?

This works:

#!/usr/bin/perl -w use strict; use warnings; use Tk; use Tk::HyperText; my $mw = MainWindow->new ( -title => 'HTML Viewer', ); my $hypertext = $mw->Scrolled ("HyperText", -scrollbars => 'e', -wrap => 'word', )->pack (-fill => 'both', -expand => 1); my $btnInsert = $mw->Button ( -text => 'insert', -command => \&insert, )->pack (-side => 'right'); MainLoop; insert(); # this insert here will only run after # the MainLoop is done. Useless use. sub insert{ # insert some HTML code # $hypertext->insert ("end","<body bgcolor=\"black\" text=\"yellow\"> +" # . "Hello, <b>world!</b></body>"); $hypertext->loadString (qq~<html> <head> <title>Hello world!</title> </head> <body bgcolor="#0099FF"> <font size="6" family="Impact" color="#FFFFFF"> <strong>Hello, world!</strong> </font> </body> </html> ~); }

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1089971]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-04-16 05:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found