So I am relatively new to python and its packages doing a project for school, messed around with the smaller features of the libraries and now im trying to put it all together in an MVC format.
The issue I am having is not rendering my child Frames with background images on the view to develop a 3 section layout. Here is a sample of what I expect the GUI layout to be like. enter image description here
And my code for the application and view are as follows but I only get a grey window to open. I was previously able to render these images as backgrouds for the frame and for a splash screen in smaller test applications using the same techniques.
`import tkinter as tk import pandas
from Controller import Controller from Model import Model from View import View
class App(tk.Tk):
def __init__(self):
super().__init__()
self.title("MVC_CSV_GUI DEMO")
nasa = pandas.read_csv("NASA2.csv")
planet_data = nasa.to_dict('records')
model = Model(planet_data)
view = View(self)
controller = Controller(model, view)
view.set_controller(controller)
width = self.winfo_screenwidth()
height = self.winfo_screenheight()
self.geometry(f"{width}x{height}")
view.master.geometry(f"{width}x{height}")
view.pack(fill=tk.BOTH, expand=True)
if __name__ == '__main__':
app = App()
app.mainloop()
import tkinter
from tkinter import ttk, PhotoImage
class View(ttk.Frame):
def __init__(self, parent):
super().__init__(parent)
self.controller = None
# Define the parent frame size
WIDTH = self.winfo_screenwidth()
HEIGHT = self.winfo_screenheight()
# define the layout frame sizes
MENU_FRAME_WIDTH = WIDTH // 3
CONSOLE_FRAME_HEIGHT = HEIGHT // 4
FILTER_FRAME_WIDTH = WIDTH - MENU_FRAME_WIDTH
FILTER_FRAME_HEIGHT = HEIGHT - CONSOLE_FRAME_HEIGHT
MENU_FRAME_HEIGHT = HEIGHT - CONSOLE_FRAME_HEIGHT
# layout frames
menu_frame = ttk.Frame(self, height=MENU_FRAME_HEIGHT, width=MENU_FRAME_WIDTH)
filter_frame = ttk.Frame(self, height=FILTER_FRAME_HEIGHT, width=FILTER_FRAME_WIDTH)
console_frame = ttk.Frame(self, height=FILTER_FRAME_HEIGHT, width=WIDTH)
# Set menu background
menu_image = PhotoImage(file="MenuS.png")
# menu_image = menu_image.resize((MENU_FRAME_WIDTH, MENU_FRAME_HEIGHT))
menu_label = ttk.Label(menu_frame, image=menu_image)
menu_label.place(relwidth=1, relheight=1)
# set filter frame background
filter_image = PhotoImage(file="galaxyS.png")
filter_label = ttk.Label(filter_frame, image=filter_image)
filter_label.place(relwidth=1, relheight=1)
# create scrollable text box
console_text = tkinter.Text(console_frame, bg='black', fg='white', wrap='word')
console_scrollbar = tkinter.Scrollbar(console_frame, orient='vertical', command=console_text.yview)
console_text.configure(yscrollcommand=console_scrollbar.set)
console_text.pack(side='left', fill='both', expand=True)
console_scrollbar.pack(side='right', fill='y')
# pack frames
menu_frame.pack(side='left', fill='both', expand=True)
filter_frame.pack(side='right', fill='both', expand=True)
console_frame.pack(side='bottom', fill='both', expand=True)
def set_controller(self, controller):
self.controller = controller
`
any advice on where i may be going wrong here would be appreciated, thanks
I was expecting an appliation window that would launch my view class as a parent frame in which 3 child frames would be placed and lkabeled with background images to act as layout containers for all my widgets.