How to create a tailbox with gtkdialog?

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
brokenman
Posts: 25
Joined: Thu 20 Oct 2011, 23:00

How to create a tailbox with gtkdialog?

#1 Post by brokenman »

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: Select all

( 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?

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#2 Post by sunburnt »

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.

User avatar
thunor
Posts: 350
Joined: Thu 14 Oct 2010, 15:24
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
Contact:

Re: How to create a tailbox with gtkdialog?

#3 Post by thunor »

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: Select all

#!/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

brokenman
Posts: 25
Joined: Thu 20 Oct 2011, 23:00

Tailbox resolved

#4 Post by brokenman »

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.

brokenman
Posts: 25
Joined: Thu 20 Oct 2011, 23:00

#5 Post by brokenman »

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?

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#6 Post by mikeb »

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

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#7 Post by zigbert »

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


Sigmund

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#8 Post by don570 »

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: Select all

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


http://www.murga-linux.com/puppy/viewto ... 245090355a
__________________________________________

brokenman
Posts: 25
Joined: Thu 20 Oct 2011, 23:00

#9 Post by brokenman »

Thanks folks. I'll take a look at these options.

User avatar
Bert
Posts: 1103
Joined: Fri 30 Jun 2006, 20:09

#10 Post by Bert »

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!
[url=http://pupsearch.weebly.com/][img]http://pupsearch.weebly.com/uploads/7/4/6/4/7464374/125791.gif[/img][/url]
[url=https://startpage.com/do/search?q=host%3Awww.murga-linux.com%2F][img]http://i.imgur.com/XJ9Tqc7.png[/img][/url]

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#11 Post by mikeb »

@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: Select all

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

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#12 Post by MochiMoppel »

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: Select all

xev >> /tmp/xev.log &
Xdialog --tailbox "/tmp/xev.log" 30 100

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#13 Post by mikeb »

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

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#14 Post by MochiMoppel »

mikeb wrote:hmm your example does not scroll up for me.
:D well, it scrolls so fast that it appears static. And - of course - you have to generate some events in the Event Tester window.

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#15 Post by mikeb »

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

User avatar
Bert
Posts: 1103
Joined: Fri 30 Jun 2006, 20:09

#16 Post by Bert »

From "impossible" to three possibilties :D

The yad code by sfs is working, as are gtklogfileviewer and the Xdialog tailbox.
With yad I cannot get the scrolling-in-reverse. Would have to create a log file and that does not auto-scroll in real time.

The reason why I wanted this to succeed in gtkdialog is I also need to add a custom button to this window. So far, I haven't found how to do this in xdialog.
(yes, I'm a totlal noob in coding) When I want a button "pizza" in gtkdialog, poof! it's there, opening a window "pizzeria" and smelling good :wink:

So I'm not against using xdialog. The tailbox is in fact really fast! It's just that I find it hard to understand its iron logic.

Thank you both, Mike and MochiMoppel!

Bert
[url=http://pupsearch.weebly.com/][img]http://pupsearch.weebly.com/uploads/7/4/6/4/7464374/125791.gif[/img][/url]
[url=https://startpage.com/do/search?q=host%3Awww.murga-linux.com%2F][img]http://i.imgur.com/XJ9Tqc7.png[/img][/url]

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

How to create a tailbox with gtkdialog?

#17 Post by L18L »

MochiMoppel wrote:
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: Select all

xev >> /tmp/xev.log &
Xdialog --tailbox "/tmp/xev.log" 30 100
And this also works as "one-liner" ( without temporary file )

Code: Select all

xev | Xdialog --tailbox "/tmp/xev.log" 30 100
mikeb wrote:....why reject good alternative tools for the job....
+1
dialog is older so give it a try:

Code: Select all

xev | dialog --tailbox "/tmp/xev.log" 30 100
(works for me, too)

or

Code: Select all

rxvt  -e xev | dialog --tailbox "/tmp/xev.log" 30 100
:?:

EDIT
forget it please :lol: :lol: :lol:
Last edited by L18L on Sun 23 Feb 2014, 12:51, edited 1 time in total.

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#18 Post by mikeb »

gtklogfileviewer /tmp/pburn-log Close -center 0 600 350 "Pburn Log"

'Close' is the button name....

mike

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

Re: How to create a tailbox with gtkdialog?

#19 Post by MochiMoppel »

L18L wrote:And this also works as "one-liner" ( without temporary file )

Code: Select all

xev | Xdialog --tailbox "/tmp/xev.log" 30 100
Very unlikely :lol:

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

Re: How to create a tailbox with gtkdialog?

#20 Post by L18L »

MochiMoppel wrote:
L18L wrote:And this also works as "one-liner" ( without temporary file )

Code: Select all

xev | Xdialog --tailbox "/tmp/xev.log" 30 100
Very unlikely :lol:
Yes you are right.
It worked only because the temporary file still existed :oops: :oops: :oops:

Post Reply