Mar-16-2020, 06:38 PM
Hello!
I wrote a very small program and created a class in it for loading pictures without defining methods. I was surprised to find that the part of the code that is in the class is executed without calling the class - the "print" operator worked. I would like to know - should it be so? If this is correct, then why is this happening?
I wrote a very small program and created a class in it for loading pictures without defining methods. I was surprised to find that the part of the code that is in the class is executed without calling the class - the "print" operator worked. I would like to know - should it be so? If this is correct, then why is this happening?
import os import tkinter as tk from tkinter import* from PIL import Image, ImageTk root = tk.Tk() class ImageInst: bild_list_image = []#список картинок здания '''загрузка картинок строения в bild_list''' path = 'C:\\ws5_class\\general\\bilds\\' for i, filename in enumerate(os.listdir(path)): if filename.find("bild") == False: if (filename.endswith(".png") or filename.endswith(".PNG")): path1 = path + '\\' + filename im = Image.open(path1).convert('RGBA') im_01 = ImageTk.PhotoImage(im) bild_list_image.append(im_01) print('bild_list_image: OK') root.mainloop()