Python + DCOP = Cheap Public Relations

So i was mucking with dcop some tonight and playing with the new python bindings. The new bindings are much faster and are self contained so you can use them from PyGTK or PyQt. So I was hacking some and came up with a trival app that I was able to drag and drop almost directly from KDCOP.

import pcop
import dcop

m_KWeatherServiceWeatherService = dcop.DCOPObject( "KWeatherService","WeatherService")
replyQStringList = m_KWeatherServiceWeatherService.listStations()

for stationID in replyQStringList:
        date =
        name = m_KWeatherServiceWeatherService.stationName(stationID)
        temp = m_KWeatherServiceWeatherService.temperature(stationID)
        report = name + " " + temp + " at " + date
        print report

This simple app will then output:

Bremerton National Automatic Weather Observing / Reporting System 18°C at Wednesday 06 August 2003 11:55 pm
Pottstown, Pottstown Limerick Airport 22°C at Wednesday 06 August 2003 11:54 pm
Philadelphia, Northeast Philadelphia Airport 22°C at Thursday 07 August 2003 12:54 am
Milwaukee, General Mitchell International Airport 21°C at Wednesday 06 August 2003 11:52 pm
Longview, Gregg County Airport 29°C at Wednesday 06 August 2003 11:53 pm

Now this was cool for about 5 minutes of work... Now to see what I can do with Kate and the Python KScriptEngine....


There must be a way to use the interfaces of non-Kuniqueapplication/applets well. Currently, they have appname-SOMENUMBER_HERE, which makes it hard to use dcop :(

By KDE User at Thu, 08/07/2003 - 14:55

dcopfind and dcopstart will both give you the unique id. These are needed because of the situations that arrise when one has more than one instance of an application open. Say I have 3 KWords open, and I chose to create a new document and clear the old one. Which one gets hit? Is it the correct one? In these instances its usually easier to use dcopstart to get a fresh one going and then work on it from dcop.

Thinks like KScriptInterface also provide the Application ID to scripts so its easy to find.

Does that make sense?

By Ian Reinhart Geiser at Thu, 08/07/2003 - 15:17