I'm new at tkinter.
I'd like to fill the Label with image. but it doesn't work at OOP structure.
For example,
import os
import cv2
import tkinter as tk
root = tk.Tk()
img = tk.PhotoImage(file='../resource/default.png')
capture = tk.Label(root, text="Class", compound="top", image=img)
capture.pack()
root.mainloop()
above is working, but below is not working.
How can I make it working with class (like below code)?
import os
import cv2
import tkinter as tk
class App(tk.Label):
def __init__(self, master=None):
tk.Label.__init__(self, master)
img = tk.PhotoImage(file='../resource/default.png')
self.configure(text="Class", compound="top", image=img)
self.pack()
root = tk.Tk()
App(root)
root.mainloop()