Un autre 'Pydget" : Pydget Clock
Le
Salvatore
Hello,
Piloter VML avec Python, voici ce qu'illustre ce code.
Les applications sont nombreuses, visualiser en temps réel
les resources systèmes par exemples.
Voici le code :
<hta:application
windowstate="normal"
border="thin"
borderstyle = "normal"
caption="yes"
maximizeButton="yes"
singleinstance="yes"
SCROLL="no"
/>
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:v="urn:schemas-microsoft-com:vml"
xml:lang="en" lang="en">
<head>
<title>PyVMLClock2</title>
<style type="text/css">
h1 { text-align: center; margin-bottom: 100px; }
v\:* { behavior: url(#default#VML); }
</style>
</head>
<body onLoad="Initialisation()">
<center>
<div>
<v:group
style="position:absolute;top:10;left:10;width:200px;height:200px;"
coordsize="400, 400" coordorigin="0, 0">
<!-- Emprunte a Josi sur
http://webdeveloper.earthweb.com/we...6361-->
<v:group style="position:absolute;top:0;left:0;
width:200px;height:200px;" coordsize="50, 50" coordorigin="0, 0"" >
<v:oval style="width: 2; height: 2; left: 49; top: 1"
fillcolor="#c0c000" />
<v:oval style="width: 2; height: 2; left: 97; top: 49"
fillcolor="#c0c000" />
<v:oval style="width: 2; height: 2; left: 1; top: 49"
fillcolor="#c0c000" />
<v:oval style="width: 2; height: 2; left: 49; top: 97"
fillcolor="#c0c000" />
<v:oval style="width: 2; height: 2; left: 8; top: 25"
fillcolor="#c0c000" />
<v:oval style="width: 2; height: 2; left: 73; top: 8"
fillcolor="#c0c000" />
<v:oval style="width: 2; height: 2; left: 25; top: 8"
fillcolor="#c0c000" />
<v:oval style="width: 2; height: 2; left: 90; top: 25"
fillcolor="#c0c000" />
<v:oval style="width: 2; height: 2; left: 8; top: 73"
fillcolor="#c0c000" />
<v:oval style="width: 2; height: 2; left: 25; top: 90"
fillcolor="#c0c000" />
<v:oval style="width: 2; height: 2; left: 73; top: 90"
fillcolor="#c0c000" />
<v:oval style="width: 2; height: 2; left: 90; top: 73"
fillcolor="#c0c000" />
</v:group>
<!-- Fin Emprunt -->
<v:shape id="seconde" style="width:400;height:400;rotation:0.0"
stroked="true" strokecolor="blue"
path="m 200 10 l 200 230 e" />
<v:shape id="minute" style="width:400;height:400;rotation:0.0"
stroked="true" strokecolor="blue"
path="m 200 10 l 200 230 e" />
<v:shape id="heure" style="width:400;height:400;rotation:0.0"
stroked="true" strokecolor="green"
path="m 200 50 l 200 230 e" />
</v:group>
</div>
</center>
<script language="Python">
import time
import math
pi = math.pi
s = 0
m = 0
h = 0
angles = 0
anglem = 0
angleh = 0
def RotatePython():
global angles, anglem, angleh
angles += 6.0
anglem += 0.1
angleh += 30.0/3600
s = document.getElementById("seconde")
s.style.rotation = str(angles)
m = document.getElementById("minute")
m.style.rotation = str(anglem)
h = document.getElementById("heure")
h.style.rotation = str(angleh)
def Initialisation():
global s,m,h,angles,anglem,angleh
x,x,x,h,m,s,x,x,x = time.localtime()
angles = s*6.0
anglem = (m+s/60.0)*6.0
angleh = (h+m/60.0+s/3600.0)*30
sp = document.getElementById("seconde")
tempo = window.setInterval("RotatePython()", 1000)
window.resizeTo(230,252)
</script>
</body>
</html>
Piloter VML avec Python, voici ce qu'illustre ce code.
Les applications sont nombreuses, visualiser en temps réel
les resources systèmes par exemples.
Voici le code :
<hta:application
windowstate="normal"
border="thin"
borderstyle = "normal"
caption="yes"
maximizeButton="yes"
singleinstance="yes"
SCROLL="no"
/>
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:v="urn:schemas-microsoft-com:vml"
xml:lang="en" lang="en">
<head>
<title>PyVMLClock2</title>
<style type="text/css">
h1 { text-align: center; margin-bottom: 100px; }
v\:* { behavior: url(#default#VML); }
</style>
</head>
<body onLoad="Initialisation()">
<center>
<div>
<v:group
style="position:absolute;top:10;left:10;width:200px;height:200px;"
coordsize="400, 400" coordorigin="0, 0">
<!-- Emprunte a Josi sur
http://webdeveloper.earthweb.com/we...6361-->
<v:group style="position:absolute;top:0;left:0;
width:200px;height:200px;" coordsize="50, 50" coordorigin="0, 0"" >
<v:oval style="width: 2; height: 2; left: 49; top: 1"
fillcolor="#c0c000" />
<v:oval style="width: 2; height: 2; left: 97; top: 49"
fillcolor="#c0c000" />
<v:oval style="width: 2; height: 2; left: 1; top: 49"
fillcolor="#c0c000" />
<v:oval style="width: 2; height: 2; left: 49; top: 97"
fillcolor="#c0c000" />
<v:oval style="width: 2; height: 2; left: 8; top: 25"
fillcolor="#c0c000" />
<v:oval style="width: 2; height: 2; left: 73; top: 8"
fillcolor="#c0c000" />
<v:oval style="width: 2; height: 2; left: 25; top: 8"
fillcolor="#c0c000" />
<v:oval style="width: 2; height: 2; left: 90; top: 25"
fillcolor="#c0c000" />
<v:oval style="width: 2; height: 2; left: 8; top: 73"
fillcolor="#c0c000" />
<v:oval style="width: 2; height: 2; left: 25; top: 90"
fillcolor="#c0c000" />
<v:oval style="width: 2; height: 2; left: 73; top: 90"
fillcolor="#c0c000" />
<v:oval style="width: 2; height: 2; left: 90; top: 73"
fillcolor="#c0c000" />
</v:group>
<!-- Fin Emprunt -->
<v:shape id="seconde" style="width:400;height:400;rotation:0.0"
stroked="true" strokecolor="blue"
path="m 200 10 l 200 230 e" />
<v:shape id="minute" style="width:400;height:400;rotation:0.0"
stroked="true" strokecolor="blue"
path="m 200 10 l 200 230 e" />
<v:shape id="heure" style="width:400;height:400;rotation:0.0"
stroked="true" strokecolor="green"
path="m 200 50 l 200 230 e" />
</v:group>
</div>
</center>
<script language="Python">
import time
import math
pi = math.pi
s = 0
m = 0
h = 0
angles = 0
anglem = 0
angleh = 0
def RotatePython():
global angles, anglem, angleh
angles += 6.0
anglem += 0.1
angleh += 30.0/3600
s = document.getElementById("seconde")
s.style.rotation = str(angles)
m = document.getElementById("minute")
m.style.rotation = str(anglem)
h = document.getElementById("heure")
h.style.rotation = str(angleh)
def Initialisation():
global s,m,h,angles,anglem,angleh
x,x,x,h,m,s,x,x,x = time.localtime()
angles = s*6.0
anglem = (m+s/60.0)*6.0
angleh = (h+m/60.0+s/3600.0)*30
sp = document.getElementById("seconde")
tempo = window.setInterval("RotatePython()", 1000)
window.resizeTo(230,252)
</script>
</body>
</html>

Poser une question


Salut
VML, pas assez connu, c'est sympa, joli et assez facile à utiliser mais :
1) ca ne marche a ma connaissance que sous win (comme les hta me diras tu)
2) c'est super gourmand en ressources !!
pourquoi ne pas utiliser SVG ?? (plugin dispo pour IE et intégré à firefox)
Merci en tous cas pour le code interessant
Julien.
Je vais suivre ton conseil tester SVG
Salvatore
Certes, mais c'est géré en standard par IE.
FF est hors course, ici, car il est incapable de gérer les HTml-Application (HTA), ainsi que
l'Active-Scripting (qui permet, entre autres, d'utiliser Python dans du HTML).
Comme Adobe le trouvait gênant, il a annoncé, il y a un an, l'arrêt de tout développements autour de
SVG. Le plug-in pour IE n'est actuellement plus supporté par Adobe ; et il devient difficile à
télécharger.
En même temps qu'Adobe abandonnait SVG, beaucoup de développeurs ont suivi.
Certes, il reste encore des outils l'utilisant (essentiellement Inkscape), ou des secteurs l'ayant
adopté (la cartographie). Mais, ce n'est pas gagné.
Et puis, SVG est plutôt complexe.
Alors, quel format choisir ? Bof ; l'important, c'est de montrer qu'on peut piloter pas mal de
choses, avec Python.
@-salutations
Michel Claveau
c'est vrai, pratique
Mauvaise nouvelle, je ne savais pas (j'avais taté il y a quelques
années)... Que nous reste il donc de portable pour les images/animations
vectorielles ? Flash ??? SMIL ?
Il y a sinon pas mal de viewers SVG sur :
http://wiki.svg.org/Viewer_Implementations
Bonne soirée
Julien
c'est vrai, pratique
Mauvaise nouvelle, je ne savais pas (j'avais taté il y a quelques
années)... Que nous reste il donc de portable pour les images/animations
vectorielles ? Flash ??? SMIL ?
Il y a sinon pas mal de viewers SVG sur :
http://wiki.svg.org/Viewer_Implementations
Bonne soirée
Julien