#1 Le 01/05/2007, à 00:55
- obelix
Appel à contribution pour l'adesklet weatherforecast
Bonsoir tout le monde, 1h50 du matin et je viens de découvrir python et les adesklets
J'ai essaye weatherforecast mais il me convenait pas parfaitement. En tant que développeur je mets naturellement les mains dedans, découvre le python et arrange le tout à ma sauce :
- ajout d'un paramètre pour le langage : francais et allemand pour le moment avec un fichier de traduction i18n xml
- ajout d'un paramètre pour afficher ou non le Feels Like (FL)
cependant j'ai besoin d'une dernière aide avant de proposer cela à l'auteur de weatherforecast et la communauté.
Il me faudrait la traduction en Français des Weather Condition Codes dispo sur http://developer.yahoo.com/weather/#codes
Malheureusement je ne suis pas très doué pour faire le beau temps et la pluie !
Merci de votre aide
PS : si vous avez des traductions dans d'autres langues merci de me les faire parvenir
PS2 : si vous avez d'autres idées simples d'maéliorations merci de me les faire parvenir
Obélix
Hors ligne
#2 Le 01/05/2007, à 03:19
- Psionic
Re : Appel à contribution pour l'adesklet weatherforecast
Si tu aime les p'tits gadgets sur bureau tente Screenlets à la place de adeskle.
C'est ce que j'ai trouvé de plus beau actuellement.
Hors ligne
#3 Le 01/05/2007, à 10:30
- obelix
Re : Appel à contribution pour l'adesklet weatherforecast
merci mais les screenlets ne proposent pas la mété, pas le diaporama de photos.
cependant ils ont l'air d'etre plus jolie !
Hors ligne
#4 Le 01/05/2007, à 15:41
- Psionic
Re : Appel à contribution pour l'adesklet weatherforecast
merci mais les screenlets ne proposent pas la mété, pas le diaporama de photos.
cependant ils ont l'air d'etre plus jolie !
Les screenlets proposent la météo et même plus
http://hendrik.kaju.pri.ee/screenlets/
Il ne leur manque que le diaporama mais il existe deja un simple cadre pour image.
ya même un visualisateur de pochette cd compatible Amarok-exaile-banshee-rythmbox-... et j'en oublie
Perso je trouve que ce projet mérite qu'on s'y attarde.
Dernière modification par Psionic (Le 01/05/2007, à 15:47)
Hors ligne
#5 Le 01/05/2007, à 16:07
- obelix
Re : Appel à contribution pour l'adesklet weatherforecast
arf ok je viens de tester...
pour le meme resultat (pratique et estetique) la météo scrennlets prend 15Mo alors que l'adeklet prend 4Mo
de plus il faut activer compiz pour avoir la transparence et il prend pas mal de ressource
cependant je pourrais proposer l'internationalisation pour le scrennlet... si j'arrive à traduire les termes...
desole mais pas convaincu
ce que j'ai besoin c'est :
- meteo
- diaporama
Dernière modification par obelix (Le 01/05/2007, à 16:08)
Hors ligne
#6 Le 01/05/2007, à 16:56
- Psionic
Re : Appel à contribution pour l'adesklet weatherforecast
C'est vrai que niveau ressource screenlets prend effectivement plus (quoiqu'on a vu pire) et nécessite beryl/compiz mais sa personnalisation est hors normes. J'ai pu modifier les thèmes grace a inkscape et ce le plus facilement du monde.
Perso j'attend que quelqu'un fasse un petit screenlets diaporama et mon bonheur serait complet.
(Et si en plus quelqu'un trouvait le moyen de modifier le comic-screenlet pour y ajouter ses propres adresses.)
Hors ligne
#7 Le 01/05/2007, à 17:00
- obelix
Re : Appel à contribution pour l'adesklet weatherforecast
je te comprends... c'est vrai que c'est beau et mieux configurable mais je suis pas un fan du design...
je prefere le fonctionnelle avec le juste ce qu'il me faut
bref chacun ses besoins
Hors ligne
#8 Le 01/05/2007, à 17:09
- Romagination
Re : Appel à contribution pour l'adesklet weatherforecast
J'ai commencé la traduction mais c'est chaud d'autant que l'anglais a un vocabulaire beaucoup plus étoffé que le français pour la météo (quinze façon de désigner ce qu'on appelle ici du brouillard et le tout à l'avenant!)
Hors ligne
#9 Le 01/05/2007, à 17:16
- obelix
Re : Appel à contribution pour l'adesklet weatherforecast
arf merci de ton aide... fait ce que tu peux, j'avance aussi et j'ai demandé de l'aide aux traducteurs francophone d'ubuntu
on devrait s'en sortir à nous tous... une fois en français je pourrais rajouter "facilement" l'allemand !
merci de ton aide !
Hors ligne
#10 Le 01/05/2007, à 17:21
- Romagination
Re : Appel à contribution pour l'adesklet weatherforecast
Ca sera surement pas fait ce soir, ma femme veut aller voir Spiderman 3 lol mais j'espère ne pas arriver après la bataille.
Hors ligne
#11 Le 01/05/2007, à 17:32
- obelix
Re : Appel à contribution pour l'adesklet weatherforecast
pas de souci l'ami ! tu me diras si le film est bien
Hors ligne
#12 Le 02/05/2007, à 04:47
- madmax
Re : Appel à contribution pour l'adesklet weatherforecast
Pour weatherforecast:
J'ai fait la traduction et ça marche très bien. Tu n'as qu'a copier ce qui suit à la place du contenu de ton weatherforecast.py et redemarrer les adesklets. Tu fait ton copier/coller à partir du #! /usr/bin/env python
Si tu veux modifier la traduction va à la ligne 219. Tu peux aussi rajouter des lignes.
J'ai utilisé cette méthode pour traduire le adesklet mais il y a surement une meilleur methode.
Je ne suis pas programmeur et j'ai donc utilisé le fichier weatherforecast.py de quelqu'un qui avait commencé à le traduire et je l'ai amélioré.
J'espère que ça pourra te servir.
#! /usr/bin/env python
# -*- coding: latin-1 -*-
import os, sys
"""
--------------------------------------------------------------------------------
Dmitry Goykolov <jeepston@mail.zp.ua>
Based on the weather desklet by Sylvain Fourmanoit <syfou@users.sourceforge.net>
and iWeather gDesklet by Michael Favia <garbage@insitesinc.com>
Copyright (C) Superkaramba's Liquid Weather ++ team
for ALL the artwork (icons + background)
The maintainer (also the main author I believe)
is Matthew <dmbkiwi@yahoo.com>
Released under the GPL, version 2. Except the artwork, which is released
pursuant to the restrictions imposed by their authors.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies of the Software and its documentation and acknowledgment shall be
given in the documentation and software packages that this Software was
used.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
See COPYING file for details
--------------------------------------------------------------------------------
"""
#-------------------------------------------------------------------------------
import adesklets
import urllib
import re
import xmltramp
from time import time
from os import getenv, system
from os.path import join, dirname
#-------------------------------------------------------------------------------
class Config(adesklets.ConfigFile):
"""
This is weatherforecast.py desklet configuration file; for each desklet,
you only have to write down the minimal delay between updates
(in seconds: less than 300 will be ignored),
the location code from www.weather.com and specify True or False for
metric, depending if you want temperature given in Celcius or in
Fahrenheits.
"""
cfg_default = { 'location' : 'USKY1079',
'metric':True,
'delay':1800,
'theme':'weather.com',
'show_current_conditions':True,
'show_forecast':True,
'show_big_icon':True,
'location_font_size':10,
'small_font_size': 10,
'location_color':'AAAAAAFF',
'cc_color':'AAAAAAFF',
'forecast_color':'AAAAAAFF',
'time_format':12,
'bg':False}
def __init__(self,id,filename):
adesklets.ConfigFile.__init__(self,id,filename)
def color(self,string):
colors = [eval('0x%s' % string[i*2:i*2+2]) for i in range(len(string)/2)]
if (len(colors) != 4): colors += [255]
return colors
#-------------------------------------------------------------------------------
class Events(adesklets.Events_handler):
def __init__(self, basedir):
if len(basedir)==0:
self.basedir='.'
else:
self.basedir=basedir
self.w = None
self.buffer= None
self.id= None
self.delay=None
adesklets.Events_handler.__init__(self)
def __del__(self):
adesklets.Events_handler.__del__(self)
def ready(self):
# Real initialisation take place here
self.config=Config(adesklets.get_id(),
join(self.basedir,'config.txt'))
self.delay=self.config['delay']
if self.delay<300:
self.delay=300
self.units=self.config['metric']
self.show_cc=self.config['show_current_conditions']
self.show_forecast=self.config['show_forecast']
self.show_icon=self.config['show_big_icon']
if self.units:
self.unit_sys='m'
else:
self.unit_sys='s'
self.buffer=adesklets.create_image(525,130)
self.theme=self.config['theme']
self.location_color=self.config.color(self.config['location_color'])
self.cc_color=self.config.color(self.config['cc_color'])
self.forecast_color=self.config.color(self.config['forecast_color'])
# Set the window property
self.window_w=0
if self.show_icon: self.window_w=120
if self.show_cc: self.window_w=140
if self.show_forecast: self.window_w=240
if self.show_icon and self.show_cc: self.window_w=260
if self.show_icon and self.show_forecast: self.window_w=360
if self.show_cc and self.show_forecast: self.window_w=380
if self.show_icon and self.show_cc and self.show_forecast: self.window_w=525
adesklets.window_resize(self.window_w,130)
adesklets.window_set_transparency(True)
adesklets.menu_add_separator()
adesklets.menu_add_item('Configure')
adesklets.window_show()
def alarm(self):
self.block()
self._display()
self.unblock()
# One second adjustment to make sure everything will be fine
return self.config['delay']+1
def menu_fire(self, delayed, menu_id, item):
if item=='Configure':
editor=getenv('EDITOR')
if editor:
system('xterm -e %s %s/config.txt &' % (editor, self.basedir))
def _display(self):
# As you may have guessed, this is the main drawing routine
# Reset the whole buffer image in transparent black
adesklets.context_set_image(self.buffer)
adesklets.context_set_color(0,0,0,0)
adesklets.context_set_blend(False)
adesklets.image_fill_rectangle(0,0,self.window_w,130)
adesklets.context_set_blend(True)
# Draw the background
if self.config['bg']:
self.background=""
if self.window_w==260:
self.background='%s/icons/bg.png' % self.basedir
if self.window_w==360:
self.background='%s/icons/bg-360.png' % self.basedir
if self.window_w==380:
self.background='%s/icons/bg-380.png' % self.basedir
if self.window_w==500:
self.background='%s/icons/bg-500.png' % self.basedir
if self.background != "":
image=adesklets.load_image(self.background)
adesklets.blend_image_onto_image(image,1,0,0,self.window_w,130,60,0,self.window_w,130)
adesklets.free_image(image)
# Getting the XML file from weather.com
self.connection=True
try:
self.w = xmltramp.load('http://xoap.weather.com/weather/local/%s?prod=xoap&par=1003832479&key=bb12936706a2d601&cc=*&dayf=3&unit=%s' % (str(self.config['location']), self.unit_sys))
except:
self.connection=False
adesklets.context_set_color(255,0,0,255)
adesklets.context_set_font(adesklets.load_font('VeraBd/12'))
adesklets.text_draw(0,0,'Weatherforecast: No internet connection')
adesklets.free_font(0)
# Draw the weather icon
if self.show_icon and self.connection:
try:
icon=str(self.w['cc']['icon'])
except (KeyError, ValueError, TypeError):
icon='na'
if (icon=="-"):
icon='na'
image=adesklets.load_image("%s/icons/%s/%s.png" % (self.basedir, self.theme, icon))
adesklets.blend_image_onto_image(image,1,0,0,120,120,0,0,120,120)
adesklets.free_image(image)
# Getting and printing out current conditions
if self.show_cc and self.connection:
# Get the location's name
try:
location=str(self.w.loc.dnam).split(',')[0]
except (KeyError, ValueError):
location='Unknown'
# Get the conditions
try:
conditions=str(self.w.cc.t)
if conditions=='Clear': conditions='Dégagé'
if conditions=='Light Rain Shower': conditions='Faible pluie'
if conditions=='Light Drizzle': conditions='Faible bruine'
if conditions=='Light Freezing Drizzle': conditions='Faible bruine verglaçante'
if conditions=='Light Rain': conditions='Faible pluie'
if conditions=='Light Rain Shower and Windy': conditions='Faibles averses et vent'
if conditions=='Light Rain and Windy': conditions='Faible pluie et vent'
if conditions=='Light Snow and Windy': conditions='Faible neige et vent'
if conditions=='Snow and Windy': conditions='Neige et vent'
if conditions=='Light Snow Shower': conditions='Faibles averses de neige'
if conditions=='Light Snow': conditions='Faible neige'
if conditions=='Light Snow and Sleet': conditions='Faible neige et verglas'
if conditions=='Blowing Snow': conditions='Rafales de neige'
if conditions=='Drifting Snow': conditions='Rafales de neige'
if conditions=='Drifting Snow and Windy': conditions='Rafales de neige et vent'
if conditions=='Blowing Snow and Windy': conditions='Rafales de neige et vent'
if conditions=='Rain': conditions='Pluie'
if conditions=='Fair': conditions='Beau temps'
if conditions=='Showers in the Vicinity': conditions='Averses aux alentours'
if conditions=='Fog': conditions='Brouillard'
if conditions=='Sunny': conditions='Ensoleillé'
if conditions=='Cloudy': conditions='Nuageux'
if conditions=='Cloudy and Windy': conditions='Nuageux et venteux'
if conditions=='Mostly Cloudy': conditions='Plutôt nuageux'
if conditions=='Partly Cloudy': conditions='Passages nuageux'
if conditions=='Partly Cloudy and Windy': conditions='Passages nuageux, Vent'
if conditions=='Mostly Cloudy and Windy': conditions='Plutôt nuageux, Vent'
except (KeyError, ValueError):
conditions='N/A'
# Get the temperature
try:
tmp=str(self.w.cc.tmp)
unit=' ' + str(self.w.head.ut)
except (KeyError, ValueError):
tmp='N/A'
if tmp=='N/A': unit=''
# Get the Feals like temp
try:
flik=str(self.w.cc.flik)
unit=' ' + str(self.w.head.ut)
except (KeyError, ValueError):
flik='N/A'
if flik=='N/A': unit=''
# Determine vertical text position from text width
#
if self.show_icon:
text_x=120 #width of the icon
else:
text_x=0
# Draw all text strings: location, conditions and temperatures
#
adesklets.context_set_color(*self.location_color)
adesklets.context_set_font(adesklets.load_font('Vera/%d' % self.config['location_font_size']))
adesklets.text_draw(text_x,20,location)
self.loc_size=self._get_str_width(location)
adesklets.free_font(0)
adesklets.context_set_font(adesklets.load_font('Vera/%d' % self.config['small_font_size']))
adesklets.context_set_color(*self.cc_color)
adesklets.text_draw(text_x,45,conditions)
self.cond_size=self._get_str_width(conditions)
adesklets.text_draw(text_x,65, tmp + unit)
#adesklets.text_draw(text_x,85, "FL: "+flik + unit)
adesklets.free_font(0)
self.f_x=max(self.loc_size,self.cond_size)
if self.show_forecast and self.connection:
# Extracting and printing out forecast
forecastTHi=[0,0,0]
forecastTLo=[0,0,0]
forecastSunrise=[0,0,0]
forecastSunset=[0,0,0]
forecastDay=[0,0,0]
forecastDayIcon=[0,0,0]
forecastNightIcon=[0,0,0]
counter=0
for forecast in self.w.dayf["day":]:
forecastTHi[counter]=str(forecast.hi)+str(self.w.head.ut)
forecastTHi[counter]=str(forecast.hi)+str(self.w.head.ut)
forecastTLo[counter]=str(forecast.low)+str(self.w.head.ut)
if forecastTHi[counter]=="N/AC": forecastTHi[counter]="N/A"
if forecastTLo[counter]=="N/AC": forecastTLo[counter]="N/A"
if forecastTHi[counter]=="N/AF": forecastTHi[counter]="N/A"
if forecastTLo[counter]=="N/AF": forecastTLo[counter]="N/A"
forecastSunrise[counter]=str(forecast.sunr)[:-3]
forecastSunset[counter]=str(forecast.suns)[:-3]
forecastDay[counter]=str(forecast("t"))
if forecastDay[counter]=="Monday": forecastDay[counter]= "Lundi"
if forecastDay[counter]=="Tuesday": forecastDay[counter]= "Mardi"
if forecastDay[counter]=="Wednesday": forecastDay[counter]= "Mercredi"
if forecastDay[counter]=="Thursday": forecastDay[counter]= "Jeudi"
if forecastDay[counter]=="Friday": forecastDay[counter]= "Vendredi"
if forecastDay[counter]=="Saturday": forecastDay[counter]= "Samedi"
if forecastDay[counter]=="Sunday": forecastDay[counter]= "Dimanche"
for dayparts in forecast['part':]:
if dayparts("p")=="d":
forecastDayIcon[counter]= str(dayparts.icon)
else:
forecastNightIcon[counter]=str(dayparts.icon)
#Output of the forecast
icon_width=28
icon_offset=8
if not self.show_cc and not self.show_icon: forecast_x=0
if not self.show_cc and self.show_icon: forecast_x=120
if self.show_cc and not self.show_icon: forecast_x=self.f_x+10
if self.show_cc and self.show_icon: forecast_x=120+self.f_x+10
forecast_x=forecast_x+85*counter
adesklets.context_set_font(adesklets.load_font('Vera/10'))
adesklets.context_set_color(*self.forecast_color)
image=adesklets.load_image("%s/icons/%s/%s.png" % (self.basedir, self.theme, forecastDayIcon[counter]))
adesklets.blend_image_onto_image(image,1,0,0,120,120,forecast_x,40,28,28)
adesklets.free_image(image)
image=adesklets.load_image("%s/icons/%s/%s.png" % (self.basedir, self.theme, forecastNightIcon[counter]))
adesklets.blend_image_onto_image(image,1,0,0,120,120,forecast_x+icon_offset+icon_width,40,28,28)
adesklets.free_image(image)
day_x=forecast_x+(2*icon_width+icon_offset)/2-self._get_str_width(forecastDay[counter])/2
adesklets.text_draw(day_x,20,forecastDay[counter])
t_hi_x=forecast_x+icon_width/2-self._get_str_width(forecastTHi[counter])/2
adesklets.text_draw(t_hi_x,68,forecastTHi[counter])
t_lo_x=forecast_x+icon_width+icon_offset+icon_width/2-self._get_str_width(forecastTLo[counter])/2
adesklets.text_draw(t_lo_x,68,forecastTLo[counter])
sunrise_x=forecast_x+icon_width/2-self._get_str_width(forecastSunrise[counter])/2
adesklets.text_draw(sunrise_x,85,forecastSunrise[counter])
sunset_hour=int(forecastSunset[counter][0])
if self.config['time_format']==24:
sunset_hour=sunset_hour+12
ss_h="%s%s" % (str(sunset_hour), forecastSunset[counter][1:])
sunset_x=forecast_x+icon_width+icon_offset+icon_width/2-self._get_str_width(ss_h)/2
adesklets.text_draw(sunset_x,85,ss_h)
adesklets.free_font(0)
counter=counter+1
# Copy everything from the buffer image to the real foreground image
adesklets.context_set_image(0)
adesklets.context_set_blend(False)
adesklets.blend_image_onto_image(self.buffer,1,0,0,self.window_w,130,0,0,self.window_w,130)
adesklets.context_set_blend(True)
system('rm -rf *.pyc')
def _get_str_width(self,text):
width, height = adesklets.get_text_size(text)
return width
#-------------------------------------------------------------------------------
Events(dirname(__file__)).pause()
Hors ligne
#13 Le 02/05/2007, à 08:06
- obelix
Re : Appel à contribution pour l'adesklet weatherforecast
ah j'ai du mal m'exprime... j'ai dejà fait le code qui va bien pour utiliser un fichier xml de traduction configurable via le fichier config.txt pour choisir french, deutsch, etc.
merci de ton aide, je vais reprendre la traduction et la compléter par une version allemande
le tout sera proposé à l'auteur...
avant cela il me faudra un beta testeur
merci de ton aide rapide !
Hors ligne
#14 Le 02/05/2007, à 10:05
- obelix
Re : Appel à contribution pour l'adesklet weatherforecast
tes traductions ne correspondent pas aux "codes conventions"...
comme j'ai pas trouvé la liste des mots que weatherforecast utilise j'ai pensé aux codes conventions qui sont utiles pour trouve l'icone du temps
maintenant, je pense que ta liste est suffisante mais pas complete (tornado, etc)
en tout cas cela m'aide dèjà beaucoup, alors merci
Hors ligne
#15 Le 02/05/2007, à 10:06
- obelix
Re : Appel à contribution pour l'adesklet weatherforecast
soit il faut trouver la liste complète des mots utilisés par weatherforecast
soit il faut se baser sur les "codes conventions"
Hors ligne
#16 Le 25/08/2007, à 14:04
- rniamo
Re : Appel à contribution pour l'adesklet weatherforecast
bonjour,
éxiste il un screenlet pour faire des diaporama ?
< Quelques un des mes programmes | Cuisine Facile (pour les gourmands) | Fast MVC for PHP >
\ ^__^
\ (o o)\_______
(___)\ )\
Hors ligne
#17 Le 28/08/2007, à 09:56
- Shaahrazade
Re : Appel à contribution pour l'adesklet weatherforecast
je dépoussière ce sujet un peu vieux.
La traduction française de la météo est-elle terminée et disponible finalement ?
J'aimerais bien l'utiliser et s'il y a encore du travail à faire, je peux participer, n'hésitez pas à demander.
Hors ligne