'Code not performing numerical calculation from what it is obtaining from the entry box

I am learning tkinter GUI development and trying to build an app that converts currency by manually entering exchange rate for now. At the moment I am stuck with the following error when i press the convert button on the GUI of my program.

Traceback (most recent call last):
  File "C:\Users\USER\AppData\Local\Programs\Python\Python39\lib\tkinter\__init__.py", line 1892, in __call__
    return self.func(*args)
  File "c:\Akshit\Currency converter\main.py", line 17, in conversion_logic
    cvalue_tbci = float(cvalue_tbc) * 1.3930973
ValueError: could not convert string to float: ''

Here is my code, it has some other entry-boxes which I plan to use for choosing specific currencies, once my code is up and running, for now it is commented out.

from tkinter import *
from tkinter.ttk import *

#window sizing and background
root= Tk()
root.title("Currency Converter")
root.state("zoomed")

#styles
style = ttk.Style()
style.configure("TEntry", foreground="black", background="#ffffff")


#functions for the logic
def conversion_logic():
    cvalue_tbci = float(cvalue_tbc) * 1.3930973
    currency_tbci_display_box = Label(root, borderwidth=3, relief="sunken", width=85, anchor="center", text=cvalue_tbci)
    currency_tbci_display_box.grid(ipadx=5, ipady=2, row=46, column=10)

#what each widget will do

#currency_tbc_entry = Entry(root, width=73, justify="center", style="TEntry")
#currency_tbc_entry.insert(0, "Please choose currency to be converted: USD, AUD, INR, MYR, GBP, EUR, JPY, CNY")
#currency_tbc = currency_tbc_entry.get()

currency_tbc_value = Entry(root, width=45, justify="center", style="TEntry")
cvalue_tbc = currency_tbc_value.get()


#currency_tbci_entry = Entry(root, width=73, justify="center", style="TEntry")
#currency_tbci_entry.insert(0, "Please choose currency to be converted in: USD, AUD, INR, MYR, GBP, EUR, JPY, CNY")
#currency_tbci = currency_tbci_entry.get()

currency_tbci_display_label = Label(root, borderwidth=2, relief="ridge", text="The value currency to be converted in will display here", anchor="center")


Convert_button = Button(root, text="CONVERT", width=20, command=conversion_logic)




#placing the widgets
#currency_tbc_entry.grid(ipady=5, ipadx=5, row=15, column= 9)

currency_tbc_value.grid(ipadx=5, ipady=5, row=17, column=10)

#currency_tbci_entry.grid(ipady=5, ipadx=5, row=15, column=15)

currency_tbci_display_label.grid(ipadx=20, ipady=5, row=38, column=10)

Hope this information is enough to solve my problem.

Thanks in advance



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source