can buttons know what happens to programs they launch?

Eric Mesa ericsbinaryworld at gmail.com
Fri Feb 17 05:21:11 UTC 2012


On Mon, Feb 13, 2012 at 9:45 AM, Eric Mesa <ericsbinaryworld at gmail.com>wrote:

> On Tue, Feb 7, 2012 at 3:12 PM, Hans Chen <hanswchen at gmail.com> wrote:
>
>> You may want to take a look at KProcess:
>> http://api.kde.org/4.x-api/kdelibs-apidocs/kdecore/html/classKProcess.html
>> For example, here's a Python plasmoid that uses it:
>> http://kde-look.org/content/show.php/Redshift+plasmoid?content=148737
>>
>
> Took a look at that but I wasn't sure how to do that based on QML.  Here
> are the ideas I've come up with, I'm not sure if they'll work.
>
> Some of them involve my python helper program using sys.exit() with a 0 or
> 1 to denote success or failure.
>
> 1) The command I'm using *runCommand(string exe[, array args])* says in
> http://techbase.kde.org/Development/Tutorials/Plasma/JavaScript/API-LaunchAppthat it returns true on success and false on failure.  I know it returns
> false if I put a program there that doesn't exist.  If I made my program
> exist on sys.exit(1) (which to the commandline is a failed program) would
> that make this command false?  Then I could just use an if statement to
> change the button color.
>
> 2) Put a javascript function in my QML that calls my helper python
> script.  Then I can have it return 0 or 1.  And I can have the button
> change its color based on the output of the javascript.
>
> 3) Based on what I found here ( http://wiki.maemo.org/Quick_Widgets ),
> but have found little documentation elsewhere about, I could use the
> Process from the first example and then for onCompleted and onFailed, make
> THAT change the button.  Again, that would mean that sys.exit() anything
> but 0 should be onFailed, right?
>
> Any suggestions on which would easiest/most correct for the QML
> programming paradigm?  If it's #3, I am curious about how my button would
> call the process and evaluate the results.
>
> --
> Eric Mesa
> http://about.me/ericmesa
> http://www.ericsbinaryworld.com
>


None of those approaches worked for me.  Is there no way to get the python
helper program to be able to contribute data back to the QML plasmoid?  All
the data I want to communicate back is whether they succeeded or failed.
 That way I can communicate that back to the user.

Eric Mesa
http://about.me/ericmesa
http://www.ericsbinaryworld.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/plasma-devel/attachments/20120217/8172d258/attachment.html>


More information about the Plasma-devel mailing list