I've defined an Entry
in def
then use it in simple math function. When I type in number in Entry
it says name (of Entry
) is not defined.
I'm very new at programing and this is an school project. In this project I'm trying to make value calculator.
marka1=float(marka.get())*1*3.79
NameError: name 'marka' is not defined
Code:
from tkinter import*
prozor1=Tk()
prozor1.title('Python')
prozor1.geometry('500x500')
prozor1.config(bg= 'yellow')
natpis1=Label(prozor1, text='Konverter valuta')
natpis1.place(x=200, y=50)
natpis1.config(font=36)
natpis1.config(bg='silver')
natpis1.config(fg='black')
suma1=Entry(prozor1, width=19)
suma1.place(x=200,y=100)
mb=Menubutton(prozor1, text='Valuta')
mb.place(x=27, y=100)
mb.menu=Menu(mb)
mb.config(bg='grey')
mb['menu']=mb.menu
def km1():
marka1=float(marka.get())*1*3.79
rezu3=Label(prozor1, text='KN='+str(marka1))
rezu3.place(x=200, y=170)
rezu3.config(bg='silver')
def KM1():
frk=Button(prozor1, text='Pretvori',width=15, command=km1)
frk.place(x=200,y=130)
frk.config(bg='silver')
natpis1=Label(prozor1, text='Unesi sumu u KM')
natpis1.place(x=90, y=100)
natpis1.config(bg='silver')
marka=Entry(prozor1, width=19)
marka.place(x=200,y=100)
mb.menu.add_command(label='KM-KN', command=KM1)
This is an important part of the project.