class main(tk.Tk):
def __init__(self, *args, **kwargs):
tk.Tk.__init__(self, *args, **kwargs)
container = tk.Frame(self)
tk.Tk.geometry(self, "600x600")
tk.Tk.configure(self, bg='green')
container.pack(side='top', fill='both', expand=True)
container.grid_rowconfigure(0, weight=1)
container.grid_columnconfigure(0, weight=1)
self.frames = {}
for F in ([Login_Page, customer_menu, takeoutbook, return_book, admin_menu, add_user, add_book]):
frame = F(container, self)
self.frames[F] = frame
frame.grid(row=0, column=0, sticky="nsew")
self.show_frame(admin_menu
)
def show_frame(self, cont):
frame = self.frames[cont]
frame.tkraise()
class showbutton(tk.Button):
def __init__(self, master, label, **kw):
tk.Button.__init__(self, master=master, **kw)
self.label = label
self.defaultBackground = self['bg']
self.bind('<Enter>', self.enter)
self.bind('<Leave>', self.leave)
def enter(self, e):
self.label.configure(show='')
self['background'] = self['activebackground']
self['cursor'] = 'trek'
def leave(self, e):
self.label.configure(show='*')
self['background'] = self.defaultBackground
self['cursor'] = 'arrow'
class add_user(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
img = PhotoImage(filr = 'image.gif')
passwordrntry = tk.Entry(self , font = 'calibri 15').place(x = 10 , y = 10)
button = showbutton(self , passwordentry , font = 'calibri 16' , image = img1)
button.place(x = 20 , y = 20)
the image doesn't show up on the button whenever the frame is raise and whenever i hover over the button and then leave the button i get the error. whenever i comment out the self['background'] and self[cursor] part of the showbutton class the error no longer shows up but the image still doesn't appear on the button
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\Owner\AppData\Local\Programs\Python\Python37-32\lib\tkinter\__init__.py", line 1705, in __call__
return self.func(*args)
File "D:\Python\Obrien's library\library.py", line 323, in leave
self['background'] = self.defaultBackground
File "C:\Users\Owner\AppData\Local\Programs\Python\Python37-32\lib\tkinter\__init__.py", line 1492, in __setitem__
self.configure({key: value})
File "C:\Users\Owner\AppData\Local\Programs\Python\Python37-32\lib\tkinter\__init__.py", line 1485, in configure
return self._configure('configure', cnf, kw)
File "C:\Users\Owner\AppData\Local\Programs\Python\Python37-32\lib\tkinter\__init__.py", line 1476, in _configure
self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
_tkinter.TclError: image "pyimage1" doesn't exist