Я изучаю python и решил создать калькулятор для равномерного перемещения линий с помощью ООП и Tkinter.И поскольку мне понадобилась пара полей ввода, я создал для него класс, но я получаю ошибки при попытке извлечь текст.Вот код:
from tkinter import *
root = Tk() # Crea una ventana basica. SIEMPRE se debe utilizar
root.geometry('350x200') # Setea las dimensiones de la ventana
root.title("Simple MRU Calculator.")
class labels: # Crea labels de texto
def __init__(self, texto, fuente, tamañoFuente, columna, rowa):
self = Label(root, text=texto, font=(fuente, tamañoFuente)
).grid(column=columna, row=rowa)
class entryBox: # Crea entryboxes
def __init__(self, largo, columna, rowa):
self = Entry(root, width=largo)
self.grid(column=columna, row=rowa)
entryBox_Distancia = entryBox(10, 1, 0)
entryBox_Velocidad = entryBox(10, 1, 1)
entryBox_TiempoF = entryBox(10, 1, 2)
entryBox_TiempoI = entryBox(10, 1, 3)
def calculando():
entryBoxDT = entryBox_Distancia.get()
print(entryBoxDT)
theLabel_Uno = labels('Distancia Inicial:', 'Arial', 11, 0, 0)
theLabel_Dos = labels('Velocidad', 'Arial', 11, 0, 1)
theLabel_Tres = labels('Tiempo Final', 'Arial', 11, 0, 2)
theLabel_Cuatro = labels('Tiempo Inicial', 'Arial', 11, 0, 3)
boton_Uno = Button(root, text='Calcular', command=calculando)
boton_Uno.grid(column=1, row=5)
theLabel_Cinco = labels('n', 'Arial', 11, 1, 4)
root.mainloop() # Inicia la ventana
Я получаю сообщение об ошибке: AttributeError: 'entryBox' object has no attribute 'get'
Как мне получить текст из каждого поля ввода?