[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-panel-devel
Subject:    Re: can buttons know what happens to programs they launch?
From:       Eric Mesa <ericsbinaryworld () gmail ! com>
Date:       2012-02-13 14:45:51
Message-ID: CAKYHq8JAEgF8y8=5Y-gDkYLyS_5XmQ9SVpZH2XbZbV5Ey3fDfQ () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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
> 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

[Attachment #5 (text/html)]

<div class="gmail_quote">On Tue, Feb 7, 2012 at 3:12 PM, Hans Chen <span \
dir="ltr">&lt;<a href="mailto:hanswchen@gmail.com">hanswchen@gmail.com</a>&gt;</span> \
wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px \
#ccc solid;padding-left:1ex"> You may want to take a look at KProcess: <a \
href="http://api.kde.org/4.x-api/kdelibs-apidocs/kdecore/html/classKProcess.html" \
target="_blank">http://api.kde.org/4.x-api/kdelibs-apidocs/kdecore/html/classKProcess.html</a><br>
 For example, here&#39;s a Python plasmoid that uses it: <a \
href="http://kde-look.org/content/show.php/Redshift+plasmoid?content=148737" \
target="_blank">http://kde-look.org/content/show.php/Redshift+plasmoid?content=148737</a><br>
 </blockquote><div> </div></div>Took a look at that but I wasn&#39;t sure how to do \
that based on QML.  Here  are the ideas I&#39;ve come up with, I&#39;m not sure if \
they&#39;ll work.<br><br>Some of them involve my python helper program using \
sys.exit() with a 0 or 1 to denote success or failure.<br><br>1) The command I&#39;m \
using  <b>runCommand(string exe[, array args])</b>  says in 
<a href="http://techbase.kde.org/Development/Tutorials/Plasma/JavaScript/API-LaunchApp \
">http://techbase.kde.org/Development/Tutorials/Plasma/JavaScript/API-LaunchApp</a>  \
that it returns true on success and false on failure.  I know it  returns false if I \
put a program there that doesn&#39;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.<br><br>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.<br><br>3) Based on what I found here ( 
<a href="http://wiki.maemo.org/Quick_Widgets">http://wiki.maemo.org/Quick_Widgets</a> \
), 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?<br>
<br>
Any suggestions on which would easiest/most correct for the QML programming paradigm? \
If it&#39;s #3, I am curious about how my button would call the process and evaluate \
the results.<br clear="all">--<br>Eric Mesa<div> <a href="http://about.me/ericmesa" \
target="_blank">http://about.me/ericmesa</a><br><a \
href="http://www.ericsbinaryworld.com/" \
target="_blank">http://www.ericsbinaryworld.com</a></div>



_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic