0
from tkinter import *
pencere = Tk() #Pencereyi Oluşturyor
def Ekmek(event):
print(0.6*x)
#Here i am trying to calcute the carbohydrate for diabetes
#1 gram of bread is 0.6 carbohydrate and i am trying to calculate the gram user enters
def Patates(event):
print(0.16666666666666666)
gramy = Label(text = "Yemeğin Gramını Girin:",fg = "green",bg = "black")
gram = Entry(fg = "green",bg = "black")
x = gram.get()
#In this part i want to change the "x" to a
#float value but it gives error.How can i fix it ?
ekmek = Button(text="Ekmek",fg="orange",bg = "black")
ekmek.bind("<Button-1>",Ekmek)
patates = Button(text="Patates",fg="orange",bg = "black")
patates.bind("<Button-1>",Patates)
makarna = Button(text="Makarna",fg="orange",bg = "black")
pilav = Button(text="Pilav",fg="orange",bg = "black")
gramy.grid(row=0,column=1)
gram.grid(row =0,column =2)
ekmek.grid(row =1,column = 0)
patates.grid(row =1,column = 1)
makarna.grid(row = 1,column = 2)
pilav.grid(row = 2,column = 0)
pencere.mainloop() #Pencerenin Çarpıya
不要只是說它給錯誤,什麼錯誤?首先,我建議你重新學習tkinter,因爲你永遠不會讓用戶寫入任何東西。綁定到一個按鈕或什麼 – abccd
但用戶打算進入克,所以如果用戶說230克,並說我想要麪包它將要做(0.6 * 230),所以用戶可以選擇幾乎所有的東西 – dartyet1