Back to Top

convertisseur de Devises 💱💲🪙

from tkinter import *

from tkinter.ttk import Combobox, Button, Entry

import math, os


class currencyApp(LabelFrame):

    def __init__(self, width = 200, height = 400, color = 'dark blue'):

        LabelFrame.__init__(self, bg= color, width = width, height = height, relief = 'ridge', bd = 1)

        self.width, self.height, self.color = width, height, color

        self.lab = Label(self, text = 'python Lite Currency',relief='flat',font=("verdana",10,"bold",'italic'), bg = 'white',fg = color)

        self.configure(labelwidget = self.lab, labelanchor = 'nw')


        self.currens = {'FCFA': {'Euro': 0.001524, 'Dollar US': 0.0018, 'Yen': 0.2, 'Livre Sterling': 0.001297, 'Naira': 0.5},

                        'Euro': {'FCFA': 655.957, 'Dollar US': 1.12, 'Yen': 130, 'Livre Sterling': 0.85, 'Naira': 420},

                        'Dollar US': {'FCFA': 555.556, 'Euro': 0.89, 'Yen': 115, 'Livre Sterling': 0.75, 'Naira': 380},

                        'Yen': {'FCFA': 5, 'Euro': 0.0077, 'Dollar US': 0.0087, 'Livre Sterling': 0.0065, 'Naira': 3.3},

                        'Livre Sterling': {'FCFA': 771.02, 'Euro': 1.1765, 'Dollar US': 1.3333, 'Yen': 153.8462, 'Naira': 495.87},

                        'Naira': {'FCFA': 2, 'Euro': 0.002381, 'Dollar US': 0.002632, 'Yen': 0.30303, 'Livre Sterling': 0.002018}}

        self.variable = [ DoubleVar(), StringVar(), DoubleVar(), StringVar()]

        self.img = PhotoImage(file = 'reload.png')

        self.inCurrens = [elt for elt in self.currens.keys()]

        

        self.variable[1].set(self.inCurrens[0])

        self.variable[3].set(self.inCurrens[1])

        

        self.inLabel = Label(self, text = 'choisissez votre devise : ', bg = color, fg = 'white')

        self.entryDev = Entry(self, width = 20, textvariable = self.variable[0])

        self.deviseIn = Combobox(self, width = 10, state = 'readonly', values = self.inCurrens, textvariable = self.variable[1])


        self.outLabel = Label(self, text = 'choisissez la destination : ', bg = color, fg = 'white')

        self.ouuterDev = Entry(self, width = 20, state = 'readonly', textvariable = self.variable[2])

        self.deviseout = Combobox(self, width = 10, state = 'readonly', values = self.inCurrens, textvariable = self.variable[3])


        self.button = Button(self, text = "conversion     ", image = self.img, compound ='right', command = self.conversion)


        self.inLabel.grid(column =0 , row =0 , columnspan =2 , sticky ='nswe', padx = 1, pady = 1)

        self.entryDev.grid(column =0 , row = 1, sticky ='nswe', padx = 1, pady = 1)

        self.deviseIn.grid(column =1 , row = 1 ,sticky ='nswe', padx = 1, pady = 1)

        self.outLabel.grid(column = 0, row =2 , columnspan =2 , sticky ='nswe', padx = 1, pady = 1)

        self.ouuterDev.grid(column =0 , row =3 , sticky ='nswe', padx = 1, pady = 1)

        self.deviseout.grid(column =1 , row =3 , sticky ='nswe', padx = 1, pady = 1)

        self.button.grid(column = 0, row =4 , columnspan =2 , sticky ='nswe', padx = 1, pady = 5)


    def conversion(self):

        for key in self.currens.keys():

            if key==self.variable[1].get():

                self.myDict = self.currens[key]

                for key2 in self.myDict:

                    if key2==self.variable[3].get():

                        self.variable[2].set(self.variable[0].get()*self.myDict[key2])

                        break

                    


if __name__ =='__main__':

    fen = Tk()

    fen['bg'] = 'dark blue'

    app = currencyApp()

    app.pack(padx = 5, pady = 5, ipadx = 5)

    fen.mainloop()


0Comments

Enregistrer un commentaire