Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sat 02 Aug 2014, 02:45
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
How to create a tailbox with gtkdialog?
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 2 [27 Posts]   Goto page: 1, 2 Next
Author Message
brokenman

Joined: 20 Oct 2011
Posts: 25

PostPosted: Sun 04 Dec 2011, 21:18    Post subject:  How to create a tailbox with gtkdialog?  

I am having trouble understanding how to create a tailbox using gtkdialog.

At the moment i have a working example using xdialog but i am unsure if i should be using a progressbox that refreshes the editbox, or the timer fucntion i read about. Any help would be appreciated ... here is my example using xdialog:

Code:
( rsync_command >> $WRK/.rsyncstream & ) 2>> $WRK/.rsyncstream
while [[ -f $WRK/rsync-lock ]]; do
  Xdialog --title "Syncing with slackbuilds $sbver" --backtitle  "When syncing is complete, click OK!" --no-cancel --tailbox $WRK/.rsyncstream 600x460
done


This (rsync_command function) streams the output of my rsync command into a file that is read by the tailbox. how can i accomplish the same using gtkdialog?
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 5010
Location: Arizona, U.S.A.

PostPosted: Tue 06 Dec 2011, 00:54    Post subject:  

The problem I`ve always run into is that gtkDialog can`t be refreshed by external code.
A gtkDialog GUI loads the widgets at startup, then only widgets can refresh widgets.
If there is a timer, then it should do the trick, but I`ve never used it.

# Suggestion: You might make your TailBox with BaCon.
I know it is capable of doing what you want.
And... It will work on any Linux distro. with C ( virtually all...).

# Puppy is one of the few Linux distros. I`ve seen that uses gtkDialog.
Back to top
View user's profile Send private message 
thunor


Joined: 14 Oct 2010
Posts: 350
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings

PostPosted: Tue 06 Dec 2011, 11:12    Post subject: Re: How to create a tailbox with gtkdialog?  

brokenman wrote:
I am having trouble understanding how to create a tailbox using gtkdialog.

At the moment i have a working example using xdialog but i am unsure if i should be using a progressbox that refreshes the editbox, or the timer fucntion i read about. Any help would be appreciated ...
...

Hi brokenman

Code:
#!/bin/sh

GTKDIALOG=gtkdialog

DIALOG_MAIN='
<window title="Syncing with slackbuilds '$sbver'" resizable="true"
   default-width="600" default-height="460">
   <vbox>
      <text label="When syncing is complete, click OK!"></text>
      <vbox scrollable="true">
         <text wrap="false">
            <variable>txtOutput</variable>
            <input>tail -n 20 '$WRK'/.rsyncstream</input>
         </text>
      </vbox>
      <hbox homogeneous="true">
         <button use-stock="true" label="gtk-ok" is-focus="true"
            width-request="90">
         </button>
      </hbox>
      <timer interval="2" visible="false">
         <action>refresh:txtOutput</action>
      </timer>
   </vbox>
   <action signal="hide">exit:Exit</action>
</window>
'
export DIALOG_MAIN

$GTKDIALOG --program=DIALOG_MAIN

Regards,
Thunor
Back to top
View user's profile Send private message Visit poster's website 
brokenman

Joined: 20 Oct 2011
Posts: 25

PostPosted: Tue 06 Dec 2011, 16:20    Post subject:  Tailbox resolved  

Thank you kindly Thunor, you are a scholar and a gentleman and freakin awesome!

This is a much more elegant solution than my hidden progress bar repeatedly refreshing.

I have added you to my my list of favourite deities.
Back to top
View user's profile Send private message 
brokenman

Joined: 20 Oct 2011
Posts: 25

PostPosted: Tue 18 Feb 2014, 11:31    Post subject:  

Apologies for the ncero bump but this is the relevant thread.

I am looking for a tailbox that scrolls when full and always shows the tailing lines. Rather like the terminal widget as it outputs, the viewer sees the last lines. The current tailbox I have creates a scroller when full, but stays viewing the text at the top of the window.

Any ideas on how to accomplish this?
Back to top
View user's profile Send private message 
mikeb


Joined: 23 Nov 2006
Posts: 8041

PostPosted: Tue 18 Feb 2014, 12:50    Post subject:  

The only gui log box that automatically scrolls, seems to handly any text thats thrown at it, and has practically zero overhead was and still is gtklogfileviewer

Yad came close but it had a quirk handling cdrecord output.

xdialog was too jerky and only scrolled every few seconds.

mike
Back to top
View user's profile Send private message 
zigbert


Joined: 29 Mar 2006
Posts: 5654
Location: Valåmoen, Norway

PostPosted: Tue 18 Feb 2014, 13:05    Post subject:  

A solution is to switch recent output to top.
The command 'tac' is the opposite of 'cat' and is handy for this.


Sigmund

_________________
Stardust resources
Back to top
View user's profile Send private message Visit poster's website 
don570


Joined: 10 Mar 2010
Posts: 3221
Location: Ontario

PostPosted: Tue 18 Feb 2014, 15:54    Post subject:  

If the version of linux you have doesn't have tac installed there is
alternate command that will work in all versions.
I explain here....

Code:
cat - DATA_file <<<"$TEXT" > /tmp/temp_script_data


http://www.murga-linux.com/puppy/viewtopic.php?t=77269&sid=03ae6beef919a2e0e8fae8245090355a
__________________________________________
Back to top
View user's profile Send private message 
brokenman

Joined: 20 Oct 2011
Posts: 25

PostPosted: Tue 18 Feb 2014, 21:12    Post subject:  

Thanks folks. I'll take a look at these options.
Back to top
View user's profile Send private message 
Bert


Joined: 30 Jun 2006
Posts: 915

PostPosted: Fri 21 Feb 2014, 08:36    Post subject:  

brokenman wrote:
Apologies for the ncero bump but this is the relevant thread.

I am looking for a tailbox that scrolls when full and always shows the tailing lines. Rather like the terminal widget as it outputs, the viewer sees the last lines. The current tailbox I have creates a scroller when full, but stays viewing the text at the top of the window.

Any ideas on how to accomplish this?


I have the same question.
For days I've been trying to get this working: an auto-refreshing tree with a dynamically growing (non-buffering) input file..displaying the most recent lines. Just like with brokenman's tailbox, as soon as the box is full of lines, the newer lines disappear out of sight.

I tried with tail -f , tac, sed -i '1i...nothing seems to work well: either just the first topmost couple of lines are displayed or nothing until the process is finished and then the buffered text is shown in reversed order all at once...a bit late Wink

Is there a working example of such a "rolling" display someone could point me to?

PS Gtklogfileviewer is a nice find! It would be perfect if its core function could be imported in a gtk-dialog.( I lack the skills to open a binary, change it and 'make' it again)

Thanks!

_________________


Back to top
View user's profile Send private message 
mikeb


Joined: 23 Nov 2006
Posts: 8041

PostPosted: Fri 21 Feb 2014, 10:32    Post subject:  

@bert
You might be able to adopt this method of piping to yad to create a way of doing it from within a gtkdialog gui without needing a log file to be generated

courtesy of sfs

Code:
f="$@"
f=ftp://ftp.yandex.ru/ubuntu/ls-lR.gz
wget  --connect-timeout=3 -t 2 "$f" 2>&1 |tee /dev/stderr |sed -u "s/^ *[0-9]*K[ .]*\([0-9]*%\).*/\1/" | \
yad --image=save48-alt --no-buttons --progress-text="Load $f" \
    --progress --auto-close --auto-kill  --undecorated --center 2> /dev/null

otherwise I find gtkdialogviewer is tiny enough to slip in there like other useful widgets could be.

mike
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 340
Location: Japan

PostPosted: Fri 21 Feb 2014, 21:38    Post subject:  

Bert wrote:
Is there a working example of such a "rolling" display someone could point me to?

Unless you insist on gtkdialog, Xdialog is reliable, small and fast:
Code:
xev >> /tmp/xev.log &
Xdialog --tailbox "/tmp/xev.log" 30 100
Back to top
View user's profile Send private message 
mikeb


Joined: 23 Nov 2006
Posts: 8041

PostPosted: Sat 22 Feb 2014, 05:56    Post subject:  

Quote:
Unless you insist on gtkdialog, Xdialog is reliable, small and fast:

hmm your example does not scroll up for me.

I tried xdialog to monitor cdrecord output and it jump up every 4-5 seconds and not smoothly like gtklogfileviewer.

Agreed though...insisting on gtkdialog for everything is chasing ones own tail....why reject good alternative tools for the job....is this a puppy disease?

mike
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 340
Location: Japan

PostPosted: Sat 22 Feb 2014, 07:06    Post subject:  

mikeb wrote:
hmm your example does not scroll up for me.
Very Happy well, it scrolls so fast that it appears static. And - of course - you have to generate some events in the Event Tester window.
Back to top
View user's profile Send private message 
mikeb


Joined: 23 Nov 2006
Posts: 8041

PostPosted: Sat 22 Feb 2014, 07:28    Post subject:  

I did...text was added but the screen stayed static just the scroll bar showed more was there. I have found xdialog behaviour varies with gtk2 version so that must be the reason. (spin boxes come to mind)
Odd really as it did scroll up for cdrecord just badly but that would have been tested on puppy 4.

By the way I do use xdialog for some things...I have no personal prejudice against it or anything else as long as it does the job.

mike
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 2 [27 Posts]   Goto page: 1, 2 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0972s ][ Queries: 11 (0.0074s) ][ GZIP on ]