Zna li netko popraviti ovaj Python kod?

from tkinter import*
def kmhums():
kmh=float(u1.get())
ms=kmh1000/3600
rez1=Label(p,text=str(ms)+‘m/s’)
rez1.place(x=330,y=60)
def msukmh():
ms=float(u2.get())
kmh=ms
3600/1000
rez2=Label(p,text=str(kmh)+‘kmh’)
rez2.place(x=330,y=100)

p=Tk()
p.config(width=500, height=180)
t=Label(p, text=‘PRETVORBA SLOŽENIH MJERNIH JEDINICA - BRZINE’)
t.place(x=50, y=20)

t1=Label(p, text=‘Unesi km/h:’)
t1.place(x=30, y=60)
u1=Entry(p)
u1.place(x=110, y=60, width=80)
g1=Button(p, text=‘Pretvori u m/s’, command=kmhums)
g1.place(x=200, y=5, width=120)

t2=Label(p, text=‘Unesi m/s:’)
t2.place(x=30, y=100)
u2=Entry(p)
u2.place(x=110, y=100, width=80)
g2=Button(p, text=‘Pretvori u km/h’, command=msukmh)
g2.place(x=200, y=99, width=120)
p.mainloop()

ChatGPT kaže:

from tkinter import *

def kmh_to_ms():
    kmh = float(u1.get())
    ms = kmh * 1000 / 3600
    rez1 = Label(p, text=str(ms) + ' m/s')
    rez1.place(x=330, y=60)

def ms_to_kmh():
    ms = float(u2.get())
    kmh = ms * 3600 / 1000
    rez2 = Label(p, text=str(kmh) + ' km/h')
    rez2.place(x=330, y=100)

p = Tk()
p.geometry('500x180')  # Adjust the window size using geometry

t = Label(p, text='CONVERSION OF COMPLEX MEASUREMENT UNITS - SPEED')
t.place(x=50, y=20)

t1 = Label(p, text='Enter km/h:')
t1.place(x=30, y=60)
u1 = Entry(p)
u1.place(x=110, y=60, width=80)
g1 = Button(p, text='Convert to m/s', command=kmh_to_ms)
g1.place(x=200, y=55, width=120)  # Adjusted y position

t2 = Label(p, text='Enter m/s:')
t2.place(x=30, y=100)
u2 = Entry(p)
u2.place(x=110, y=100, width=80)
g2 = Button(p, text='Convert to km/h', command=ms_to_kmh)
g2.place(x=200, y=95, width=120)  # Adjusted y position

p.mainloop()

Ja inače nemam pojma o pythonu.

1 Like