Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Take a look at the text_demo script that comes with Tk800.023 ...
#!/usr/bin/perl -w use Tk; require Tk::Text; my $top = MainWindow->new; $top->option('add','*Text.background'=>'white'); my $t = $top->Scrolled('Text',"-relief" => "raised", "-bd" => "2", "-setgrid" => "true"); my $m = $t->Menu(); $m->add("command", "-label" => "Open", "-underline" => 0, "-command" => \&sayopen); $m->add("command", "-label" => "Close", "-underline" => 0, "-command" => \&sayclose); $m->add("separator"); $m->add("command", "-label" => "Selection", "-underline" => 0, "-command" => \&showsel); $m->add("separator"); $m->add("command", "-label" => "Exit", "-underline" => 1, "-command" => \&doexit); $t->pack(-expand => 1, "-fill" => "both"); $t->tag("configure", "underline","-underline","on"); $t->insert("0.0", "This window is a text widget. It displays one or m +ore lines of text and allows you to edit the text. Here is a summary of the things you can do to a text widget: 1. Insert text. Press mouse button 1 to set the insertion cursor, then type text. What you type will be added to the widget. You can backsp +ace over what you've typed using either the backspace key, the delete key, or Control+h. 2. Resize the window. This widget has been configured with the \"setG +rid\" option on, so that if you resize the window it will always resize to a +n even number of characters high and wide. Also, if you make the window narrow you can see that long lines automatically wrap around onto additional lines so that all the information is always visible. 3. Scanning. Press mouse button 2 in the text window and drag up or do +wn. This will drag the text at high speed to allow you to scan its content +s. 4. Select. Press mouse button 1 and drag to select a range of characte +rs. Once you've released the button, you can adjust the selection by press +ing button 1 with the shift key down. This will reset the end of the selection nearest the mouse cursor and you can drag that end of the selection by dragging the mouse before releasing the mouse button. You can double-click to select whole words, or triple-click to select whole lines. 5. Delete. To delete text, select the characters you'd like to delete and type Control+d. 6. Copy the selection. To copy the selection either from this window or from any other window or application, select what you want, click button 1 to set the insertion cursor, then type Control+v to copy the selection to the point of the insertion cursor. You can also bind commands to tags. Like press button 3 for menu "); &insertwtag($t,"here","underline"); $t->tag("bind","underline","<3>", [sub { shift; shift->Post(@_)},$m,Ev +(X),Ev(Y)] ); $t->bind("<Any-Enter>", sub { $t->focus }); $t->Subwidget('text')->OnDestroy(sub { print "Destroyed!\n"; print $t- +>get('1.0','end') }); Tk::MainLoop; sub insertwtag { local($w,$text,$tag) = @_; my $start = $w->index("insert"); print "start=$start\n"; $w->insert("insert",$text); $w->tag("add",$tag,$start,"insert"); } sub sayopen { print "Open something\n" } sub sayclose { print "Close something\n" } sub showsel { my @info = $t->tagRanges('sel'); if (@info) { print "start=$info[0] end=$info[1]\n" } } sub doexit { die "'die' no longer exits" }

In reply to Re: Regular Expression GUI? by rbc
in thread Regular Expression GUI? by major tom

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 exploiting the Monastery: (6)
As of 2024-04-19 11:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found