LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 12-05-2007, 12:18 PM   #1
Carunkumar
Member
 
Registered: Sep 2006
Location: chennai
Distribution: fedora core 8
Posts: 106

Rep: Reputation: 15
how to use command line program in gui


I wrote a program that would take an audio file and process it. I wrote a shell script which used 'brec' to record users voice data and store it to a file. brec takes the filename.wav as an commnand line argument..

eg:

Code:
$brec -s 16000 -t 5 -b 16 -w filename.wav
this command took input data from mic and wrote it to filename.wav. Later in the script I used the filename.wav as a command line argument for my program which would process it.

Now I want to build a gui for this. I thought of putting a button called 'record'. The callback function for 'clicked' event of this button would invoke the 'brec' binary. Can I pass command line arguments from the callback function. Can I use brec from the callback function??

I am using c with glade-2.

Thank you..

Last edited by Carunkumar; 12-05-2007 at 12:21 PM.
 
Old 12-05-2007, 01:24 PM   #2
schneidz
Senior Member
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 4,010

Rep: Reputation: 624Reputation: 624Reputation: 624Reputation: 624Reputation: 624Reputation: 624
my suggestion is to use tcl/ tk. it is simple and is useful for quick-and-dirty 'command-line -> button-press -> text-box' event widgets.

else try menus (gdialog, zenity) i made quite a useful transcode, cdrecord, tarballer front-end using gdialog and gnome's built-in nautilus scripts.

edit: this search might help: http://www.linuxquestions.org/questi...archid=1916859
hope this helps

Last edited by schneidz; 12-05-2007 at 01:27 PM.
 
Old 12-06-2007, 02:18 AM   #3
Carunkumar
Member
 
Registered: Sep 2006
Location: chennai
Distribution: fedora core 8
Posts: 106

Original Poster
Rep: Reputation: 15
thank you..
 
Old 12-06-2007, 02:33 AM   #4
Carunkumar
Member
 
Registered: Sep 2006
Location: chennai
Distribution: fedora core 8
Posts: 106

Original Poster
Rep: Reputation: 15
The search is not working. I searched for zenity. Is it a program to show up gui widgets to get input and output from scripts?? I wanted to know how to run a command line utility from gtk+ applications. Can I have a frontend designed in glade, where I could pass the name of the program which runs on command line from the callback function?? just like the mini commander, a widget which we add to pannels in gnome.. is it possible to have a text entry which would execute commands from shell, in an gui interface?

Thanks for the help.
 
Old 12-06-2007, 11:26 AM   #5
schneidz
Senior Member
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 4,010

Rep: Reputation: 624Reputation: 624Reputation: 624Reputation: 624Reputation: 624Reputation: 624
my gdialog scripts:
http://www.linuxquestions.org/questi...hlight=gdialog
http://www.linuxquestions.org/questi...hlight=gdialog
http://www.linuxquestions.org/questi...hlight=gdialog

feel free to modify to your hearts content. zenity is basically a newer version of gdialog. if you use gnome, i suspect the pop-up dialog box from a right-click -> copy and a right-click -> paste is a gdialog box. there is an examples directory; try looking for the paste one - sorry i dont remember where it is.

this might also help: g-scripts.sourceforge.net

anything more than simple menus you will probably need to use gtk+/ glade. i have no experience with that.
 
Old 12-06-2007, 12:08 PM   #6
Carunkumar
Member
 
Registered: Sep 2006
Location: chennai
Distribution: fedora core 8
Posts: 106

Original Poster
Rep: Reputation: 15
thank you..
 
Old 12-06-2007, 01:03 PM   #7
MicahCarrick
Member
 
Registered: Jul 2004
Distribution: Fedora
Posts: 241

Rep: Reputation: 31
This might be of use to you: Execute command into a GtkTextView (C and Libglade)
 
Old 12-09-2007, 05:25 AM   #8
Carunkumar
Member
 
Registered: Sep 2006
Location: chennai
Distribution: fedora core 8
Posts: 106

Original Poster
Rep: Reputation: 15
Thank you.. That is what I wanted to know.. Now I got an idea.. Can I use the execl() function in one of the call back function? I didn't know how it would work. I tried the ls command. It didn't show up any terminal window. If I pass a function for recording data with arguments using execl, obviously the ouputs to the console won't get printed. But will the recording take place??

Thank you again.
 
Old 12-10-2007, 04:44 AM   #9
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: FreeBSD, Debian, Mint, Puppy
Posts: 3,287

Rep: Reputation: 173Reputation: 173
i agree, try tcl/tk
or perl/tk
 
Old 12-10-2007, 02:01 PM   #10
schneidz
Senior Member
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 4,010

Rep: Reputation: 624Reputation: 624Reputation: 624Reputation: 624Reputation: 624Reputation: 624
one more thing, a specific type of tcl used for gui's is v-tcl (visual tcl).

in college i had an assignment to create an ssh front-end for newbies that didnt want to mess with the command-line.

the command-line was for the hostname or command. so when they hit the 'go' button the results would display in the text-box.

i didnt get very far...

Last edited by schneidz; 12-10-2007 at 02:05 PM.
 
Old 12-10-2007, 02:45 PM   #11
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,755

Rep: Reputation: 466Reputation: 466Reputation: 466Reputation: 466Reputation: 466
Xdialog and gtkdialog are also very useful for doing this sort of thing.
 
Old 12-13-2007, 01:44 PM   #12
Carunkumar
Member
 
Registered: Sep 2006
Location: chennai
Distribution: fedora core 8
Posts: 106

Original Poster
Rep: Reputation: 15
thank you..
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Viewing program messages when program isn't run from command line? Locura Linux - Software 1 09-27-2003 08:19 AM
Command line to GUI Jon84 Slackware 34 03-12-2003 08:54 PM
Need help getting to GUI from command line Negativ13 Linux - Newbie 6 02-25-2003 03:20 PM
gui vs. command line sdfjk Linux - Newbie 1 10-05-2002 03:59 PM
Command Line vs GUI Poorman Linux - General 27 07-11-2002 12:40 PM


All times are GMT -5. The time now is 08:00 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration