Home Forums Wiki Doc Install Extras Screenshots Source Code Projects Blog Users Groups Register
Glx-Dock / Cairo-Dock List of forums Applets | Applets My Python Applets ceased to work when I upgraded.
The latest stable release is the *3.4.0* : How to install it here.
Note: We just switched from BZR to Git on Github! (only to host the code and your future pull requests)
Applets | Applets

Subjects Author Language Messages Last message
[Locked] My Python Applets ceased to work when I upgraded.
rozen English 5 SQP [Read]
17 February 2014 à 15:50

rozen, Monday 10 February 2014 à 04:30

Subscription date : 20 December 2009
Messages : 19
    • The version of Cairo-Dock ('cairo-dock -v' in a terminal). 3.3.99.beta1
    • Your GNU/Linux distribution (Debian, Ubuntu, Fedora, etc.). Mint 16
    • Or you using OpenGL or not. Yes
    • Your Window manager (Compiz, Metacity, Kwin, Openbox, etc.). ?
    • Your Desktop Environment (Gnome, KDE, XFCE, etc.). XFCE


I just upgraded my linux system from Mint 15 to Mint 16. My problem is that several crucial applets that I wrote in Python no longer work. The include a date applet, a clock, and a network monitor. They all are meant to be updated periodically, usually every second.

My applets appear in a separate dock located at the right edge of my screen. When I start the applets they appear, that is the correct initial values but they never seem to be updated. I use Python threading to recreated the the icons periodically and I use the dbus ReloadIcon to update the icon. Let me emphasize that the applets seemed to work fine before I updated my system which also updated the version of cairo-dock. I don't remember the version, it may have been 3.2.99. I am including the clock applet since it is the smallest one:

#!/usr/bin/env python
# -*- python -*-
# Time-stamp: <2014-02-09 18:45:55 rozen>

# This is my version of a clock.

print "dprClock starting."

import os
import sys
import shutil
import time
import threading

import os
import sys
import copy
import Image
import math
from datetime import datetime

from CDApplet import CDApplet
from CairoDock import CairoDock

"dbus-send --session --dest=org.cairodock.CairoDock /org/cairodock/CairoDock org.cairodock.CairoDock.ReloadIcon string:\"config-file=dprClock.conf\""

restart_command " dbus-send --session --dest=org.cairodock.CairoDock /org/cairodock/CairoDock org.cairodock.CairoDock.ReloadModule string:dprClock # new icon -> reload (only the icon is reloaded)"

class dprClock(CDApplet):
def __init__(self):
#self.f = open("/home/rozen/clocklog", "w")
        #print >> self.f, "*** dprClock init starting."
CDApplet.__init__(self)      # call high-level init
self.duration # sleep duration.
self.die = 0
.dialog_active_time 30   # time in seconds that the dialog window
                                       # will be active
self.clock_image Image.new('RGB', (6464), (100149237))
self.dbus CairoDock().iface

    def begin
"*** begin function: dprClock."

def end(self):
"*** end function: dprClock"
self.die = 1

    def update
#print "*** update function: dprClock."

def restart(self):
"*** restart function: dprClock"

def update_clock(self):
        print >> 
self.f"*** update clock: dprClock"
clock_template =self.clock_template.copy()
draw ImageDraw.Draw(clock_template)
center 32
# Put in the time
time datetime.time(datetime.now())
hr time.hour 12

# hours
hr_degrees hr * (360 12)
min_degrees min 0.5       # (360/12) / 60
hr_degrees += min_degrees
#psi = hr * (math.pi / 6.0)
        #psi += min * (math.pi / 360)

hdx math.floor(math.sin(psi) * 26 0.45)
hdy math.floor(-math.cos(psi) * 26 0.45)
hr_box = (centercentercenter+hdxcenter+hdy# box for hour hand.
        #draw.line( hr_box, width=4, fill= 'black')    # draw hour hand.
draw.linehr_boxwidth=4fill'white')  # draw hour hand.

        # minutes
psi min * (math.pi 30.0)
#psi += sec * (M_PI / 1800)
mdx math.floor(math.sin(psi) * 26 0.8)
mdy math.floor(-math.cos(psi) * 26 0.8)
min_box = (centercentercenter+mdxcenter+mdy# box for minute hand.
        #draw.line( min_box, width=3, fill='black') # draw minute hand.
draw.linemin_boxwidth=3fill='white'# draw minute hand.

        # seconds
psi sec * (math.pi 30.0)
sdx math.floor(math.sin(psi) * 26 0.9)
sdy math.floor(-math.cos(psi) * 26 0.9)
sec_box = (centercentercenter+sdxcenter+sdy# box for second hand.
draw.linesec_boxwidth=2fill 'cyan'# draw second hand.

        # save the icon
fn os.path.expanduser('icon')
# Put icon on screen
self.dbus.ReloadIcon('config-file=dprClock.conf')   # Just give it a try

def create_template(self):
''' Create clock template with dots for hour markers.  Done
        once in __init__'''
# Create clack face.
clock_template Image.new('RGB', (6464), '#b22222'# Firebruck
draw ImageDraw.Draw(clock_template)
center 32
# Do background with dots for the hours.
for spot in range(0605):
psi spot * (math.pi 30.0)
spot_x math.floor(math.sin(psi) * 27) + 34
math.floor(-math.cos(psi) * 27) + 34
if ((spot 15) == 0):
# 0/15/30/45 - big spots
spot_x -= 3
-= 3
# everything else - small spots
spot_x -= 1
-= 1
= (spot_x-deltaspot_y-deltaspot_x+deltaspot_y+delta)
draw.ellipse(boxfill 'yellow')

self.clock_template clock_template.copy()

def update_timer(cduration):
'''This is the timer thread.'''
while 1:
        print >> 
c.f"timer loop"
c.die: return

def main():

if __name__ == '__main__':

I seem to remember that in the past debugging print statements wrote to .xsession-errors. But that does not seem to be the case currently. Is there an easy way to capture my debugging messages. I tried running cairo-dock in a terminal but that was not very satisfactory and I didn't learn much.

Any suggestions would be very much appreciated,

Thanks in Advance,

fabounet, Monday 10 February 2014 à 13:59

Subscription date : 30 November 2007
Messages : 17118
first, an applet doesn't need to access the dock directly
if you want to update your applet periodically, use a timer (for instance, use the timeout_add function from glib)

second, ReloadIcon and ReloadModule don't exist anymore; there is an unique Reload method
the Dock API has changed to be easier and more powerful, and you can find the info on the wiki

SQP, Monday 10 February 2014 à 20:03

Subscription date : 03 July 2010
Messages : 1081
fabounet :
the Dock API has changed to be easier and more powerful, and you can find the info on the wiki :)

since you talk about that, I miss the old ActivateModule command. Add+Remove are too complicated for such a simple operation. It's needed to work easier on external applets.

Guest, Tuesday 11 February 2014 à 05:55


I was not able to get Reload to do update the Icon but self.icon.SetIcon(...) seemed to work.

I was not able to get the timeout_add function from glib work but pythons time.sleep(1) seemed to work.

Now I can't get any response in on_click() function. The icon enlarges and rotates but I don't seem to get into the on_click function.

Thanks for your responses,


fabounet, Monday 17 February 2014 à 13:55

Subscription date : 30 November 2007
Messages : 17118
I think that using sleep is not that good, because meanwhile your applet doesn't respond to events from the dock.

so using a glib timeout seems a better approach (and I think you can find some examples in our third-party applets)

@SQP: well, you can still define a wrapper around those functions, personnaly I like having a unified API
(but I agree with you that you need the wiki to know the syntax, that's the drawback)

SQP, Monday 17 February 2014 à 15:50

Subscription date : 03 July 2010
Messages : 1081
of course I wrapped it, how the fuck can you work on external applets without that? It's the command I use the most.

but even if that sound more "unified", this method is still really needed. I don't know how to do it from bash, nor should I have to use complex arguments to do that. (find location of conf file??)

I need this ActivateModule or some sort of RebootModule method to really unload and reload external applets.

(and since I'm forced to do the "remove/add" method, I regularly have a violent dock crash with "glist: double list corrupted")

Applets | Applets

Subjects Author Language Messages Last message
[Locked] My Python Applets ceased to work when I upgraded.
rozen English 5 SQP [Read]
17 February 2014 à 15:50

Glx-Dock / Cairo-Dock List of forums Applets | Applets My Python Applets ceased to work when I upgraded. Top

Online users :

Powered by ElementSpeak © 2007 Adrien Pilleboue, 2009-2013 Matthieu Baerts.
Dock based on CSS Dock Menu (Ndesign) with jQuery. Icons by zgegball
Cairo-Dock is a free software under GNU-GPL3 licence. First stable version created by Fabounet.
Many thanks to TuxFamily for the web Hosting and Mav for the domain name.