I am learning python and decided to create a calculator for uniform line movement with OOP and Tkinter. And because i needed a couple of entry boxes i created a class for it, but i am getting errors when triying to extract the text. Here is the code:
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 The error i am getting with it is this: AttributeError: 'entryBox' object has no attribute 'get'
How do i get the text from each entryBox?