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 Thu 23 Oct 2014, 16:02
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
GTK Terminal Window
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 2 [29 Posts]   Goto page: 1, 2 Next
Author Message
8-bit


Joined: 03 Apr 2007
Posts: 3382
Location: Oregon

PostPosted: Mon 12 Oct 2009, 09:38    Post subject:  GTK Terminal Window
Subject description: How do I incorporate one in a GTK script
 

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?
Back to top
View user's profile Send private message 
sunburnt


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

PostPosted: Thu 15 Oct 2009, 00:58    Post subject:  

Hi 8-bit; This is how to start rxvt and have it run a command:
Code:
rxvt -e (exec. file name)

I`ve used a vt for a couple of apps., usually works nice... Terry
Back to top
View user's profile Send private message 
disciple

Joined: 20 May 2006
Posts: 6449
Location: Auckland, New Zealand

PostPosted: Thu 15 Oct 2009, 06:24    Post subject:  

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.

Quote:
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]

_________________
DEATH TO SPREADSHEETS
- - -
Classic Puppy quotes
- - -
Beware the demented serfers!
Back to top
View user's profile Send private message 
8-bit


Joined: 03 Apr 2007
Posts: 3382
Location: Oregon

PostPosted: Thu 15 Oct 2009, 20:41    Post subject:  

sunburnt wrote:
Hi 8-bit; This is how to start rxvt and have it run a command:
Code:
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:

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.
Back to top
View user's profile Send private message 
disciple

Joined: 20 May 2006
Posts: 6449
Location: Auckland, New Zealand

PostPosted: Thu 15 Oct 2009, 22:31    Post subject:  

It looks to me like Gparted deals with floppies...
_________________
DEATH TO SPREADSHEETS
- - -
Classic Puppy quotes
- - -
Beware the demented serfers!
Back to top
View user's profile Send private message 
8-bit


Joined: 03 Apr 2007
Posts: 3382
Location: Oregon

PostPosted: Thu 15 Oct 2009, 22:49    Post subject:  

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.
Back to top
View user's profile Send private message 
disciple

Joined: 20 May 2006
Posts: 6449
Location: Auckland, New Zealand

PostPosted: Thu 15 Oct 2009, 22:56    Post subject:  

You're talking about shell scripts now aren't you? Do they both use the same shell?
_________________
DEATH TO SPREADSHEETS
- - -
Classic Puppy quotes
- - -
Beware the demented serfers!
Back to top
View user's profile Send private message 
8-bit


Joined: 03 Apr 2007
Posts: 3382
Location: Oregon

PostPosted: Fri 16 Oct 2009, 00:30    Post subject:  

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.
Back to top
View user's profile Send private message 
disciple

Joined: 20 May 2006
Posts: 6449
Location: Auckland, New Zealand

PostPosted: Fri 16 Oct 2009, 00:57    Post subject:  

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.

_________________
DEATH TO SPREADSHEETS
- - -
Classic Puppy quotes
- - -
Beware the demented serfers!
Back to top
View user's profile Send private message 
8-bit


Joined: 03 Apr 2007
Posts: 3382
Location: Oregon

PostPosted: Fri 16 Oct 2009, 01:15    Post subject:  

Thank you for the clarification of use of 'done'.
I learn as I go along.
Back to top
View user's profile Send private message 
8-bit


Joined: 03 Apr 2007
Posts: 3382
Location: Oregon

PostPosted: Sat 17 Oct 2009, 15:09    Post subject:  

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.
pyfloppy-1.6.tar.bz2
Description  Internal floppy formatter that requires Python to run.
bz2

 Download 
Filename  pyfloppy-1.6.tar.bz2 
Filesize  20.36 KB 
Downloaded  495 Time(s) 
Back to top
View user's profile Send private message 
disciple

Joined: 20 May 2006
Posts: 6449
Location: Auckland, New Zealand

PostPosted: Sat 17 Oct 2009, 17:17    Post subject:  

Have you looked at the two ways zigbert has used with pburn?
_________________
DEATH TO SPREADSHEETS
- - -
Classic Puppy quotes
- - -
Beware the demented serfers!
Back to top
View user's profile Send private message 
8-bit


Joined: 03 Apr 2007
Posts: 3382
Location: Oregon

PostPosted: Sun 18 Oct 2009, 14:26    Post subject:  

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.
Back to top
View user's profile Send private message 
8-bit


Joined: 03 Apr 2007
Posts: 3382
Location: Oregon

PostPosted: Sun 18 Oct 2009, 14:37    Post subject:  

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:
<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]
Back to top
View user's profile Send private message 
sunburnt


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

PostPosted: Sun 18 Oct 2009, 15:22    Post subject:  

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.
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 2 [29 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.0753s ][ Queries: 12 (0.0040s) ][ GZIP on ]