DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk4 min

How to Build a Currency Converter with Tkinter and forex-python

A beginner-friendly Python desktop converter using Tkinter for the interface and forex-python for currency conversion, with input checks and clear error handling.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

You can build a simple desktop currency converter by using Tkinter for the interface and forex-python to request a conversion. The example below accepts an amount and two currency codes, validates the amount before making a request, and displays either the converted value or a useful error message.

What you need

  • Python installed in the environment where you will run the app.
  • Tkinter, Python’s interface to Tcl/Tk. Tkinter widgets wrap Tcl/Tk commands, and its variable classes—such as StringVar—connect Python values to interface controls. Python 3.14.8 Tkinter documentation
  • The forex-python package for rate lookup and conversion. Its documented interface includes CurrencyRates.convert() and CurrencyRates.get_rate(). forex-python usage documentation

Install the package in the same Python environment you will use to launch the program:

As an Amazon Associate I earn from qualifying purchases.

python -m pip install forex-python

If your system uses a different Python launcher, use that launcher consistently for both installation and execution.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Build the converter

Save the following as currency_converter.py. Enter three-letter currency codes such as USD or INR; the program passes those codes to forex-python. It checks that the amount is numeric and positive before requesting a conversion.

import tkinter as tk
from forex_python.converter import CurrencyRates

rates = CurrencyRates()


def convert_currency():
    try:
        amount = float(amount_var.get())
    except ValueError:
        result_var.set("Enter a valid number for the amount.")
        return

    if amount <= 0:
        result_var.set("Enter an amount greater than zero.")
        return

    source = source_var.get().strip().upper()
    target = target_var.get().strip().upper()

    if not source or not target:
        result_var.set("Enter both currency codes.")
        return

    try:
        converted = rates.convert(source, target, amount)
    except Exception as error:
        result_var.set(
            "Conversion failed. Check the currency codes and your connection."
        )
        print(f"Conversion error: {error}")
        return

    result_var.set(f"{amount:g} {source} = {converted:.2f} {target}")


root = tk.Tk()
root.title("Currency Converter")
root.resizable(False, False)

amount_var = tk.StringVar()
source_var = tk.StringVar(value="USD")
target_var = tk.StringVar(value="INR")
result_var = tk.StringVar(value="Enter an amount and currency codes.")

padding = {"padx": 10, "pady": 6}

tk.Label(root, text="Amount").grid(row=0, column=0, sticky="w", **padding)
tk.Entry(root, textvariable=amount_var, width=24).grid(
    row=0, column=1, **padding
)

tk.Label(root, text="From (currency code)").grid(
    row=1, column=0, sticky="w", **padding
)
tk.Entry(root, textvariable=source_var, width=24).grid(
    row=1, column=1, **padding
)

tk.Label(root, text="To (currency code)").grid(
    row=2, column=0, sticky="w", **padding
)
tk.Entry(root, textvariable=target_var, width=24).grid(
    row=2, column=1, **padding
)

tk.Button(root, text="Convert", command=convert_currency).grid(
    row=3, column=0, columnspan=2, pady=8
)
tk.Label(root, textvariable=result_var, wraplength=320).grid(
    row=4, column=0, columnspan=2, **padding
)

root.mainloop()

Run it with:

python currency_converter.py

How the conversion works

Tkinter stores and displays the input

The root window contains entry fields for the amount and currency codes, a button, and a result label. Each field is connected to a StringVar, so the callback can read the current text with get() and update the message with set(). Tkinter documents these variable wrappers as the usual way to connect widget values to Python code. Tkinter variables

forex-python performs the request

The button calls convert_currency(). After basic input checks, it invokes rates.convert(source, target, amount), the package’s direct amount-conversion method. For an app that needs to show the rate separately or apply its own calculation, use rates.get_rate(source, target) and multiply the amount by the returned rate instead. The package documentation demonstrates both methods. forex-python usage examples

Displayed precision is not a promise about the rate

The example formats the converted amount to two digits after the decimal point for readability. That is display formatting; it does not change the rate returned by the package or establish how a bank, card issuer, or exchange service would round an actual transaction.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Handle errors and rate-source limits

An invalid amount is rejected locally, before a request. The conversion call is wrapped so failures—such as an unsupported code or a network/service problem—produce a message in the window rather than closing the app. The code also prints the underlying error to the terminal for debugging. The package documentation demonstrates these methods but does not establish an exhaustive exception contract, so this example avoids depending on a specific exception class.

Do not treat the displayed figure as a guaranteed real-time quote or a transaction rate. The forex-python usage documentation identifies ratesapi.io as its source, while the package’s PyPI description refers to theratesapi.com and says it provides rates published by the European Central Bank. Those descriptions differ; the cited material does not establish a current update schedule, uptime guarantee, or transaction availability. forex-python documentation · forex-python on PyPI

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Use Decimal for monetary arithmetic

The basic example uses ordinary floating-point values, which matches the package’s default-style examples. If you want decimal arithmetic instead, initialize the class with force_decimal=True and pass a Decimal amount consistently:

from decimal import Decimal
from forex_python.converter import CurrencyRates

rates = CurrencyRates(force_decimal=True)
converted = rates.convert("USD", "INR", Decimal("10.45"))

The package example notes that using an integer or float amount in this mode raises DecimalFloatMismatchError. Convert validated input text to Decimal rather than to float when adapting the GUI for this mode. MicroPyramid forex-python repository

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.