I am trying to get a picture to fit within the bounds of a full screen window I have created. With this code:
import sys
import random
import tkinter as tk
from tkinter import *
from PIL import Image, ImageTk
window = tk.Tk()
width = window.winfo_screenwidth()
height = window.winfo_screenheight()
window.geometry("%dx%d" % (width, height))
window.title("War of the Ring")
def CloseProgram():
window.destroy()
window.quit()
def PlayMainGame():
#Destroy widgets and title
Title.destroy()
NewGameButton.destroy()
LoadGameButton.destroy()
OptionsButton.destroy()
global ResizedBoardImage
canvas = Canvas(window, width = width, height = height)
canvas.pack()
BoardImage = Image.open("Middle Earth Map.jpg")
ResizedBoardImage = BoardImage.resize((width, height), )
ResizedBoardImage = ImageTk.PhotoImage(BoardImage)
canvas.create_image(10,10, anchor = NW, image = ResizedBoardImage)
` I get the result in the photo, about a quarter of the image filling the entirety of the screen. No warnings or errors pop up in the shell. Not sure what I'm doing wrong.
I get the result in the photo, about a quarter of the image filling the entirety of the screen, when I was expecting the image to fit to the window screen.
No warnings or errors pop up in the shell. Not sure what I'm doing wrong.

Description: The issue is here in your code:
You are defining you tkinter window width and height according to your display.
For example if your windows resolution is
1920x1080then width in this snippetwidth = window.winfo_screenwidth()will be defined as 1920 and height in this snippetheight = window.winfo_screenheight()will be 1080.Issue: The tkinter window is so big that its expanding out of your screen if you reduce the tkinter windows height and width then it will work for you.
Solution: Considering your resolution is
1920x1080:Considering you resolution is
1600x900:Conclusion: Reduce the size of the tkinter window and do not keep it as same as your original resolution because windows widgets are also taking up some space of the window as well as the tkinter windows taskbar which makes the window to become bigger then the expected width and height.