Convertisseur Euro / zone euro

 

Voici un convertisseur euro / zone euro. Les images sont intégrées dans le script. Il est mis sous lisence GPL par son auteur, Eric Freyens.

Capture d'écran :

Sources :

    #!/usr/bin/wish
    # Créé par Eric Freyens
    # Email : eric.freyens@tiscali.be
    #
    # License : GPL2

    # Table contenant les infos des différents pays -----
    array set monnaies {
        bef "BE64 Belgique {Franc Belge} 40.3399 BEF"
        dem "DE64 Allemagne  Mark  1.95583 DEM"
        ats "AU64 Autriche Shilling 13.7603 ATS"
        esp "ES64 Espagne Peseta 166.386 ESP"
        fim "FI64 Finlande {Mark Finlandais} 5.94573 FIM"
        frf "FR64 France Franc 6.55957 FRF"
        iep "IE64 Irlande {Livre Irlandaise} 0.787564 IEP"
        itl "IT64 Italie Lire 1936.27 ITL"
        luf "LU64 Luxembourg {Franc Luxembourgeois} 40.3399 LUF"
        nlg "NL64 Pays-Bas Florin 2.20371 NLG"
        pte "PO64 Portugal Escudo 200.482 PTE"
        grd "GR64 GrÚce Drachme 304.750 GRD"
    }

    # Définition des drapeaux en BASE64 -----
    image create photo BE64 -data "R0lGODlhFAAOALMAAMDAwP//AP8AAPPz89vb28/Pz5SUlHBwcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAUAA4AAARDEMkZqhU4kzGprVlmEJ30gaFwFCVyBqnKlm+8tnV606c9d7nQDtjT/TwfH64oPJqYmRXBcKhar9jDaEAoeL/gcGETAQA7"
    image create photo DE64 -data "R0lGODlhFAAOALMAAAAAAP/////nIf8hCPPz89vb28/Pz5SUlHBwcP///wAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAkALAAAAAAUAA4AAAQ6EMhJ6yzE6nrK/gBigJs4nGiqoubqpu37xvIqCniu7/nN/zofECgc8kSFA2LJbDoRHULBQK1arwZMBAA7"
    image create photo AU64 -data "R0lGODlhFAAOAMIAAP8hCNvb2/Pz85SUlHBwcM/Pz////////yH5BAEKAAcALAAAAAAUAA4AAAMzCLrcG8LJNsK8gBQ8tflgKILeaIbleabqqHHSCzfyvNR2VgQD4f/AIKEiCBSOyKRyJ0gAADs="
    image create photo ES64 -data "R0lGODlhFAAOAMIAAP8hCNvb2/Pz85SUlHBwcM/Pz/7/A////yH5BAEKAAcALAAAAAAUAA4AAAMzCLrcG8LJNsK8gBTDu/+dBo6fSJ7mOaZqubWghk3y7NQ2owUD4f/AIKEiCBSOyKSyAEkAADs="
    image create photo FI64 -data "R0lGODlhFAAOALMAAAAAAP///yk5xvPz89vb28/Pz5SUlHBwcP///wAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAgALAAAAAAUAA4AAARAMMggqph4koHtzZhBdBaIHQVZmRPqvbDlxnQ11zGqfqw+eSyJTwIMDiklY+qX7BUIhoN0Sq0eRANCYcvtep+DCAA7"
    image create photo FR64 -data "R0lGODlhFAAOALMAAAAAAP///w45re8YAPPz89vb28/Pz5SUlHBwcP///wAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAkALAAAAAAUAA4AAARDUMgZqh04FzKprVl2FJ30geGAGKVwBqnKlm+8tnV606c9d7nQDtjT/TwfH64oPJqYmVXhgKhar1jEiFAweL/gsGETAQA7"
    image create photo IE64 -data "R0lGODlhFAAOAOMAAADmAP////+ZANvb2/Pz85SUlHBwcM/Pz////////////////////////////////yH5BAEKAAgALAAAAAAUAA4AAARDEMgZqhU4DzKprVlWDJ30gaFgHCVwBqnKlm+8tnV606c9d7nQDtjT/TwfH64oPJqYmdWgYKhar1jDiDA4eL/g8GETAQA7"
    image create photo IT64 -data "R0lGODlhFAAOALMAAAAAAP///0aMAPcYAPPz89vb28/Pz5SUlHBwcP///wAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAkALAAAAAAUAA4AAARDUMgZqh04FzKprVl2FJ30geGAGKVwBqnKlm+8tnV606c9d7nQDtjT/TwfH64oPJqYmVXhgKhar1jEiFAweL/gsGETAQA7"
    image create photo LU64 -data "R0lGODlhFAAOAOMAAP8hCNvb2/Pz85SUlHBwcM/Pz////wOW/f///////////////////////////////yH5BAEKAAgALAAAAAAUAA4AAAQ6EMhJ6wzC6jrC/gBRgJtonGiqoubqpu37xvIqHniu7/nN/zofECgc8kSBAWHJbDoJHUGgQK1arwVMBAA7"
    image create photo NL64 -data "R0lGODlhFAAOALMAAP////8hCPPz89vb28/Pz5SUlHBwcA45rcDAwAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAgALAAAAAAUAA4AAAQ6MMhJ6xzC6lrG/oFBgJsInGiqoubqpu37xvIqHniu7/nN/zofECgc8kSDgmHJbDoNHcGAQK1arwRMBAA7"
    image create photo PO64 -data "R0lGODlhFAAOAOMAAACzAv8hCNvb2/Pz85SUlC+7C6jPIuraL/TUL/eiJPxFEHBwcM/Pz/TcMf///////yH5BAEKAA8ALAAAAAAUAA4AAARQEMgJgr04iEFn/oRAFcaBJMpnLcxUHE3cIOnHToYsJ+otwbpZr/ULCm1EQC7IQ7qAMdpwVDrVnJ2K6uLrbLkMAWFBLpvPi9BAwGi73/DwIAIAOw=="
    image create photo GR64 -data "R0lGODlhFAAOAMIAAA45rf///9vb2/Pz85SUlHBwcM/Pz////yH5BAEKAAcALAAAAAAUAA4AAAM5CBDa/kAMxVa4OF8iNPyFQVFaGYTjB4pqG5owhrbqTENvDNu3w/eKkIBQKBqPyAJnIDA4n9CoQZIAADs="

    array set monnaie {}

    # Procédure de convertion -----
    proc convert { sens } {
        global monnaie
        set taux $monnaie(taux)

        set val [ .v get ]

        switch $sens {
            N { set out [ expr $val * $taux ] }
            E { set out [ expr $val / $taux ] }
        }

        .v delete 0 end
        .v insert end $out
    }

    # Selection du pays -----
    proc selectCountry { { country "bef" } } {
        global monnaies monnaie

        array set monnaie [ list img  [lindex $monnaies($country) 0] ]
        array set monnaie [ list pays [lindex $monnaies($country) 1] ]
        array set monnaie [ list mon  [lindex $monnaies($country) 2] ]
        array set monnaie [ list taux [lindex $monnaies($country) 3] ]
        array set monnaie [ list unit [lindex $monnaies($country) 4] ]

        wm title . "Convertion - $monnaie(pays) - $monnaie(unit)"
        .n configure -text "$monnaie(mon)"
    }

    wm title . "Convertion"

    # Mise en place des bouton de sélection de pays -----
    frame .frm
    foreach country [ array names monnaies ]  {
        set nf [lindex $monnaies($country) 0]
        set wi [ image width $nf ]
        button .frm.$country -image $nf -command "selectCountry $country" -width $wi
        pack .frm.$country -side left
    }

    # Creation des autres widget -----
    entry .v -width 40
    button .n -text "Nationale" -command { convert N }
    button .e -text "Euro"      -command { convert E }

    selectCountry

    pack .frm .v .n .e -fill both