From kde-panel-devel Fri Feb 17 05:21:11 2012 From: Eric Mesa Date: Fri, 17 Feb 2012 05:21:11 +0000 To: kde-panel-devel Subject: Re: can buttons know what happens to programs they launch? Message-Id: X-MARC-Message: https://marc.info/?l=kde-panel-devel&m=132945610515728 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--===============3473543002959488381==" --===============3473543002959488381== Content-Type: multipart/alternative; boundary=047d7b2ed887e071af04b9221c4e --047d7b2ed887e071af04b9221c4e Content-Type: text/plain; charset=ISO-8859-1 On Mon, Feb 13, 2012 at 9:45 AM, Eric Mesa wrote: > On Tue, Feb 7, 2012 at 3:12 PM, Hans Chen 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 --047d7b2ed887e071af04b9221c4e Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
On Mon, Feb 13, 2012 at 9:45 AM, Eric Mesa <ericsbinaryw= orld@gmail.com> wrote:
On Tue, Feb 7, 2012 at 3:12 PM= , Hans Chen <hanswchen@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<= br> For example, here's a Python plasmoid that uses it: http://kde-look.org/content/show.php/Redshift+plasmoid?content=3D14= 8737
=A0
Took a look at that but I wasn't= sure how to do that based on QML.=A0 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=20 http://techbase.kde.org/Development/Tutori= als/Plasma/JavaScript/API-LaunchApp that it returns true on success and false on failure.=A0 I know it=20 returns false if I put a program there that doesn't exist.=A0 If I made= my program exist on sys.exit(1) (which to the commandline is a failed=20 program) would that make this command false?=A0 Then I could just use an if= statement to change the button color.

2) Put a javascript=20 function in my QML that calls my helper python script.=A0 Then I can have= =20 it return 0 or 1.=A0 And I can have the button change its color based on=20 the output of the javascript.

3) Based on what I found here (=20 http://wi= ki.maemo.org/Quick_Widgets ), but have found little=20 documentation elsewhere about, I could use the Process from the first examp= le and=20 then for onCompleted and onFailed, make THAT change the button.=A0 Again,= =20 that would mean that sys.exit() anything but 0 should be onFailed,=20 right?

Any suggestions on which would easiest/most correct for the QML programming= paradigm?=A0 If it's #3, I am curious about how my button would call t= he process and evaluate the results.


None of those approa= ches worked for me. =A0Is there no way to get the python helper program to = be able to contribute data back to the QML plasmoid? =A0All the data I want= to communicate back is whether they succeeded or failed. =A0That way I can= communicate that back to the user.

Eric Mesa=
--047d7b2ed887e071af04b9221c4e-- --===============3473543002959488381== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Plasma-devel mailing list Plasma-devel@kde.org https://mail.kde.org/mailman/listinfo/plasma-devel --===============3473543002959488381==--