# -*- coding: cp1252 -*- import _winreg,sys try: name, value, typ = _winreg.EnumValue(_winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\Classes\CLSID\{EC501258-201C-449C-BE20-837A316EA382}\PythonCOMPath'), 0) if not sys.path.__contains__(value): sys.path.append(value) except: pass import pluie, time, os def cree(): g=pluie.ggroup(sens='H') t1=pluie.glabel(label='Ceci est un texte') image=pluie.gimage(ID='IM1', nomfichier='pluimg\\tchin-tchin.gif') guirlande=pluie.gimage(ID='IM1', nomfichier='pluimg\\lumiere_80.gif') br=pluie.gbr(nb=3) g.insert(guirlande, guirlande, guirlande, br, image, t1) sv=pluie.gsensv() #on passe en sens vertical ch1=pluie.gchamp(ID='CH1', larg=180, maxlength=30, label='Calcul') ch2=pluie.gchamp(ID='CH2') ch2.larg=180 ch2.maxlength=30 ch2.label='Résultat' ch2.align='center' br=pluie.gbr(nb=2) c1=pluie.gbutton(ID='BTCALC', label='Calculer') c2=pluie.gbutton(ID='BTQUIT', label='Quitter') g.insert(sv, br, ch1,ch2, br, c1,c2) pluie.gwrite(g, template='pluie___.htm', fichier='temp.htm') return g def utilise(): fiche=cree() g=pluie.pluie('temp.htm', width=420, height=400) ch1=g.ie.connectid('CH1') ch1.value='' ch2=g.ie.connectid('CH2') ch2.value='' ch1.focus() while True: if not g.getnextaction(): if g.type=='break': print 'pluie cassé.' break else: time.sleep(0.050) else: if g.type=='clic': if g.cible=='BTCALC': try: result=eval(ch1.value, locals(),locals()) except: result='Erreur dans le calcul.' ch2.value=result if g.cible=='BTQUIT': print "Le bouton 'Quitter' a été cliqué." g.close() break elif g.type=='changevalue': if g.cible=='CH1': try: result=eval(ch1.value, locals(),locals()) except: result='Erreur dans le calcul.' ch2.value=result print "On a fini." utilise()