From orangensaftx@web.de Thu Jan 7 02:00:59 2016 Return-Path: X-Original-To: gtk-perl-list@gnome.org Delivered-To: gtk-perl-list@gnome.org Received: from localhost (localhost.localdomain [127.0.0.1]) by restaurant.gnome.org (Postfix) with ESMTP id 2288B762AD for ; Thu, 7 Jan 2016 02:00:59 +0000 (UTC) X-Virus-Scanned: by amavisd-new at gnome.org X-Spam-Flag: NO X-Spam-Score: -0.877 X-Spam-Level: X-Spam-Status: No, score=-0.877 tagged_above=-999 required=2 tests=[BAYES_00=-1.9, FREEMAIL_FROM=0.001, FREEMAIL_REPLY=1, HTML_MESSAGE=0.001, MIME_HTML_ONLY=0.723, RCVD_IN_DNSWL_LOW=-0.7, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001] autolearn=no Received: from restaurant.gnome.org ([127.0.0.1]) by localhost (restaurant.gnome.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id L8mT7rFreMf3 for ; Thu, 7 Jan 2016 02:00:57 +0000 (UTC) Received: from mout.web.de (mout.web.de [212.227.15.4]) by restaurant.gnome.org (Postfix) with ESMTP id BF59F76290 for ; Thu, 7 Jan 2016 02:00:56 +0000 (UTC) Received: from [217.84.101.239] by 3capp-webde-bs55.server.lan (via HTTP); Thu, 7 Jan 2016 03:00:56 +0100 MIME-Version: 1.0 Message-ID: From: orangensaftx@web.de To: gtk-perl-list@gnome.org Subject: Aw: RE: EXTERNAL: stdout/sterr to GtkTextView at runtime Content-Type: text/html; charset=UTF-8 Date: Thu, 7 Jan 2016 03:00:56 +0100 Importance: normal Sensitivity: Normal In-Reply-To: References: , X-UI-Message-Type: mail X-Priority: 3 X-Provags-ID: V03:K0:6OeKRwN9KM6G88ZX6M/t6nhZp+HeVBDpBTwQAQCsTj5 O6zca70A3t6oGxqO9WMdnbGRn/kTS4b4ciXSFRof+/Dz+rkRWr zVn5JbHhbp1i2nP475fE42IOg03v3NjX/cfdcbwXJTNMe8f/iE mMsOjomz6z1K9oOXar2GN+VMFhMAIdGdYxWHZJrpuqhAm3jYHK zCwbBzVT4C0R/x6hhZ+2njSvWhHMPdNcOGROmTaGcaELcJajM2 jchYgwJUq73AX6hqOUNZa9v9G1NCdo4ad1dqUxXAe+AXfO2jNX PlNTbs= X-UI-Out-Filterresults: notjunk:1;V01:K0:2Z2wv7/WbgQ=:KUtsNnH8d9MCh+APYm1hyw klhJzRrHgmYGd1sQgI7twMN0vcS+befAlMDzYoRmc51KpaBdbkaxB5gzcfx+e9rqWsZ4B+Skg h1ONdP1UP4GhiZI9CEk+nCHyr1e1DeH5HfpvpyVgo06lkID5Qcg7mXAgVbtbkZccMESDjqDhb ICgneKgRaCIeC6a3vdXfoG30cR+h6vtZo50x6JpAoz2EYdHhelhMqGdxJq7Q2K22TuPNQlTtW 5nC3P57lGXo3P6vngSUXICU8naLskBt4w7kwDtOs3gY9NV0MKq5ufmLSC5b26XL0dl3bZh8Fz HC2LcybeCe6GV0Ltwct6IXDu9fTBuIz44CVPljuJk2n7a8zNXSGN5GRNCxiFp01IxXEjHirub gkAGXxmrZBrUYWm2U/XJpFk9UXl3K1pKHdnjDZ/oQFwggwCKtTpjUZks/JTQ+FulDdDKnwLfB cjHFUvKrbw== X-BeenThere: gtk-perl-list@gnome.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Using GTK+ with Perl List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Jan 2016 02:00:59 -0000
Thank you very much! It works now. :) You were all a great help.
 
Happy New Year.
orangensaft
 
Gesendet: Montag, 21. Dezember 2015 um 18:44 Uhr
Von: "Williams, James P2" <james.p2.williams@lmco.com>
An: "'orangensaftx@web.de'" <orangensaftx@web.de>, "'gtk-perl-list@gnome.org'" <gtk-perl-list@gnome.org>
Betreff: RE: EXTERNAL: stdout/sterr to GtkTextView at runtime

Yeah, buffering can be a sticky issue.  At a minimum, the sender needs to turn it off.  In your test_output.pl, you should do something like this on the file handle to which you’re writing,

 

   use IO::Handle;

   $fh->autoflush(TRUE);

 

which you might see done this way,

 

   $fhPrev=select($fh);

   $|=TRUE;

   select($fhPrev);

 

or with an older idiom for maximum compactness/obfuscation,

 

   select((select($fh),$|=TRUE)[0]);

 

or with an I/O layer.

 

   binmode($fh,”:unix”) or die “Unable to binmode: $!.\n”;

 

Good luck.

 

Jim

 

From: Williams, James P2 (US)
Sent: Friday, December 11, 2015 11:38 AM
To: 'orangensaftx@web.de' <orangensaftx@web.de>; 'gtk-perl-list@gnome.org' <gtk-perl-list@gnome.org>
Subject: RE: EXTERNAL: stdout/sterr to GtkTextView at runtime

 

One way to deal with this is to open a pipe to the program instead of using backticks.

 

   use Glib qw(TRUE FALSE);

   use IO::File;

 

   ...

 

   my($cmd)=”/usr/bin/perl test_output.pl”;

   my($fh)=new IO::File(“$cmd 2>&1 |”);

   die “$0: Unable to open pipe from $cmd: $!.\n” if !$fh;

 

Then, add a function to be called when input is available on that file handle.

 

   my($io)=Glib::IO->add_watch($fh->fileno(),[qw(in hup)],sub {ioCB($fh,$cmd,@_)});

 

where the callback would read the file handle, and append what it gets to your widget.

 

   sub ioCB

   {

      my($fh,$cmd,$fd,$cond)=@_;

      my(@lines,$done);

 

 

      if ($cond & ‘hup’) {

         @lines=$fh->getlines();

         $done=TRUE;

      } elsif ($cond & ‘in’) {

         @lines=($fh->getline());  #read only one line; may block if we try more

      }

 

      if (@lines) {

         ...

         $buf->insert($buf->get_end_iter(),join ‘’,@lines);

         ...

      }

 

      if ($done && !$fh->close()) {

         showError($!

            ? “Unable to close pipe to $cmd: $!.”

            : “Got non-zero exit status from $cmd, $?.”);

      }

 

      return !$done;                       #i.e., keep IO channel if not at EOF

   }

 

$io in the earlier code can be used to remove the callback later, or you can just return FALSE from the callback, as I do above.  You can get more details in the Glib::MainLoop docs and those for the C bindings that module wraps.

 

Another way to deal with this is to do blocking reads in a separate thread, but if your Perl skills are weak, I’d go with this simpler IO channel approach.

 

Good luck.

 

Jim

 

From: gtk-perl-list [mailto:gtk-perl-list-bounces@gnome.org] On Behalf Of orangensaftx@web.de
Sent: Thursday, December 10, 2015 11:14 PM
To: gtk-perl-list@gnome.org
Subject: EXTERNAL: stdout/sterr to GtkTextView at runtime

 

Hi,

 

I'm writing a gui for an existing program that can run for a while. I want to display all possible terminal output of this program in a GtkTextView. So far i failed to display the output at runtime. I tried this

 

my $iter = $textbuffer->get_end_iter;

my $command = `perl test_output.pl 2>&1`;

$textbuffer->insert($iter, $command);

 

which isn't working the way i want. My program is blocked while test_output.pl is running. I tried to use

 

my $command = system("perl test_output.pl 2>&1 &");

 

instead but while my program keeps running, all output is shown in the terminal again.

 

 

How can i achieve to get all output at runtime in my textview? And how do i check if test_output is done running? I found an old solution using Gtk+ itself but my perl skills aren't good enough to reproduce this:

 

 

I'm using Gtk3.

 

 

Thanks for any help.

From brian@xaoc.org Fri Jan 8 16:52:58 2016 Return-Path: X-Original-To: gtk-perl-list@gnome.org Delivered-To: gtk-perl-list@gnome.org Received: from localhost (localhost.localdomain [127.0.0.1]) by restaurant.gnome.org (Postfix) with ESMTP id 6B2B5765AC for ; Fri, 8 Jan 2016 16:52:58 +0000 (UTC) X-Virus-Scanned: by amavisd-new at gnome.org X-Spam-Flag: NO X-Spam-Score: -2.7 X-Spam-Level: X-Spam-Status: No, score=-2.7 tagged_above=-999 required=2 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_LOW=-0.7] autolearn=ham Received: from restaurant.gnome.org ([127.0.0.1]) by localhost (restaurant.gnome.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fNC3JJdqG08O for ; Fri, 8 Jan 2016 16:52:56 +0000 (UTC) Received: from mail-yk0-f177.google.com (mail-yk0-f177.google.com [209.85.160.177]) by restaurant.gnome.org (Postfix) with ESMTP id CC81376908 for ; Fri, 8 Jan 2016 16:52:56 +0000 (UTC) Received: by mail-yk0-f177.google.com with SMTP id x67so368699258ykd.2 for ; Fri, 08 Jan 2016 08:52:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xaoc.org; s=google; h=mime-version:sender:date:message-id:subject:from:to:content-type; bh=QZeBm+E90GyPC35omSmxG9dKkGmC3mZb0ekQ7aTTa9M=; b=Dcv8T3yRr2ulm5CxKp13QCULSx/OfR7uGSu6joMK/jrbWaz+c2Oym77D/4tjKgtSvu U1r91IlCsuqKXjKf6Axv0lL4QiVoojN+undBf3bMmoMZNDGXMHkexXE1eY+bnLo7l1ln 3wwxEX4R7j1Pf4WQo1h6CCa2Ru6YNBQMiCdNk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:date:message-id:subject:from :to:content-type; bh=QZeBm+E90GyPC35omSmxG9dKkGmC3mZb0ekQ7aTTa9M=; b=HtLDIo7tO9bTqaLZ6wZ00B6zcoJ9W6ckXHqP5dGq9/eUam4MkEJ3oJL+g4SiA5PFIg 0kaY1Eq2TneHiGlU+dPOAHGQ0sfD3fYyRVbmPNanbHswgx+Dft5mKaW1F5ZBTv/aUbCw sXYqlWFDR95hhwFNl2IybQZw0B5vuOHptTsEhjcf5oYVClmQu5EdH3HHk7Q/uBAj6PZT IH/DkXEvbUthqzqG27yk5gM1F5olvDLu79QqgFMlywgNuuTnF+5PPwwmTAIalu0R+RMu d7+8VjTPDNqVM6IKZkdTDWcyLyjwIIKuHlkAot5Ag/Yv4MSGDtCii0+wo1I4c+pBGuqY lDwQ== X-Gm-Message-State: ALoCoQmL57DNyQ3PRFIwgKwDD8Uhb6P5NduhHkPcWExFtAy1O3e72kk/HFbHbm1RY+nl8IeaKZ+nwsm7HdMZ6TKMvU5iWYAzxw== MIME-Version: 1.0 X-Received: by 10.129.155.198 with SMTP id s189mr76592649ywg.316.1452271978270; Fri, 08 Jan 2016 08:52:58 -0800 (PST) Sender: brian@xaoc.org Received: by 10.37.12.2 with HTTP; Fri, 8 Jan 2016 08:52:58 -0800 (PST) X-Originating-IP: [208.54.4.181] Date: Fri, 8 Jan 2016 08:52:58 -0800 X-Google-Sender-Auth: YtMRPsqiMiO0gajdcJ_-lys86TU Message-ID: Subject: Next release deadline: Saturday, January 23rd 2016 at 00:01 UTC From: Brian Manning To: GTK-Perl List Content-Type: text/plain; charset=UTF-8 X-BeenThere: gtk-perl-list@gnome.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Using GTK+ with Perl List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Jan 2016 16:52:58 -0000 Hi folks, Based on the Gnome 3.19.x release calendar [1], I am setting the deadline for code submissions for the next release of Gtk-Perl modules to be Saturday, January 23rd 2016, at 00:01 UTC. Please have all code submissions into the Gtk-Perl maintainers before the above deadline; please allow time for the maintainers to audit and test code submissions. If you have your favorite RT ticket[2][3] or Gnome bug tracker bug[4] that you would like looked at, don't be afraid to bring it up for discussion here on the mailing list. Once the above deadline date arrives, I will begin packaging any new code in the Gtk-Perl git repos. After packaging, I will distribute tarballs to CPAN and Sourceforge, and post the release announcements, usually within a few days of the release date. If you have any questions about the above, please ask. Heads up for February, the release deadline will be Saturday, February 20th 2016, at 00:01UTC. Thanks, Brian [1] https://wiki.gnome.org/ThreePointNineteen [2] https://rt.cpan.org/Public/Dist/ByMaintainer.html?Name=XAOC [3] https://rt.cpan.org/Public/Dist/ByMaintainer.html?Name=TSCH [4] https://bugzilla.gnome.org/browse.cgi?product=gnome-perl