can buttons know what happens to programs they launch?

Eric Mesa ericsbinaryworld at gmail.com
Mon Feb 13 14:45:51 UTC 2012


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/plasma-devel/attachments/20120213/589a266d/attachment.html>


More information about the Plasma-devel mailing list