Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how the class works
#1
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?

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()
Reply


Messages In This Thread
how the class works - by berckut72 - Mar-16-2020, 06:38 PM
RE: how the class works - by buran - Mar-16-2020, 06:45 PM
RE: how the class works - by berckut72 - Mar-16-2020, 06:48 PM
RE: how the class works - by buran - Mar-16-2020, 06:52 PM
RE: how the class works - by berckut72 - Mar-16-2020, 06:57 PM
RE: how the class works - by buran - Mar-16-2020, 09:43 PM
RE: how the class works - by berckut72 - Mar-17-2020, 05:04 AM
RE: how the class works - by buran - Mar-17-2020, 06:31 AM
RE: how the class works - by berckut72 - Mar-17-2020, 09:54 AM
RE: how the class works - by buran - Mar-17-2020, 09:56 AM
RE: how the class works - by berckut72 - Mar-17-2020, 10:03 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020