Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Hi Monks-

I have an issue that seems to work correctly under unix, but not under windows.

Specifically, it has to do with keeping selected text highlighted in a pTk Text window, even after the user clicks into an entry widget.

If you run the attached code, do the following:

  • Select some text (it should turn light green)
  • Click in the entry widget on top (does the light-green highlighting disappear? If so, this is my issue)
  • Click the bottom button (selected text should print on STDERR)

    When I do this under unix, the light-green highlighting remains, even when typing in the entry widget

    When I do this under windows, the light-green highlighting disappears as soon as I click in the entry widget. However, the text still shows up on STDERR when clicking the button.

    Why does the light-green highlighting disappear if the text is still selected? How can I fix this?



    Update: thundergnat++ for your solution.

    #!/opt/exp/bin/perl5.8 use strict; use warnings; use Tk; my $mw = new MainWindow; my $lines = "Distribution ILYAZ/os2/tk/ Distribution INGY/Kwiki-Zipcode-0.12.tar.gz Distribution ISHIGAKI/Archive-Any-Plugin-Bzip2-0.01.tar.gz Distribution JAE/perlipse/ Distribution JALYCAI/ Distribution JAME/ Distribution JBNIVOIT/ Distribution JBRYAN/ Distribution JBRYAN/ Distribution JBRYAN/ Distribution KRYDE/Filter-gunzip-4.tar.gz"; my $entry = $mw->Entry->pack; my $txt = $mw->Text(-selectbackground=>'lightgreen')->pack; my $but = $mw->Button(-text=>'List Selected to STDOUT', -command=>sub{ print STDERR $txt->getSelected,"\n"; print STDERR "HI THERE\n"; })->pack; $txt->insert('end', $lines); MainLoop;

    In reply to pTk Text Selection: Win32 Issue? by cmv

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

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    [erix]: ah! Those germans again! ... they have a lot to answer for ;-)

    How do I use this? | Other CB clients
    Other Users?
    Others studying the Monastery: (8)
    As of 2018-06-19 09:10 GMT
    Find Nodes?
      Voting Booth?
      Should cpanminus be part of the standard Perl release?

      Results (111 votes). Check out past polls.