Hejka, załóżmy że mam taki prosty kod
import random
from tkinter import *
class Car:
def __init__(self, id, model, year_of_prod):
self.id = id
self.model = model
self.year_of_prod = year_of_prod
def create_list_of_cars(number):
list_of_cars = []
for i in range(1, number):
car = Car(i, 'Ford C-Max', random.randint(2011, 2016))
root = Tk()
root.geometry("300x200")
root.title("Utworz auta")
text_label = Label(root, text="Ile aut utworzyc?")
text_label.place(x=60, y=50)
number_entry = Entry()
number_entry.place(x=45, y=100)
confirm_button = Button(root, text="Potwierdz utworzenie listy", command=lambda: create_list_of_cars(int(number_entry.get())))
confirm_button.place(x=25, y=150)
root.mainloop()
W jaki sposób mogę tę listę samochodów "zwrócić" tzn. dostać się do jej obiektów w dalszym kodzie (po wciśnięciu przycisku i utworzeniu jej)