#1 Le 04/03/2008, à 15:13
- TeddyTheBest
[Résolu] GDesklets - Affichage des digits sur une horloge
Bonjour,
J'ai installé GDesklets sur mon Ubuntu Gutsy Gibbon 7.10 et ça fonctionne parfaitement ; à part, peut être certains scripts... Et encore, je chipotte....
Mais, bon, là j'ai un petit problème d'affichage qui ne me convient pas (pas esthétique à mon goût)
GDesklet me lance une horloge classique sous laquelle figure la date du jour sous la forme d.m.yyyy. Cet affichage ne me convient pas et je souhaiterai avoir quelque chose de la forme dd/mm/yy.
J'ai édité le code source de cette horloge et voici ce qu'il y a :
<?xml version="1.0" encoding="UTF-8"?>
<display window-flags="sticky, below" anchor="center">
<meta author="Martin Grimme"
version="0.50"
name="clock"
description="A scalable and configurable clock for your desktop."
preview="gfx/pocketwatch.png"/>
<!-- clock face consisting of a background image and a canvas for displaying
the hands -->
<group id="main">
<image id="face" uri="gfx/plain.png"
image-width="100%" image-height="100%" width="100%" height="100%"/>
<canvas id="clock" width="4cm" height="4cm"/>
</group>
<!-- date and timezone labels beneath the clock -->
<label id="date" relative-to="main, y" x="50%" anchor="n"
font="Serif bold 12" color="white"/>
<label id="tz" relative-to="date, y" anchor="n" font="Serif bold 12"
color="white" visible="False"/>
<!-- the preferences dialog -->
<prefs callback="prefs_cb">
<page label="Appearance">
<enum label="Face:" bind="clockface" help="What the clock looks like.">
<item label="Plain" value="clock.png"/>
<item label="gDesklets" value="gdclock.png"/>
<item label="Royal Air Force" value="rafclock.png"/>
<item label="GNOME" value="gnomeclock.png"/>
<item label="OS-X" value="osXclock.png"/>
<item label="Grandpa's pocket watch" value="pocketwatch.png"/>
</enum>
<float label="Size:" bind="size" min="0.5" max="50.0"
help="The size of the clockface."/>
<boolean label="Show seconds" bind="show_seconds"/>
</page>
<page label="Date">
<string label="Output format:" bind="date_format"
help="The ouput format of the date."/>
<boolean label="Display date" bind="Dsp.date.visible"/>
<font label="Font:" bind="Dsp.date.font"/>
<color label="Text color:" bind="Dsp.date.color"/>
</page>
<page label="Timezone">
<enum id="continent" label="Region:" bind="tz_continent" callback="continent_cb">
<item label="System Default" value=""/>
<item label="Africa" value="Africa"/>
<item label="America" value="America"/>
<item label="Antarctica" value="Antarctica"/>
<item label="Arctic" value="Arctic"/>
<item label="Asia" value="Asia"/>
<item label="Atlantic Ocean" value="Atlantic"/>
<item label="Australia" value="Australia"/>
<item label="Europe" value="Europe"/>
<item label="Indian Ocean" value="Indian"/>
<item label="Pacific Ocean" value="Pacific"/>
</enum>
<enum id="city" label="Location:" bind="tz_city" callback="city_cb"/>
<boolean label="Display timezone" bind="Dsp.tz.visible"/>
<font label="Font:" bind="Dsp.tz.font"/>
<color label="Text color:" bind="Dsp.tz.color"/>
</page>
</prefs>
<script uri="timezones.script"/>
<script>
#<![CDATA[
HAND_HOUR = "<path d='M-1 8 L-1.5 -20 L1.5 -20 L1 8Z' " \
" style='stroke:none;fill:black' " \
" transform='rotate(%f)'/>"
HAND_MINUTE = "<path d='M-1 10 L-1.5 -28 L1.5 -28 L1 10Z' " \
" style='stroke:none;fill:black' " \
" transform='rotate(%f)'/>"
HAND_SECOND = "<path d='M-0.5 10 L-0.5 -30 L0.5 -30 L0.5 10Z' " \
" style='stroke:none;fill:red' " \
" transform='rotate(%f)'/>"
clockface = "plain.png"
size = 4.0
date_format = "%d. %m. %y"
show_seconds = False
tz_continent = ""
tz_city = ""
def prefs_cb(key, value):
if (key == "clockface"): set_face(value)
elif (key == "size"): set_scale(value)
def continent_cb(key, value):
Prefs.city.items = CITIES[value]
def city_cb(key, value):
if (tz_continent and tz_city):
tz = tz_continent + "/" + tz_city
else:
tz = tz_city
time.timezone = tz
Dsp.tz.value = time.timezone
def set_face(face):
Dsp.face.uri = "gfx/" + face
def do_time(value):
h, m, s = value
h_angle = 360 / 12 * (h + (m / 60.0))
m_angle = 360 / 60 * (m + (s / 60.0))
s_angle = 360 / 60 * s
w = Dsp.clock.width[PX]
h = Dsp.clock.height[PX]
scalex = float(w) / 100
scaley = float(h) / 100
body = HAND_HOUR % (h_angle) + HAND_MINUTE % (m_angle)
if (show_seconds): body += HAND_SECOND % (s_angle)
Dsp.clock.graphics = \
"<svg>" + \
"<g transform='translate(50,50)'>" + \
body + \
"</g></svg>"
def set_scale(value):
Dsp.clock.width = Unit(value, CM)
Dsp.clock.height = Unit(value, CM)
do_time(time.time)
def do_date(value):
y, m, d = value
out = date_format.replace("%y", `y`) \
.replace("%m", `m`) \
.replace("%d", `d`)
Dsp.date.value = out
# retrieve the time control
time = get_control("ITime:9y703dqtfnv4w373caserz68r")
# watch date and time
time.bind("date", do_date)
time.bind("time", do_time)
set_scale(size)
set_face(clockface)
do_time(time.time)
]]>
</script>
</display>
Je souhaiterait remplacer une partie du code pour mettre à la place du code existant, quelque chose du type :
def do_date(value):
y, m, d = value
if m<10: m=concat'0'm;
if d<10: d=concat'0'd;
y=y-2000
out = date_format.replace("%y", `y`) \
.replace("%m", `m`) \
.replace("%d", `d`)
Dsp.date.value = out
J'ai mis concat car je sais pas comment écrire ce code ; donc vos idées seront les bienvenues...
Merci à vous
Dernière modification par calimarno (Le 03/04/2008, à 20:45)
Black-Out contre Hadopi 2 : agir avant la censure de l'Internet.........Loi finalement acceptée.... :-(
Ubuntu Lucid Lynx 10.04 32 bits
Laptop HP / Processeur 1.6Ghz / Carte Graphique ATI / 512 Mo DDRAM
Hors ligne
#2 Le 03/04/2008, à 19:24
- TeddyTheBest
Re : [Résolu] GDesklets - Affichage des digits sur une horloge
Finalement, et après recherche de desklets, j'ai trouvé un script qui m'affiche la date dans le format que je souhaite, ainsi que l'horloge.
Donc , je dirai pas que le sujet initial est résolu, mais que j'ai trouvé une autre solution.....
Black-Out contre Hadopi 2 : agir avant la censure de l'Internet.........Loi finalement acceptée.... :-(
Ubuntu Lucid Lynx 10.04 32 bits
Laptop HP / Processeur 1.6Ghz / Carte Graphique ATI / 512 Mo DDRAM
Hors ligne