Click here to Skip to main content
15,434,147 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
from PIL import Image,ImageTk
from tkinter import*
from tkinter.font import BOLD


class HotelManagementSystem:
    def __init__(self,root):
        self.root=root
        self.root.title=("Hotel Management System")
        self.root.geometry("1366x768+0+0")

        img1=Image.open(r"D:\python\project 1\photo1.png")
        img1=img1.resize((1366,140),Image.ANTIALIAS)
        self.photoimg1=ImageTk.PhotoImage(img1)

        lblimg=Label(self.root,image=self.photoimg1,bd=4,relief=SUNKEN)
        lblimg.place(x=0,y=0,width=1366,height=140 )





if __name__=="__main__":
    root=Tk()
    obj=HotelManagementSystem(root)
    root.mainloop()


What I have tried:

type object 'Image' has no attribute 'open'
Posted
Updated 21-Jun-22 1:34am
v2

 
Share this answer
 
The problem is caused by the order of the import statements. When using tkinter with pillow you need to import the tkinter modules before PIL thus:
Python
from tkinter import*
from tkinter.font import BOLD
from PIL import Image,ImageTk
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900