Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Below is a snippit of code I found to display text in a Tk Window.
sub show_instr { my $mw = shift; my $tl = $mw->Toplevel(-title => 'TkSolitaire Instructions'); my $text = $tl->Scrolled('ROText', -scrollbars => 'e', -wrap => 'word', -width => 80, -height => 32, -font => $FONT, -setgrid => 1, )->pack(-expand => 1, -fill => 'both'); $text->tagConfigure('title', -font => '-*-Helvetica-Bold-R-Normal--*-190-*-*-*-*-*-*', ); # separate paragraphs with two newlines my $instr = <<'EOInstr'; This program is free software. You may distribute or modify it under the terms of the Artistic license that is distributed with the Perl Kit. The card images in the cards directory came from <URL:http://www.waste.org/~oxymoron/cards/> and are distributed under the terms of the GPL. The object of the game is to pick up all the cards. You start with yo +ur base card (centered at the bottom). You may pick up (by clicking) any uncovered card whose denomination is one away from the base card's denomination (the ace is adjacent to both the king and the deuce). Su +it does not matter. Attempting to illegally pick up a card (if the card +is covered or if the card's denomination is not adjacent to the base card +'s denomination) will result in a terminal bell. Once you pick up a card +, it becomes the new base card. If you there are no more cards to pick up, click the base card. This +is equivalent to pulling the next card from the bottom of the pile. When the pile is exhausted, a card will be placed face down at the base. T +he game is over when no more cards are left in the field or when the base is exhausted and no legal moves remain. There is an undo option that lets you undo your last pickup. You can' +t undo once you've flipped the next base card because that would give an unfair advantage. My good friends Susan, Sarah and Mackenzie taught me how to play this game. I instantly loved it. Thanks for all the fun guys! When I relized my mom would soon be 29 and holding (again), I decided +that I'd let Tk and Fisher-Yates do the layout and shuffling so she (my mom +) could try her hand at this version of Solitaire. Happy 29th Birthday Mom! :) EOInstr chomp $instr; # make the paragraphs into one long line $instr =~ s/\n(?!\n)/ /g; $text->insert('end', "TkSolitaire Instructions\n", 'title'); $text->insert('end', $instr); }

if I wanted the window body to be the contents of a text file what would I need to do? Sorry, for such a dumb question but I cant figure this out.

Edit Masem 2001-07-31 - Title change from "Tk perl"


In reply to Displaying text file with perl/tk by akm2

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
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: (3)
As of 2024-04-24 22:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found