PDA

View Full Version : Evolution calendar screenlet


ze_serge
May 12th, 2007, 12:04 PM
Hi everybody,

First, sorry for my english.

Screenlet is a really good app and allow me to have the same config i had with Windows and samurize (nobody's perfect...:oops:)
The only thing that miss me is to have my appointments and tasks on the desktop.

So, let's go coding for the first time.

Based on numerous helps and examples found on the web, I've finished a screenlet which display information from evolution calendar.
It is supposed to work with any ics compliant file (to be confirmed)
It's based on Icalendar module avalaible here http://codespeak.net/icalendar/.

I need some help for the following points:
. to have a background which automatically resize
. to be able to input the calendar file from the screenlet instead of writing it in the script file

As it is my first attempt, any remark regarding the poor code is more than welcome

If interest, i will mail the file

Waiting for comments...

Sorcerer
May 13th, 2007, 12:50 PM
Great! Any screenshots?

ze_serge
May 14th, 2007, 12:56 PM
Here it is:


http://img134.imageshack.us/img134/6756/shotyf9.jpg (http://imageshack.us)


calendar icon because i can't get a background which auto-resize

screenlet displays :
today's event (aujourd'hui) with hour or --- for all day event. Yearly event are also displayed

tomorrow's event (demain)

tasks (taches) with (!) for task already started but not in late and (!!!) for task in late

Sorcerer
May 14th, 2007, 02:34 PM
Very nice! Could you mail it to me (hendrik@kaju.pri.ee) or post it here (http://hendrik.kaju.pri.ee/screenlets)?

ze_serge
May 14th, 2007, 03:34 PM
File has been sent to your mail address.

naazgull
August 24th, 2007, 03:21 PM
Hi! I would have this screenlet. Please, post it at http://hendrik.kaju.pri.ee/screenlets

Thanks,

Cheers

nomego
August 26th, 2007, 05:02 PM
For an auto-resize background, you can calculate how much you need to scale the background:

ctx.save()
ctx.scale(self.scale * X, self.scale * Y)
self.theme.render(ctx, 'background')
ctx.restore()

Just remember to resize the window as well! Can't remember how you access it, maybe self.window.resize(w, h)

The input could be handled via the Screenlet options?

whise
August 27th, 2007, 02:53 AM
i would love something like this

kaince
August 27th, 2007, 03:12 PM
Hi,

Like everyone else, I would love the screenlet. Please post it on one of the Screenlets sites already mentioned or mail it to me at kaince at gmail.com.

Götz
September 10th, 2007, 12:59 AM
I would like it to! Is the screenlet finished? Or is somewhere any version of it?

Quattro
September 10th, 2007, 04:42 PM
i would like this one as well ^_^

Götz
September 20th, 2007, 10:16 PM
Any body knows where to download this screenlet? Because I woult like it a lot, since I only use evolution because of the calendar.
I dont know any other good calendar software.

badabing
September 24th, 2007, 12:21 AM
this looks interesting. what happened to it?

Götz
October 7th, 2007, 06:41 PM
It seems that the evolution calendar proyect is dead... :(

ze_serge
November 7th, 2007, 07:41 PM
Ooops !!!
it seems I missed some replies !
Sorry for that but I started a new job few months ago which is greatly time consuming.
As this screenlet does what I expect, I do not modify it but it must be improved.
I can't managed to load this screenlet on http://hendrik.kaju.pri.ee/screenlets neither as an attachment.
So here it is: 3 files, IcalendarScreenlet.py is the one to launch

IcalendarScreenlet.py:
#!/usr/bin/env python

import screenlets
import cairo
import pango
from ical_event import today, tomorrow
from ical_todo import todo
from screenlets import Screenlet
from screenlets.options import StringOption, FontOption, ColorOption, IntOption

class IcalendarScreenlet(Screenlet):
"""A simple example of how to create a Screenlet"""

# default meta-info for Screenlets
__name__ = 'Icalendar Screenlet'
__version__ = '0.00001'
__author__ = 'ze_serge'
__desc__ = 'First & last try to display calendar events on desktop'

# editable options
today_text = today
tomorrow_text = tomorrow
todo_text = todo
text_x = 0
text_y = 0
rgba_color = (0.0, 0.0, 0.0, 0.8)
text_font = "Purisa Medium 8"
title_font = "Purisa Medium 9"
today_txt = ""
tomorrow_txt = ""
today_title = "Aujourd'hui"
tomorrow_title = "Demain"
todo_title = "Taches"

def __setattr__(self, name, value):
screenlets.Screenlet.__setattr__(self, name, value)
if name in ('text_x', 'text_y', 'tomorrow_title', 'today_title', 'todo_title', 'text_font', 'title_font', 'rgba_color'):
if self.window:
self.redraw_canvas()

# constructor
def __init__(self, **keyword_args):
#call super
screenlets.Screenlet.__init__(self, width=300, height=400, **keyword_args)
# set theme
self.theme_name = "default"
# add default menu items
self.add_default_menuitems()
# add option group
self.add_options_group('Text Option', 'This is an example of editable' +\
' options within an options-group ...')
self.add_options_group('Title Option', 'This is an example of editable' +\
' options within an options-group ...')
# add editable option
self.add_option(FontOption('Text Option', 'text_font',
self.text_font, 'Text-Font', 'The font of the text (when no Markup is used) ...'))
self.add_option(FontOption('Text Option', 'title_font',
self.title_font, 'title-Font', 'The font of the title (when no Markup is used) ...'))
self.add_option(ColorOption('Text Option', 'rgba_color',
self.rgba_color, 'Text-Color', 'The color of the text (when no Markup is used) ...'))
self.add_option(IntOption('Text Option', 'text_x',
self.text_x, 'X-Position of Text',
'The X-Position of the text-rectangle\'s upper left corner ...',
min=0, max=100))
self.add_option(IntOption('Text Option', 'text_y',
self.text_y, 'Y-Position of Text',
'The Y-Position of the text-rectangle\'s upper left corner ...',
min=0, max=100))
self.add_option(StringOption('Title Option', 'today_title',
self.today_title, 'today_title',
'The text/Pango-Markup to be placed on the clock\'s face ...'))
self.add_option(StringOption('Title Option', 'tomorrow_title',
self.tomorrow_title, 'tomorrow_title',
'The text/Pango-Markup to be placed on the clock\'s face ...'))
self.add_option(StringOption('Title Option', 'todo_title',
self.todo_title, 'todo_title',
'The text/Pango-Markup to be placed on the clock\'s face ...'))

def on_draw(self, ctx):
# if theme is loaded
if self.theme:
# set scale rel. to scale-attribute
## ctx.scale(self.scale, self.scale)
# render svg-file
## self.theme['calendar.svg'].render_cairo(ctx)
p_layout = ctx.create_layout()
p_fdesc = pango.FontDescription()
p_fdesc.set_family_static("Free Sans")
p_fdesc.set_size(10 * pango.SCALE)
ctx.translate(self.text_x, self.text_y)
p_layout.set_font_description(p_fdesc)
p_layout.set_width(((self.width - self.text_x) * pango.SCALE))
om = '<span font_desc="'+self.text_font+'">'
omt = '<span font_desc="'+self.title_font+'">'
cm = '</span>'
title_1 = "<b>" + self.today_title + " :" + "</b>"
title_2 = "<b>" + self.tomorrow_title + " :" + "</b>"
title_3 = "<b>" + self.todo_title + " :" + "</b>"
for today_text in self.today_text :
today_txt = "<b>" + self.today_text + "</b>\n\n\n\n"
for tomorrow_text in self.tomorrow_text :
tomorrow_txt = "<b>" + self.tomorrow_text + "</b>\n\n\n\n"
for todo_text in self.todo_text :
todo_txt = "<b>" + self.todo_text + "</b>\n\n\n\n"
p_layout.set_markup(omt + title_1 + cm + om + today_txt + cm + omt + title_2 + cm + om + tomorrow_txt + cm + omt + title_3 + cm + om + todo_txt + cm)
ctx.set_source_rgba(self.rgba_color[0], self.rgba_color[1], self.rgba_color[2], self.rgba_color[3])
ctx.show_layout(p_layout)
ctx.fill()
ctx.save()
ctx.restore()

def on_draw_shape(self, ctx):
self.on_draw(ctx)

# If the program is run directly or passed as an argument to the python
# interpreter then create a Screenlet instance and show it
##if __name__ == "__main__":
## sl = screenlets.create_new_instance('IcalendarScreenlet ')
## sl.main()

# If the program is run directly or passed as an argument to the python
# interpreter then create a Screenlet instance and show it
if __name__ == "__main__":
# create new session
import screenlets.session
screenlets.session.create_session(IcalendarScreenl et)

ze_serge
November 7th, 2007, 07:41 PM
and th 2 others:

ical_event.py:
#!/usr/bin/python

# -*- coding: latin1 -*-

from icalendar import Calendar
from dateutil.tz import *; from datetime import *

cal = Calendar.from_string(open('/home/serge/.evolution/calendar/local/system/calendar.ics','r').read())
iDate = ''
first_event = ''
n = 0
_today = ""
_tomorrow = ""
hTime= " "
mTime = " "
h_letter = ""

##del alpha signs
def replace(x):
a=x.split('\n')
a.sort()
b= str(a)
c = b.replace("u'", '\n')
d = c.replace("',", "")
e = d.replace("[", "")
f= e.replace("']", "")
return f

### control date - return today
nowDate = str(datetime.now())
date1 = nowDate[:4]
date2 = nowDate[5:7]
date3 = nowDate[8:10]
part_controlDate = date2 + date3
controlDate = date1 + date2 + date3

def get_duDate(x):
eventDate = str(x)
eDate1 = eventDate[:4]
eDate2 = eventDate[4:6]
eDate3 = eventDate[6:8]
hTime = eventDate[9:11]
mTime = eventDate[11:13]
du_Date = eDate1 + eDate2 + eDate3
return du_Date

def get_hTime():
eventDate = str(iDate)
_hTime = eventDate[9:11]
return _hTime

def get_mTime():
eventDate = str(iDate)
_mTime = eventDate[11:13]
return _mTime

def get_part_duDate(y):
eventDate = str(y)
eDate2 = eventDate[4:6]
eDate3 = eventDate[6:8]
part_du_Date = eDate2 + eDate3
return part_du_Date

### total event in calendar
item = str(cal).count("BEGIN:VEVENT")

while item>n:
first_event = cal.walk('vevent')[n]
for event in first_event.walk('vevent'):
tempEvent = {}
tempEvent['dtstart'] = event.get('dtstart', '')
iDate = tempEvent.get('dtstart', '')
tempYearly = {}
tempYearly['rrule'] = event.get('rrule', '')
duYearly = tempYearly.get('rrule', '')
## is event yearly
if duYearly != "":
duDate = get_part_duDate(iDate)
h_letter = " "
else:
duDate = get_duDate(iDate)
hTime = get_hTime()
## is event all day
if hTime != "":
h_letter = "H"
hTime = get_hTime()
mTime = get_mTime()
else:
hTime = " "
mTime = " "
h_letter = " "
## is event today
if int(duDate) == int(controlDate) or int(duDate) == int(part_controlDate):
my_event_a = hTime + h_letter + mTime + " " + first_event['summary'][:75]
_today = _today + my_event_a + '\n'
##is event tomorrow
elif int(duDate) == (int(controlDate)+1) or int(duDate) == (int(part_controlDate)+1):
my_event_b = hTime + h_letter+ mTime + " " + first_event['summary'][:75]
_tomorrow = _tomorrow + my_event_b + '\n'
n = n+1
else:
today = replace(_today)
tomorrow = replace(_tomorrow)

----------------------------------------------------------------------------------------
ical_todo.py:
#!/usr/bin/python

from icalendar import Calendar
from dateutil.tz import *; from datetime import *

##del alpha signs
def replace(x):
a=x.split('\n')
a.sort()
b= str(a)
c = b.replace("u'", '\n')
d = c.replace("',", "")
e = d.replace("[", "")
f= e.replace("']", "")
return f

cal = Calendar.from_string(open('/home/serge/.evolution/tasks/local/1178099663.10940.4@Desktubuntu/tasks.ics','r').read())
iDate = ''
first_todo = ''
n = 0
_todo = ""

### control date - return today
nowDate = str(datetime.now())
date1 = nowDate[:4]
date2 = nowDate[5:7]
date3 = nowDate[8:10]
controlDate = date1 + date2 + date3

### total todo in calendar
item = str(cal).count("BEGIN:VTODO")

while item>n:
first_todo = cal.walk('vtodo')[n]
for todo in first_todo.walk('VTODO'):
temptodo = {}
temptodo['dtstart'] = todo.get('dtstart', '')
iDate = temptodo.get('dtstart', '')
todoDate = str(iDate)
sDate1 = todoDate[:4]
sDate2 = todoDate[4:6]
sDate3 = todoDate[6:8]
startDate = sDate1 + sDate2 + sDate3

tempcomplete = {}
tempcomplete['percent-complete'] = todo.get('percent-complete', '')
dupercent = tempcomplete.get('percent-complete', '')

tempdue = {}
tempdue['due'] = todo.get('due', '')
dutask = tempdue.get('due', '')
todoDate = str(dutask)
dDate1 = todoDate[:4]
dDate2 = todoDate[4:6]
dDate3 = todoDate[6:8]
duDate = dDate1 + dDate2 + dDate3

## is task finished
if dupercent != 100:
if int(startDate) >= int(controlDate) and int(startDate) <= (int(controlDate)+7):
my_todo = dDate3 + "/" + dDate2 + " " + first_todo['summary'][:75]
_todo = _todo + my_todo + '\n'

if int(startDate) < int(controlDate) and int(duDate) > int(controlDate):
my_todo = dDate3 + "/" + dDate2 + " " + first_todo['summary'][:75]
_todo = _todo + my_todo + ' (!)' + '\n'

if int(startDate) < int(controlDate) and int(duDate) < int(controlDate) :
my_todo = dDate3 + "/" + dDate2 + " " + first_todo['summary'][:75]
_todo = _todo + my_todo + ' (!!!)' + '\n'






n = n+1
else:
todo = replace(_todo)

fabs
November 7th, 2007, 08:58 PM
maybe you should try to upload the screenlet to http://www.screenlets.org/index.php/Category:UserScreenlets

whise
November 8th, 2007, 01:34 AM
gnome look ofers free uploads , you cant host any files on screenlets.org