Regarding Text Widget in Perl/Tk

Ask a Question related to PERL Beginners, Design and Development.

  1. #1

    Default Regarding Text Widget in Perl/Tk


    Hi Friends,

    I am presently working on an Automation project where I am using Active
    state perl as the programming language on windows platform. For the
    above mentioned project I am using Perl/Tk for the GUI. I created a Text
    Widget and wanted to show the output from my perl code on the text box.
    I tried tieing the STDOUT to the text box , but the output is shown only
    after the program is terminated. What ever I am printing to STDOUT is
    accumulated and shown at once after the program is terminated. I wanted
    to show them as and when the program is running. I don't know where I am
    mistaken. Please help me in this regard.

    Thanks is Advance,

    Vinesh


    Confidentiality Notice

    The information contained in this electronic message and any attachments tothis message are intended
    for the exclusive use of the addressee(s) and may contain confidential orprivileged information. If
    you are not the intended recipient, please notify the sender at Wipro [email]orMailadmin@wipro.com[/email] immediately
    and destroy all copies of this message and any attachments.
    Vinesh Varghese Guest

  2. Similar Questions and Discussions

    1. Widget system
      Hi, I am implementing a widget environment. The concept is simple : Widgets are draggables windows with unique content and can be moved and...
    2. sql mega-widget
      Hello, due to recent changes in the core Tk module, I am dropping a subroutine in my old application, and thus seeking for a "copy and paste"...
    3. Help! Has anyone made the Text Scroll bar widget work?
      When I try using my own images for drag, bar, up and down arrows, it repositions them automatically to an ugly unusable position. Any ideas? ...
    4. FileSelect widget with Tk?
      I'm writing a simple little ruby application to munge some files. I've got a command-line version that works like a charm, but I want to port it...
    5. Perl module for doing text/document comparisons?
      Hi Everyone, I've been looking for a Perl module that can be used to do document comparisons. I've done a web search and looked in my perl books,...
  3. #2

    Default Re: Regarding Text Widget in Perl/Tk

    [email]vinesh.varghese@wipro.com[/email] wrote:
    > Hi Friends,
    >
    > I am presently working on an Automation project where I am using Active
    > state perl as the programming language on windows platform. For the
    > above mentioned project I am using Perl/Tk for the GUI. I created a Text
    > Widget and wanted to show the output from my perl code on the text box.
    > I tried tieing the STDOUT to the text box , but the output is shown only
    > after the program is terminated. What ever I am printing to STDOUT is
    > accumulated and shown at once after the program is terminated. I wanted
    > to show them as and when the program is running. I don't know where I am
    > mistaken. Please help me in this regard.
    >
    > Thanks is Advance,
    >
    > Vinesh
    The text appearing in a Tk [or any other GUI library] widget
    is an attribute, generally '-text', of the
    widget. It has nothing to do with standard input/output
    communications. In order to properly manage the
    behavior of Tk widgets, you must understand the widget
    itself.

    perldoc Tk::Text
    perldoc Tk::WidgetName

    Joseph

    Hmmm--this didn't go through to the group because something
    hashed the list address. Just as well. The Tk docs are
    very poor in samples, so here is a small working example of
    loading some text to a Text widget. They are complicated
    little buggers, and if you do the lead work of reading the
    docs, I am happy to help clarify some of the questions the
    docs raise. I'm sure others will be also, but you do have
    to start by reading the docs for any Tk widget you are
    trying to use.

    my $text = '';
    open IN, "txt/txt$padded_path.txt" or die "Could not open
    $!";
    my $line;
    $text .= $line while $line = <IN>;
    close IN or die "Could not close $!";
    my $text_area = $message_area->{'SubWidget'}->{'text'};
    $text_area->delete('0.1', 'end');
    $text_area->insert('end', $text);

    The snippet above clears a text widget entirely, and loads
    it from the start--in this case, also the end, with the new
    text held in $text.


    Joseph
    R. Joseph Newton Guest

  4. #3

    Default Perl/Tk and portability

    Hi folks,

    I'm looking to write an app that I want both Linux and Windows users to be
    able to use. This app will be interactive (my train simulator/controller app
    for those who followed my previous threads) so I will need some form of user
    interface.

    As I've never looked at Tk before I would appreciate people's opinions on it.
    Specifically, how easy is it to develop, and how portable is it between the
    two platforms?

    Any comments about deploying on a Windows platform would also be appreciated
    (I want to provide it as a download, so simple install would be good).
    --
    Gary Stainburn

    This email does not contain private or confidential material as it
    may be snooped on by interested government parties for unknown
    and undisclosed purposes - Regulation of Investigatory Powers Act, 2000

    Gary Stainburn Guest

  5. #4

    Default Re: Perl/Tk and portability

    For Quality purpouses, Gary Stainburn 's mail on Friday 30 January 2004 16:26
    may have been monitored or recorded as:
    > Hi folks,
    >
    Hi Gary,
    > As I've never looked at Tk before I would appreciate people's opinions on
    > it. Specifically, how easy is it to develop, and how portable is it between
    > the two platforms?
    I havent read your privious thred, so I dont really know if this is helpful
    for you:

    most of the scripts I ever wrote that I wanted to have a GUI for were scripts
    that needed (sometimes complicated) config files.
    So what I did was writing qw/simle/ GUIs using Tk to produce these config
    files, that way keeping program logic and User Interface seperate (and easily
    exchangable). In that approach it is possible to do a little interactivity
    even when the "real" programm is running, but if you need to promt users for
    something ever second at runtime, thats probably to not a good idea.
    However, the GUIs are pretty reusable and for these simple tasks pretty easy
    to write.
    > Any comments about deploying on a Windows platform would also be
    > appreciated (I want to provide it as a download, so simple install would be
    > good). --
    The pairs of script/gui I wrote so far worked fine on SuSe Linux 8.0 up and
    Win32 (didnt try other OS).
    I once did a Win package for download using the tarma installer TI
    ([url]www.tarma.com[/url]) which installed activestateperl if required and my script/GUI
    pair - TI is freeware that produces a Win Installer for you. Worked fine.

    If you only need to do a Win GUI, look at the GUI Loft, too. ([url]www.banhof.se/[/url]
    ~johanl/perl/Loft/)
    Thats a WYSIWYG GUI design tool, pretty delphi like, except that it doesent
    produce code but a design file which you can work with in you app, so you can
    click your GUI together and focus on the logic. Neat thing.

    As Joseph was pointing out, examples in the Tk docu are an endangerd species:
    Mastering Perl/Tk by Steve Lidie and Nacy Walsh is an extended zoo of these.

    Enjoy clicking around, Wolf

    Wolf Blaum Guest

  6. #5

    Default Re: Regarding Text Widget in Perl/Tk

    For Quality purpouses, zentara 's mail on Friday 30 January 2004 16:22 may
    have been monitored or recorded as:

    Hi,

    neat trick! Great.
    However, I have a, well, couriosity?

    My script looks pretty much the same, except the print in &dosomething
    (since it is acctually your script:-))
    > Here is a set of programs, that do what you want.
    > ################################################## ####
    > #!/usr/bin/perl -w
    > use strict;
    > use Tk;
    > my $mw = new MainWindow;
    >
    > my $listbox = $mw->Scrolled("Listbox", -scrollbars => "osoe",
    > -height => 5,
    > -selectmode => "multiple")
    > ->pack(-side => "left");
    >
    > my $start = $mw->Button( -text => 'Start', -command => \&start )->pack;
    > $mw->Button( -text => 'Exit', -command => \&exit )->pack;
    >
    >
    > #start external command to pipe
    > sub start {
    > $start->configure(-state => 'disabled');
    > open(C, "./read-own-stdout-piper 2>&1 |") or warn $!;
    > $mw->fileevent( \*C, 'readable', \&doSomething );
    >
    > }
    >
    > sub doSomething {
    > if ( eof(C) ) { # Child closed pipe
    > close(C); # Close parent's part of pipe,
    > # filevent is cancelled as well
    > wait; # Avoid zombies
    > return;
    > }
    > my $text = <C>; # Get text from child and put it into listbox
    > print $text; #only diffeerence.
    chomp($text);
    > $listbox->insert( 'end', 'Got: ' . $text );
    > $listbox->see('end');
    > }
    >
    > MainLoop;
    >
    > __END__
    > ##############################################

    and the called script looks different (but prints to STDOUT and has a $|++ for
    flush.

    When I call the GUI from a command prompt opend under X I should see two
    parallel outputs, one in the terminal and one in the listbox, right.

    I do see these outputs on both, but the one in the listbox is way slower than
    the one to the console. However, the relation seams to be random (ie there is
    no, say constant 5 line adtvantage).
    I also tried the
    tie @array, "Tk::Listbox", $listbox in &start and only call
    $listbox->see('end') in &dosomething with the result, that I get to see the
    whole output in the listbox at once and only when the callled script is
    finished.

    Any Idea?

    Thanks a lot,
    Wolf

    Wolf Blaum Guest

  7. #6

    Default Re: Regarding Text Widget in Perl/Tk

    zentara wrote:
    > Try putting a "TK::after in the event loop to set the timing.
    Yee-haw!! Just what I was looking for! Thanks. Serendipity is a wonderful thing.

    Joseph

    R. Joseph Newton Guest

  8. #7

    Default Re: Regarding Text Widget in Perl/Tk

    For Quality purpouses, zentara 's mail on Saturday 31 January 2004 17:23 may
    have been monitored or recorded as:
    >
    > It's hard to say without showing us your script.
    well, the called script (not the gui) is bout 500 lines...
    > Try putting a "TK::after in the event loop to set the timing.
    That works: no clue why, bu a great tip. Thanks.

    Wolf

    Wolf Blaum Guest

  9. #8

    Default Re: Regarding Text Widget in Perl/Tk


    I tried to send off-list, but the e-mail address did not
    work, so I'm posting to the list:



    Hey, I was very impressed when this script you provided
    ran for me. All I did is run the first script and it
    creates the box nicely.

    I don't know much about spawning child processes. I'm
    on vacation and much of my Perl documentation is at
    home.

    I was wondering if you could help me get this script
    tied to one of my Perl programs on my Win2000 box.
    After much experimentation, I've changed the line
    open(C, "./read-own-stdout-piper 2>&1 |") or warn $!;
    to
    open(C, "round2.bat 2>&1 |") or warn $!;

    round2.bat is a DOS batch file with a single line:
    perl round2.pl # (that is the way I run perl programs)

    round2.pl has:

    use strict;
    use warnings;
    my $number = 5.6278;
    my $rounded = sprintf '%.2f', $number;
    print "$rounded\n";
    $|++; # << SHOULD THIS LINE BE HERE?

    AND IT ALL WORKS!


    I can't just do
    open(C, "round2.pl 2>&1 |") or warn $!;
    because then it just opens round2.pl in my text editor,
    since that is the association I have ".pl" set to. I tried
    open(C, "'perl round2.pl' 2>&1 |") or warn $!;
    but that didn't work either.

    That "Got:" prompt isn't too cool, but I'm sure I'll
    learn how to turn that off later.

    Also, it's unfortunate that copy and paste don't work
    in that TK box.

    Anyway, thanks a bunch. If there are other posts
    on the NG related to this, I'll see them when I get
    home.


    Mike Flannigan
    Houston, TX


    _______________________________________


    Subject: Re: Regarding Text Widget in Perl/Tk
    Date: Fri, 30 Jan 2004 10:22:24 -0500
    From: zentara <zentara@highstream.net>
    To: [email]beginners@perl.org[/email]


    On Thu, 29 Jan 2004 20:01:10 +0530, [email]vinesh.varghese@wipro.com[/email] (Vinesh
    Varghese) wrote:
    >I am presently working on an Automation project where I am using Active
    >state perl as the programming language on windows platform. For the
    >above mentioned project I am using Perl/Tk for the GUI. I created a
    Text
    >Widget and wanted to show the output from my perl code on the text
    box.
    >I tried tieing the STDOUT to the text box , but the output is shown
    only
    >after the program is terminated. What ever I am printing to STDOUT is
    >accumulated and shown at once after the program is terminated. I wanted
    >to show them as and when the program is running. I don't know where I
    am
    >mistaken. Please help me in this regard.
    Since you don't show your code, it's hard to say what your problem is.

    Here is a set of programs, that do what you want.
    ################################################## ####
    #!/usr/bin/perl -w
    use strict;
    use Tk;
    my $mw = new MainWindow;

    my $listbox = $mw->Scrolled("Listbox", -scrollbars => "osoe",
    -height => 5,
    -selectmode => "multiple")
    ->pack(-side => "left");

    my $start = $mw->Button( -text => 'Start', -command => \&start )->pack;
    $mw->Button( -text => 'Exit', -command => \&exit )->pack;


    #start external command to pipe
    sub start {
    $start->configure(-state => 'disabled');
    open(C, "./read-own-stdout-piper 2>&1 |") or warn $!;
    $mw->fileevent( \*C, 'readable', \&doSomething );

    }

    sub doSomething {
    if ( eof(C) ) { # Child closed pipe
    close(C); # Close parent's part of pipe,
    # filevent is cancelled as well
    wait; # Avoid zombies
    return;
    }
    my $text = <C>; # Get text from child and put it into listbox
    chomp($text);
    $listbox->insert( 'end', 'Got: ' . $text );
    $listbox->see('end');
    }

    MainLoop;

    __END__
    ##############################################
    #and here is read-own-stdout-piper

    #!/usr/bin/perl
    $|++;
    for my $i ( 0 .. 10) {
    print $i, "\n";
    sleep 1;
    }
    __END__
    ############################################


    Mike Flannigan Guest

  10. #9

    Default Re: Regarding Text Widget in Perl/Tk

    Mike Flannigan wrote:
    > I was wondering if you could help me get this script
    > tied to one of my Perl programs on my Win2000 box.
    > After much experimentation, I've changed the line
    > open(C, "./read-own-stdout-piper 2>&1 |") or warn $!;
    > to
    > open(C, "round2.bat 2>&1 |") or warn $!;
    >
    > round2.bat is a DOS batch file with a single line:
    > perl round2.pl # (that is the way I run perl programs)
    >
    > round2.pl has:
    >
    > use strict;
    > use warnings;
    > my $number = 5.6278;
    > my $rounded = sprintf '%.2f', $number;
    > print "$rounded\n";
    > $|++; # << SHOULD THIS LINE BE HERE?
    >
    > AND IT ALL WORKS!
    >
    > I can't just do
    > open(C, "round2.pl 2>&1 |") or warn $!;
    > because then it just opens round2.pl in my text editor,
    > since that is the association I have ".pl" set to.
    Why?!?! Why screw with something that works, unscrewed with, just fine? The
    asscociations set up
    by the ActivePerl install are the appropriate ones for making Perl run. If you
    want associations to your
    preferred editor, then:
    Open Windows Explorer, or the abonminable kindergarten version My Computer
    Click Folder Options on the Tools menu
    Select File types
    Find the PL extension.
    Click the Advanced button.
    Restore the Open association with the perl executable. The Open action should
    read:

    "C:\Perl\bin\perl.exe" "%1" %*

    presuming that Perl is installed to the default location for Windows

    Create an Edit action tied to your editor.

    Changing the primary association is a bad hack, and a bad habit to be in as you
    start learning a programming
    language.

    Actually, once you right-click on any registered file type in Win2K, and use the
    Open with... option option to
    select an alternate handler, that handler will thereafter be available on a list
    under the Open with menu item.

    In brief, there is no good reason to mess with a working file association
    > I tried
    > open(C, "'perl round2.pl' 2>&1 |") or warn $!;
    > but that didn't work either.
    open(C, "perl round2.pl 2>&1 |") or warn $!;
    or simply:
    open(CHILD, "perl round2.pl | ") or warn "Could not open pipe from child
    process: $!";
    >
    > That "Got:" prompt isn't too cool, but I'm sure I'll
    > learn how to turn that off later.
    >
    > Also, it's unfortunate that copy and paste don't work
    > in that TK box.
    If it is a Text widget, copy and paste will indeed work. Can you provide more
    detail on
    why you think it doesn't?
    > Anyway, thanks a bunch. If there are other posts
    > on the NG related to this, I'll see them when I get
    > home.
    >
    > Mike Flannigan
    > Houston, TX
    Mike, I think you have a conceptual problem here. Seeking STDIN from a GUI
    widget, hacking
    and breaking working file associations, etc. indicate a bad habit that will
    hobble your programming
    efforts if unaddressed. *Let working systems be*, don't fix what ain't broke.

    Joseph

    R. Joseph Newton Guest

  11. #10

    Default Re: Regarding Text Widget in Perl/Tk


    > > I was wondering if you could help me get this script
    > > tied to one of my Perl programs on my Win2000 box.
    > > After much experimentation, I've changed the line
    > > open(C, "./read-own-stdout-piper 2>&1 |") or warn $!;
    > > to
    > > open(C, "round2.bat 2>&1 |") or warn $!;
    > >
    > > round2.bat is a DOS batch file with a single line:
    > > perl round2.pl # (that is the way I run perl programs)
    > >
    > > round2.pl has:
    > >
    > > use strict;
    > > use warnings;
    > > my $number = 5.6278;
    > > my $rounded = sprintf '%.2f', $number;
    > > print "$rounded\n";
    > > $|++; # << SHOULD THIS LINE BE HERE?
    > >
    > > AND IT ALL WORKS!
    > >
    > > I can't just do
    > > open(C, "round2.pl 2>&1 |") or warn $!;
    > > because then it just opens round2.pl in my text editor,
    >
    > > since that is the association I have ".pl" set to.
    >
    > Why?!?! Why screw with something that works, unscrewed with, just fine? The
    > asscociations set up
    > by the ActivePerl install are the appropriate ones for making Perl run.
    Thanks for the response. Remember, I am using Windows on
    this box. As others have recently pointed out, I need to run
    Perl in a command prompt anyway, so it behooves me to
    associate ".pl" with my text editor and not the Perl
    executable.

    > If you
    > want associations to your
    > preferred editor, then:
    > Open Windows Explorer, or the abonminable kindergarten version My Computer
    > Click Folder Options on the Tools menu
    > Select File types
    > Find the PL extension.
    > Click the Advanced button.
    > Restore the Open association with the perl executable. The Open action should
    > read:
    >
    > "C:\Perl\bin\perl.exe" "%1" %*
    >
    > presuming that Perl is installed to the default location for Windows
    >
    > Create an Edit action tied to your editor.
    I don't know what an "Edit action" is, but I am looking
    into it.

    >
    > Changing the primary association is a bad hack, and a bad habit to be in as you
    > start learning a programming
    > language.
    >
    > Actually, once you right-click on any registered file type in Win2K, and use the
    > Open with... option option to
    > select an alternate handler, that handler will thereafter be available on a list
    > under the Open with menu item.
    >
    > In brief, there is no good reason to mess with a working file association
    >
    > > I tried
    > > open(C, "'perl round2.pl' 2>&1 |") or warn $!;
    > > but that didn't work either.
    >
    > open(C, "perl round2.pl 2>&1 |") or warn $!;
    I thought I tried that, but apparently not, because it
    works perfectly. Not too smart on my part.

    > or simply:
    > open(CHILD, "perl round2.pl | ") or warn "Could not open pipe from child
    > process: $!";
    >
    > >
    > > That "Got:" prompt isn't too cool, but I'm sure I'll
    > > learn how to turn that off later.
    > >
    > > Also, it's unfortunate that copy and paste don't work
    > > in that TK box.
    >
    > If it is a Text widget, copy and paste will indeed work. Can you provide more
    > detail on
    > why you think it doesn't?
    I changed round2.pl to include "print "Hello World\n";"

    Now it's the nice, pretty Tk box with "Got: 5.63" on the
    first line and "Got: Hello World" on the 2nd line. Clicking
    on each line alternately highlights the entire line or
    unhighlights the entire line with a dark blue line. You
    can have both lines highlighted if you like.

    In any case, hitting ctrl C does not copy anything to the
    clipboard, and you cannot highlight just part of a line
    of text.


    > > Anyway, thanks a bunch. If there are other posts
    > > on the NG related to this, I'll see them when I get
    > > home.
    > >
    > > Mike Flannigan
    > > Houston, TX
    >
    > Mike, I think you have a conceptual problem here.
    Yeah, my main problem is I'm using Windows. I've been
    trying to get a Linux box set up for quite some time now,
    but it looks like it's going to be quite a bit longer before I
    have it running.

    > Seeking STDIN from a GUI
    > widget,
    Yeah, I thought you could do that. I need to study TK quite
    a bit.

    > hacking
    > and breaking working file associations, etc. indicate a bad habit that will
    > hobble your programming
    > efforts if unaddressed. *Let working systems be*, don't fix what ain't broke.
    >
    > Joseph
    Mike Flannigan Guest

  12. #11

    Default Re: Regarding Text Widget in Perl/Tk

    Mike Flannigan wrote:
    > In any case, hitting ctrl C does not copy anything to the
    > clipboard, and you cannot highlight just part of a line
    > of text.
    Ah, but right clicking on the Text widget will--unless you have hacked the selection
    activities.
    If so, well--*Don't do that*--at least not until you have checked the unhacked
    functionality of the widget. Tk::Text widgets have built-in copy-and-paste
    functionality. If you manipualte the selection variables, though, you may be
    generating side effects that disable this functionality.

    Okay. I just checked it out. I brought up a project containing a Tk::Text widget,
    whose editing functions I had done nothing with. Highlighted one phrase,
    right-clicked and selected Copy. Pasted to Notepad from the clipboard, and got the
    same phrase. Then I went down a line or two, selected another passage, used Ctl-c to
    copied, and again the pasted text showed a successful copy.

    I think something is going wrong with your highlighting routine. Or perhaps this is
    ot a Text widget? If left alone, the Text widget will offer full copy-and-paste
    functionality.
    > > Houston, TX
    > >
    > > Mike, I think you have a conceptual problem here.
    >
    > Yeah, my main problem is I'm using Windows.
    Nope. Windows certainly has its share of shortcomings, but they really don't seem to
    bear on the issues you are presenting. The habit of low-level hacking will get you in
    even more trouble on Linux.
    > I've been
    > trying to get a Linux box set up for quite some time now,
    > but it looks like it's going to be quite a bit longer before I
    > have it running.
    >
    > > Seeking STDIN from a GUI
    > > widget,
    >
    > Yeah, I thought you could do that. I need to study TK quite
    > a bit.
    Yes. Tk is a complex, diverse, and somewhat uneven libary. It is really a ood idea
    to read the documentation on each widget you use. Each widget has its own
    characteristics and behaviorSome of them are pretty obvious, some are more subtle.

    So I will reiterate:
    > > hacking
    > > and breaking working file associations, etc. indicate a bad habit that will
    > > hobble your programming
    > > efforts if unaddressed. *Let working systems be*, don't fix what ain't broke.
    Joseph

    R. Joseph Newton Guest

  13. #12

    Default Re: Regarding Text Widget in Perl/Tk


    If I right click on the title bar, it gives "move", "size",
    "minimize", "maximize", "close". If I right click anywhere else,
    it doesn't do anything - produces no box. I don't recall
    hacking anything to do with that, but perhaps I did.


    Mike

    > Ah, but right clicking on the Text widget will--unless you have hacked the selection
    > activities.
    > If so, well--*Don't do that*--at least not until you have checked the unhacked
    > functionality of the widget. Tk::Text widgets have built-in copy-and-paste
    > functionality. If you manipualte the selection variables, though, you may be
    > generating side effects that disable this functionality.
    >
    > Okay. I just checked it out. I brought up a project containing a Tk::Text widget,
    > whose editing functions I had done nothing with. Highlighted one phrase,
    > right-clicked and selected Copy. Pasted to Notepad from the clipboard, and got the
    > same phrase. Then I went down a line or two, selected another passage, used Ctl-c to
    > copied, and again the pasted text showed a successful copy.
    >
    > I think something is going wrong with your highlighting routine. Or perhaps this is
    > ot a Text widget? If left alone, the Text widget will offer full copy-and-paste
    > functionality.
    >
    Mike Flannigan Guest

  14. #13

    Default Re: Regarding Text Widget in Perl/Tk

    Mike Flannigan wrote:
    > I> I think something is going wrong with your highlighting routine. Or perhaps this is
    > > ot a Text widget? If left alone, the Text widget will offer full copy-and-paste
    > > functionality.
    > >
    >
    > f I right click on the title bar, it gives "move", "size",
    > "minimize", "maximize", "close". If I right click anywhere else,
    > it doesn't do anything - produces no box. I don't recall
    > hacking anything to do with that, but perhaps I did.
    >
    > Mike
    Mike,

    That is because you are mixing threads. You pggybacked your issue on a thread initiated by
    Vinesh Vargese, concerning the Tk::Text widget, as specified in the title bar. The sample
    code you tried had do with getting standard output redirected to a Tk widget, though
    Zentara chose a Listbox rather than a Text widget to display the text. The Listbox widget
    does not have built-in copy-and-paste functionality. Such functionality would be much more
    dificult to define in a generic sense for a listbox.

    This is actualy the question I posed at the end of my post. I corrected your top-posting
    above so you could see in context. No, this is not a Text widget. I think this is by
    design. Zentara provided sample code to demonstrate the difference between Tk display text
    and standard output. I don't think he had any intention of handing anyone a completed
    assignment.

    A simpler example, which does not deal with the original question, but which does show the
    functionality you are interested in:

    Greetings! E:\d_drive\perlStuff>perl -w
    use Tk;

    my $win = MainWindow->new(-title => 'This Text Copies Right');
    my $text = $win->Text->pack(-expand => 'both');
    MainLoop;
    ^Z

    Joseph



    R. Joseph Newton Guest

  15. #14

    Default Re: Regarding Text Widget in Perl/Tk


    Ahhh. Not comparing apples to apples. That does make
    a difference.

    I need to get me a good Tk book and learn it proper, heh?


    Mike

    > Mike,
    >
    > That is because you are mixing threads. You pggybacked your issue on a thread initiated by
    > Vinesh Vargese, concerning the Tk::Text widget, as specified in the title bar. The sample
    > code you tried had do with getting standard output redirected to a Tk widget, though
    > Zentara chose a Listbox rather than a Text widget to display the text. The Listbox widget
    > does not have built-in copy-and-paste functionality. Such functionality would be much more
    > dificult to define in a generic sense for a listbox.
    >
    > This is actualy the question I posed at the end of my post. I corrected your top-posting
    > above so you could see in context. No, this is not a Text widget. I think this is by
    > design. Zentara provided sample code to demonstrate the difference between Tk display text
    > and standard output. I don't think he had any intention of handing anyone a completed
    > assignment.
    >
    > A simpler example, which does not deal with the original question, but which does show the
    > functionality you are interested in:
    >
    > Greetings! E:\d_drive\perlStuff>perl -w
    > use Tk;
    >
    > my $win = MainWindow->new(-title => 'This Text Copies Right');
    > my $text = $win->Text->pack(-expand => 'both');
    > MainLoop;
    > ^Z
    >
    > Joseph
    Mike Flannigan Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139