Re: [Lazarus] GUI frontend to a console application
On Wed, Feb 25, 2009 at 7:04 AM, Funky Beast funkybe...@pacific.net.sg wrote: If the console app is self-written, you can use a mix of TProcess and TSimpleIPCServer and TSimpleIPCClient. This is a very interesting approach. Thanks for mentioning it. I will definitely give this a try. And I love the benefit of the multi-core system. :-) Regards, - Graeme - ___ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/ ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
[Lazarus] GUI frontend to a console application
Hi, This is probably more related to unix systems... Has anybody got a small sample application, some documentation or is a sample included in Lazarus that shows how to go about writing a GUI frontend to a console application? For our company I want to implement a GUI app to help them setup a few basic things on a Linux system and interact with some console apps. Our users are NOT tech-savy, so I need a GUI to help them along. Any idea how I go about this? Regards, - Graeme - ___ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/ ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] GUI frontend to a console application
Le Tue, 24 Feb 2009 10:46:43 +0200, Graeme Geldenhuys graemeg.li...@gmail.com a écrit : in Lazarus that shows how to go about writing a GUI frontend to a console application? FreeVision? (fpcsrc/2.2.x/packages/fv) I don't know if it's still working, I din't use it for years now and I can't compile the example project. If it works for you, any TurboVision doc sample apps can help you. Regards, Thierry -- Toraka Bilaogy : http://torakabilaogy.blogspot.com Le 'salon' Madagascar : http://friendfeed.com/rooms/madagascar (New!) Thierry sur Facebook : http://profile.to/thierryandriamirado/ ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] GUI frontend to a console application
On Tue, Feb 24, 2009 at 12:43:43PM +0300, Thierry Andriamirado wrote: in Lazarus that shows how to go about writing a GUI frontend to a console application? FreeVision? (fpcsrc/2.2.x/packages/fv) I don't know if it's still working, I din't use it for years now and I can't compile the example project. If it works for you, any TurboVision doc sample apps can help you. It is working largely. The example also compiles.What error do you get ? ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] GUI frontend to a console application
On Tue, Feb 24, 2009 at 11:43 AM, Thierry Andriamirado thierry.andriamir...@free.fr wrote: FreeVision? (fpcsrc/2.2.x/packages/fv) I didn't mean writing a GUI in the console. I meant a true GUI app (LCL or fpGUI based), which uses a console application as the backend. For example, Linux has many GUI frontends for programs like makeiso, burncd, cdrecord, cvs, mpg123 etc... eg: FLTK burncd GUI frontend for burncd http://linux.softpedia.com/get/Programming/UI-User-Interfaces-/FLTK-burncd-GUI-frontend-3184.shtml bburn GUI frontend for mkisofs/cdrecord http://savannah.nongnu.org/projects/bburn/ Gnome-Toaster - gui frontend for cdrecord http://gnometoaster.rulez.org/ Regards, - Graeme - ___ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/ ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] GUI frontend to a console application
2009/2/24 Graeme Geldenhuys graemeg.li...@gmail.com: On Tue, Feb 24, 2009 at 2:41 PM, Graeme Geldenhuys graemeg.li...@gmail.com wrote: For example, Linux has many GUI frontends for programs like makeiso, burncd, cdrecord, cvs, mpg123 etc... The most obvious example would probably be all the GUI frontends available for GDB debugger. :-) I have no clue how to write such a GUI application. Anybody know? it depends how the back-end works. your gui would set the options to the back-end, start it, then read and write from the back-end. you can do all of this with tprocess henry ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] GUI frontend to a console application
On Dienstag, 24. Februar 2009 13:46:21 Graeme Geldenhuys wrote: On Tue, Feb 24, 2009 at 2:41 PM, Graeme Geldenhuys graemeg.li...@gmail.com wrote: For example, Linux has many GUI frontends for programs like makeiso, burncd, cdrecord, cvs, mpg123 etc... The most obvious example would probably be all the GUI frontends available for GDB debugger. :-) I have no clue how to write such a GUI application. Anybody know? Just take TProcess class and run your console app. Then you can pass input and read output from there. I think there is some example in the wiki. For a more detailed example you can also look at my mplayer class. http://svn.berlios.de/svnroot/repos/cactusjukebox/source/mplayer.pas It's an interface to mplayer console app. Sebastian ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] GUI frontend to a console application
Graeme Geldenhuys wrote: Hi, This is probably more related to unix systems... Has anybody got a small sample application, some documentation or is a sample included in Lazarus that shows how to go about writing a GUI frontend to a console application? While it isn't a small example. The IDE itself contains such code wrapping gdb. debugger\cmdlinedebugger.pp It will be similar (probably easier) if the command line app is *not* interactive. Best Regards Martin ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] GUI frontend to a console application
On Tue, Feb 24, 2009 at 3:06 PM, Sebastian Kraft sebastian_kr...@gmx.de wrote: For a more detailed example you can also look at my mplayer class. http://svn.berlios.de/svnroot/repos/cactusjukebox/source/mplayer.pas It's an interface to mplayer console app. This will come in very handy. Thanks Sebastian! Regards, - Graeme - ___ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/ ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] GUI frontend to a console application
On Tue, Feb 24, 2009 at 3:08 PM, Martin Friebe laza...@mfriebe.de wrote: It will be similar (probably easier) if the command line app is *not* interactive. The console apps we want to wrap works similar to the SubVersion (svn) command line client. Execute with certain parameters and read back the results, which must be displayed in a GUI form via various components. Some console apps which we will be writing ourselves will output % progress, which we would like to represent with a TProgressBar. The reason we want both console and a GUI wrapper is so that we can script/automate the console app, but also allow the user to run it manually via a easier to use GUI frontend. Regards, - Graeme - ___ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/ ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] GUI frontend to a console application
On Tue, Feb 24, 2009 at 2:50 PM, ik ido...@gmail.com wrote: The svn integration in Lazarus contain good example on how to do it. And you can also use my code: http://ik.homelinux.org/projects/files/mazrim-nx.tar.gz Thanks Ido, that's exactly what I wanted to know. Never thought to look at the svn integration code. :) Regards, - Graeme - ___ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/ ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] GUI frontend to a console application
Graeme Geldenhuys schreef: On Tue, Feb 24, 2009 at 2:41 PM, Graeme Geldenhuys graemeg.li...@gmail.com wrote: For example, Linux has many GUI frontends for programs like makeiso, burncd, cdrecord, cvs, mpg123 etc... The most obvious example would probably be all the GUI frontends available for GDB debugger. :-) I have no clue how to write such a GUI application. Anybody know? Browsing the projects using Lazarus on the wiki, I got to http://www.ullihome.de/index.php/QFront I bet there are more on that page. And the most (all?) of the examples on http://wiki.lazarus.freepascal.org/Executing_External_Programs are GUIs calling console apps. Vincent ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] GUI frontend to a console application
It simple, you need to use TProcess (TProcessUTF8 if you must), and pipes. if you need input as well as output then you need to work with them both. The svn integration in Lazarus contain good example on how to do it. And you can also use my code: http://ik.homelinux.org/projects/files/mazrim-nx.tar.gz Ido On Tue, Feb 24, 2009 at 10:46 AM, Graeme Geldenhuys graemeg.li...@gmail.com wrote: Hi, This is probably more related to unix systems... Has anybody got a small sample application, some documentation or is a sample included in Lazarus that shows how to go about writing a GUI frontend to a console application? For our company I want to implement a GUI app to help them setup a few basic things on a Linux system and interact with some console apps. Our users are NOT tech-savy, so I need a GUI to help them along. Any idea how I go about this? Regards, - Graeme - ___ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/ ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] GUI frontend to a console application
Graeme Geldenhuys escreveu: On Tue, Feb 24, 2009 at 3:08 PM, Martin Friebe laza...@mfriebe.de wrote: It will be similar (probably easier) if the command line app is *not* interactive. The console apps we want to wrap works similar to the SubVersion (svn) command line client. Execute with certain parameters and read back the results, which must be displayed in a GUI form via various components. Some console apps which we will be writing ourselves will output % progress, which we would like to represent with a TProgressBar. The reason we want both console and a GUI wrapper is so that we can script/automate the console app, but also allow the user to run it manually via a easier to use GUI frontend. I tweaked a class found in PasDoc project (made it standalone) that provides methods to talk with a process. http://code.google.com/p/luipack/source/browse/trunk/miscutils/processlinetalk.pas It's used by sevenzipwrapper found in the same dir Luiz ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] GUI frontend to a console application
Graeme Geldenhuys schrieb: I didn't mean writing a GUI in the console. I meant a true GUI app (LCL or fpGUI based), which uses a console application as the backend. What then is your technical problem? For example, Linux has many GUI frontends for programs like makeiso, burncd, cdrecord, cvs, mpg123 etc... These frontends most probably collect the options and then call the backends with the appropriate command line. Or they use the application libraries directly, without starting the console programs. In this case the command line argument evaluation has to be moved to the GUI frontend, which finally calls the same procedures as the main procedure of the console application does. For easy maintenance the console programs can be changed to use a shared library, which then can be used by every frontend. The shared libraries then should not do any console output, eventually output to stdout or stderr must be caught by the frontend, or the handles must be redirected/piped to the frontend. I never separated existing applications into shared libraries, so I don't know about the best solution for console output. When every output ends up in a few unique procedures, these procedures can be replaced by callback functions, provided by the frontend and installed during initialization of the shared library. DoDi ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] GUI frontend to a console application
Graeme Geldenhuys wrote: On Tue, Feb 24, 2009 at 3:08 PM, Martin Friebe laza...@mfriebe.de wrote: It will be similar (probably easier) if the command line app is *not* interactive. The console apps we want to wrap works similar to the SubVersion (svn) command line client. Execute with certain parameters and read back the results, which must be displayed in a GUI form via various components. Some console apps which we will be writing ourselves will output % progress, which we would like to represent with a TProgressBar. The reason we want both console and a GUI wrapper is so that we can script/automate the console app, but also allow the user to run it manually via a easier to use GUI frontend. Regards, - Graeme - ___ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/ ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus If the console app is self-written, you can use a mix of TProcess and TSimpleIPCServer and TSimpleIPCClient. Add a TSimpleIPCClient to your console app, so that it can send message to its paired up TSimpleIPCServer which is hosted on the GUI frontend. This way, your console app can speak to your GUI frontend app. Be sure to read an argument as your IPCServerName, so it knows which IPCServer to talk to. On your GUI frontend, use a thread to read messages from the IPCServer continuously. If you want to execute multiple console apps simultaneously, use TProcess to execute your console apps with poWaiting and poUsePipes turned off (so that it returns control to your app immediately) and use a TSimpleIPCServer to listen to the TSimpleIPCClient from your console app. In the long run you should have a multi-threaded process-manager that handles a collection of TProcess and TSimpleIPCServer. I have chopped up all my big apps into small console apps and frontends. So, my apps can all run with or without a GUI. So my big app is now a package of console apps and a frontend, sort of like how Linux works. A rough model of my process-manager: ** TIPCServerThread = class (TThread) public IPCServer: TSimpleIPCServer;//For listening to the IPCClient of the console app end; TIPCProcess = class (TCollectionItem) public Process: TProcess;//For executing the console app (Execute without waiting) IPCServerThread: TIPCServerThread;//Listens and update status of this process property Status; property Progress; property MaxProgress; property Errors; //Note: the console app will receive an IPCServerName as a argument so it knows // which IPCServer to talk to. end; TIPCProcessList = class (TCollection)//For handling a collection of TIPCProcess. TIPCProcessManager = class(TComponent) //For complex mangement of processes like executing events when a particular process completes. //or a timer for polling the processlist for status to be displayed or actions to be taken. ** This allows me to add features to my app easier as debugging my new console app is easier than debugging the monolithic app (most of my console apps handles long-loopy functions). Also you take advantage of multi-core processors instantly as the OS will do it for you like as though you open multiple programs, you don't need to spend time tweaking your threads to consume or force-feed them to a paticular core. The front end serves only to display or execute console apps and load results. my $0.002 Funky Beast ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus