I'm still trying to understand classes. I have used a class to easily initialize several identical labels and entry box widgets. Here is my code:
import tkinter as tk
class Tile:
def __init__(self, master, row_number, text_entry):
item = tk.Label(master, fg="white", bg="#300000",
text="Tile # " + text_entry + ":",
font=("Arial", 14, "bold"))
user_input = tk.Entry(master, width=50)
item.grid(column=0, row=rows, padx=(0, 30), pady=(0, 10))
user_input.grid(column=1, row=row_number, padx=(0, 30), pady=(0, 10))
self.ent = user_input.get()
I was under the impression that I could use "self.ent = user_input.get()" to get the user input from the entry widget within my Tile object:
example = Tile(root,5,"5")
# then later have a button to call this action:
def button_clicked():
print(example.ent)
This isn't working... How can I achieve this goal?