I've been posing on here about my learning project as some of you have read.
Currently I'm working on learning more on classes and methods.
While re-writing my script something unexpected happened.
The original code will show the header image but, the re-written code will not.
I can put text on the label and it will work. I can put color on the container frame and widget.
I can even use tk.Label and the size of the container will be there.(See image below)
For the life of me, I can't seem to get the image to show.
[Image: book.png]
Relevant code
Currently I'm working on learning more on classes and methods.
While re-writing my script something unexpected happened.
The original code will show the header image but, the re-written code will not.
I can put text on the label and it will work. I can put color on the container frame and widget.
I can even use tk.Label and the size of the container will be there.(See image below)
For the life of me, I can't seem to get the image to show.
[Image: book.png]
Relevant code
import tkinter as tk from tkinter import ttk class RootWindow: '''RootWindow''' def __init__(self, master): self.master = master self.master.grid_columnconfigure(0, weight=1) self.master.rowconfigure(0, weight=1) self.logo_frame() Child(self.logoframe) def logo_frame(self): '''logo frame''' style= ttk.Style() style.configure('TY.TFrame', background='orange') self.logoframe = ttk.Frame(self.master, border=5, relief='ridge', style='TY.TFrame') self.logoframe.grid(column=0, row=0, sticky='new') self.logoframe.grid_columnconfigure(0, weight=3) class Child: '''Child''' def __init__(self, logoframe): self.my_logo(logoframe) def my_logo(self, logoframe): '''logo''' self.imgfile = tk.PhotoImage(file='/home/johnny/Desktop/CookBook/images/cookbook_logo.png') img_logo = tk.Label(logoframe, image=self.imgfile, anchor='n', bg='pink') img_logo.grid(column=0, row=0, sticky='new') def main(): '''main''' root = tk.Tk() root.resizable(width=False, height=False) RootWindow(root) root.mainloop() if __name__ == '__main__': main()
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags
Download my project scripts
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags
Download my project scripts