예제 #1
0
 def get_currency(cls, currency_name):
     try:
         with request.urlopen(cls.Constants.base_url +
                              currency_name) as response:
             data = response.read().decode()
             json_data = json.loads(data)
             return Currency(json_data)
     except Exception as error:
         return None
    def get_currency(cls, initial_currency_name, final_currency_name):
        try:
            with request.urlopen(cls.Constants.base_url + initial_currency_name) as response:
                data = response.read().decode()
                json_data = json.loads(data)
                return Currency(final_currency_name, json_data)

        except URLError:
            return None
 def get_currency(cls, currency_name):
     try:
         with request.urlopen(cls.Constants.base_url +
                              currency_name) as response:
             data = response.read().decode()
             data_dictionary = json.loads(data)
             return Currency(data_dictionary)
     except Exception:
         print(
             'The calculator is not going to work, invalid URL inserted or non-available currency.'
         )
예제 #4
0
class MainApp():
    def __init__(self):
        self.__master = MainView(convert_handler=self.__convert)

    def run(self):
        self.__currency = Currency("USD", 18.90)
        self.__master.mainloop()

    def __convert(self, from_currency, to_currency, ammount):
        result = self.__currency.get_convertion(to_currency, ammount)
        self.__master.update_result(result)
예제 #5
0
 def run(self):
     self.__currency = Currency("USD", 18.90)
     self.__master.mainloop()