Self.to_currency_dropdown = ttk.Combobox(self, textvariable=self.to_currency_variable,values=list(self.currency_()), font = font, state = 'readonly', width = 12, justify = tk.CENTER) om_currency_dropdown = ttk.Combobox(self, textvariable=om_currency_variable,values=list(self.currency_()), font = font, state = 'readonly', width = 12, justify = tk.CENTER) Self.option_add('*TCombobox*Listbox.font', font) Self.to_currency_t("USD") # default value Self.to_currency_variable = StringVar(self) nverted_amount_field_label = Label(self, text = '', fg = 'black', bg = 'white', relief = tk.RIDGE, justify = tk.CENTER, width = 17, borderwidth = 3) Self.amount_field = Entry(self,bd = 3, relief = tk.RIDGE, justify = tk.CENTER,validate='key', validatecommand=valid) # restricNumberOnly function will restrict thes user to enter invavalid number in Amount field. Valid = (self.register(self.restrictNumberOnly), '%d', '%P') It allows users to enter the amount as well as choosing among the various available currencies. Now follows the Entry box that will entail amount and currency options. Self.date_label = Label(self, text = f"1 Indian Rupee equals = ", relief = tk.GROOVE, borderwidth = 5)Īfter setting up the frame, information is added and starts taking shape as below, Self.intro_label = Label(self, text = 'Welcome to Real Time Currency Convertor', fg = 'blue', relief = tk.RAISED, borderwidth = 3) The above Code forms the frame of the converter.īelow is the format for creating a converter, Here we are going to develop the currency converter UI, by creating the Class currency converter (UI) as illustrated below, The output here is 1.33, therefore, 1.33 USD Equals to 100Indian Rupees. To currency, in the currency one wants to convertĪmount refers to the value or amount intended for conversion, as well as returns from the converted Amount. The from currency, from the currency one, wants to convert # limiting the precision to 4 decimal placesĪmount = round(amount * self.currencies, 4) #first convert it into USD if it is not in USD.Īmount = amount / self.currencies After that, JSON Format converts the page to JSON File then it is stored in the data variable.ĭef convert(self, from_currency, to_currency, amount): Get (URL), the page is loaded in the Python Program. It will convert the concerned currency as well as returning the amount that has been converted. It is time to create the currency converter cluster to get real-time conversion or exchange rate. Therefore, we have to Import the concerned Library, as below:įrom tkinter import ttk The Creation of Currency Converter Cluster or Class Here we are using Tkinter and requests to complete this assignment. It will also show the applicable rates for currencies that have a USD Currency base. It will also show the date and time details that it was last updated. It is only after this that we will be able to convert it to any other desired currency. This means before converting any other currency, we must convert it to the US dollar. The two are to be typed in the terminal.īefore anything else, it is important to download Python Source Code.įor real-time currency conversion rates, the JSON format serves better. To start, these two terms will be crucial, Tkinter as UI (User Interface), and Requests for getting URL. To be able to execute the entire process successfully, it is important to have some basic knowledge of Python Programming as well as Pygame Library. For purpose of this article, for User Interface we will be using the Tkinter file. We are going to develop a simple and easy-to-use Python currency converter. Therefore, whether you are a trader, investor, or someone interested in currency conversion, if you follow this guide to the end, you will qualify to become a Python developer. Of course, there are many currency converters out there however, for this article, we will highlight the Python Source Code Currency Converter. One of the basic tools to convert one currency to the other is the Currency Converter. It is, therefore, important to know the value difference between the currencies you trade-in. The process of converting one currency to the other is known as Currency Conversion. However, this cannot be possible if you do not have enough information or knowledge about the value of the currencies in question. As an investor, especially where two or more currencies are involved, you will of course want to get the maximum returns out of your investment.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |