GTK Terminal Window

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

GTK Terminal Window

#1 Post by 8-bit »

I had a wild thought of incorporating a terminal window in my usb floppy formatting program.
I want it to be able to display the output of the formatting command and also
the dos writing command. Anyone know GTK code to do this?

But I thought "Why not take it a little further and have it work for internal floppy drives."
With a few tests included, It could become a floppy format utility for both types of floppy drives.

But to me, currently the rxvt window as part of the GUI display would clean things up.
So, with Barry's permission, do you think a GTK program for all floppy drives is a good idea?

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

#2 Post by sunburnt »

Hi 8-bit; This is how to start rxvt and have it run a command:

Code: Select all

rxvt -e (exec. file name)
I`ve used a vt for a couple of apps., usually works nice... Terry

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#3 Post by disciple »

Also, Barry recently (in the last year or so) added a bash script that enables the -h (IIRC) option, so it remains open after running the comman, if you call it as xterm instead of rxvt (IIRC).

If you just want to display output you could also look at the way Zigbert does it with gtkdialog in Pburn, or the way he used to do it with xdialog (I think that was better.
If you are writing a C program and don't want to call an external program you could use libvte, but I think it is over the top if you just want to display output... there must be a simpler way.
So, with Barry's permission, do you think a GTK program for all floppy drives is a good idea?
You don't need Barry's permission, although obviously he or whoever builds a Puppy version would decide if it was included. Is there no gui in Puppy to do it currently? What about Gparted?[/quote]
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#4 Post by 8-bit »

sunburnt wrote:Hi 8-bit; This is how to start rxvt and have it run a command:

Code: Select all

rxvt -e (exec. file name)
I`ve used a vt for a couple of apps., usually works nice... Terry
Been there, done that. Thanks though.

Now I am trying to figure out how to have error checking passed from the child program I run using rxvt -e (program name) through rxvt and back to my GTK script.
A segment of it that attempts it is:

Code: Select all

llfloppy()
{
rxvt +sb -bg green -geometry 80x4 -e $CBOX1 $COMBO1 $WORD1
#ufiformat -f  $COMBO1 $WORD1
 if [ $? != 0 ]; then
 #	    rxvt +sb -bg red -geometry 80x4 -e echo  No floppy in drive or floppy write protected or mounted. 
 gxmessage -center -name USB_Floppy_Formatter "No floppy in drive or floppy write protected or mounted. "
 exit 1
 else
 gxmessage -center -name USB_Floppy_Formatter  "Formatting  is finished. "
 fi
return
}
If an error occurs with the program being run using rxvt, the error is returned to rxvt, but rxvt does not return the error to my script.

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#5 Post by disciple »

It looks to me like Gparted deals with floppies...
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#6 Post by 8-bit »

Very true!
I got a request of adding a little error checking and returning to the main program window after displaying an error message.

But I also found out something interesting in making some routines.
If I used 'done' as the final line of the subroutine, the program would not run.
When I substituted "return" in it's place, everthing worked.
I even had the main dialog set up as a routine I could call.
But I wonder why "done' worked in Barry's program and not mine.
It was set up in exactly the same format.

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#7 Post by disciple »

You're talking about shell scripts now aren't you? Do they both use the same shell?
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#8 Post by 8-bit »

Barry's Program is in menu/system/Format Floppy Disk.
It only handles internal floppy drives.
Mine handles external USB floppy drives.
As to what he used to write his, a script, I do not know.
But it looked like gtkdialog3 in style.
His is /usr/sbin/floppy-format.sh if you want to examine it.
My early version of USB floppy formatter is a Pet available from
The Pet Store. It uses GTKdialog3 which is included in puppy and also uses ufiformat which is included in the PET.
I did not write ufiformat.
I only wrote a GTKdialog script to give it a GUI interface.

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#9 Post by disciple »

His script uses a while statement: while [some condition]; do [some tasks]; [done].
done is needed to mark the end of the do statement. You don't have a while/do, so you don't need it.
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#10 Post by 8-bit »

Thank you for the clarification of use of 'done'.
I learn as I go along.

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#11 Post by 8-bit »

What I am after with my USB floppy program written with gtkdialog3 is an interface that has a window for displaying output from the formatting command.
I investigated an open source copyrighted program called pyfloppy.
But it requires python to run.
I have played with the python script for it and actually got it to work with a USB floppy.
But I would like to keep size down by just using gtkdialog3 and ufiformat.
I will attach the original pyfloppy so you can see what I mean.
It only works with internal floppy drives, not USB floppys.
To run it from it's directory using Python, you type 'python pyfloppy.py' in a terminal opened in the directory.
Or set run action to python.
Attachments
pyfloppy-1.6.tar.bz2
Internal floppy formatter that requires Python to run.
(20.36 KiB) Downloaded 691 times

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#12 Post by disciple »

Have you looked at the two ways zigbert has used with pburn?
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#13 Post by 8-bit »

disciple wrote:Have you looked at the two ways zigbert has used with pburn?
I looked!
Looks like a foreign language that I cannot comprehend.
It is composed of a lot of script files though.
I eventually will find a way to display the output of an external command WHILE it is running.
The thing here is it is kind of like the Puppy Installer.
An external process is run from the installer and the installer disappears until external process completes with the user wondering what the heck happened.

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#14 Post by 8-bit »

I also played around with the tailing thing and although I can get some of the output of an external command to display in a window, it is only after the external program completes.

Part of my attempt was a code line:

Code: Select all

<input>"`ufiformat -i`"</input>
When I run the program with tailings in it as a test, I get a gtkdialog error of Command /dev/sde /dev/sg5 not found.
The dev string was being returned to gtk but handling it is another thing.
[/code]

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

#15 Post by sunburnt »

8-bit; If you want the GUI to remain visible while your format program runs
in Xterm, use " &" on the end of the xterm command to background it.
The only problem is that the GUI won`t know when Xterm is finished.
In some of my apps. like this that was a problem, it may not be for yours.

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#16 Post by 8-bit »

Has anyone had any luck with the -geometry option working fully?
I have tried it with -geometry 80x4+20+10 and have had no luck with positioning of a window.
If I understand it correctly, the first part is character size of windows and the second is placement by pixel addressing.
But the second part supposedly can be changed by adding a suffix of c to it.
Or is it prefix?
Can't remember right now.

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#17 Post by 8-bit »

sunburnt wrote:8-bit; If you want the GUI to remain visible while your format program runs
in Xterm, use " &" on the end of the xterm command to background it.
The only problem is that the GUI won`t know when Xterm is finished.
In some of my apps. like this that was a problem, it may not be for yours.
One of my problems was to get text output of the external program to display while it was running.
But if I use rxvt or xterm [name of program] and have it send it's output to a temporary file to be read and displayed,
the external program completes before the routine to display the text starts.
Also, if I use rxvt [name of program] with an rxvt window, if the program has an error, it is sent to rxvt only and rxvt exits with no error
so checking for errors of the program run via rxvt is driving me nuts.

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

#18 Post by sunburnt »

Code: Select all

rxvt -e (run program and redirect it`s output to /tmp/file) &
GUI top app. monitoring the /tmp/file
So rxvt and the GUI top app. are running at the same time.

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#19 Post by 8-bit »

I tried that approach with running the external program in the background with it's output directed to a /temp/file and the tailings routine waited for the external program to finish before it ran.
As a result, only the tailings of the output from the external program were displayed.

Now on to another thing.
First, the -geometry option works!
You can try it in a terminal to bring up another terminal by typing
#rxvt -geometry 40x15+480+400
The 40x15 is character size of window.
The 480+400 is window position by pixel in format of horizontal+vertical.

And...
Does anyone know if it is possible to pass an error code from an external program run with rxvt -e back to the gtkdialog script?
When the external program is run with rxvt -e, and has an error, it passes it to rxvt, which closes without passing along the error to the script.

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

#20 Post by sunburnt »

8-bit; Why did you have the tail output app. wait for rxvt to finish?
I thought that you wanted it to show it`s output interactively.

To answer your last Q:
First do you expect the parent app. to know what the child app. is doing
while the child is running, or get the error after the child finishes?
If after... Run it like this:

Code: Select all

. rxvt -e 
If during... The child writes a /tmp file and the parent watches for it.

Post Reply