I have a question about using the Tkinter Canvas object for making a GUI in Python.
When creating your frame object you give it the width and height you would like it to have. Is there a way to detect the size of it's container and use that for it's width and height?
For example lets say you wanted to created a Canvas that would always take up space equal to the entire Top Right Corner of the screen, even if your window was to be resized, or you were to use the Frame it's contained in in another program that maybe has another Frame taking up other screen space.
Take this for example:
import tkinter as tk
root = tk.Tk()
root.geometry("800x480")
container = tk.Frame(root, bg = "yellow")
container.pack(expand = True, fill = "both")
drawArea = tk.Canvas(container, bg = "red")
drawArea.pack()
In the above code the canvas will not take up the entirety of the yellow frame it is place in. I know if I want to set it to be the full size of the yellow frame I add expand = True, fill = "both"
to the .pack()
statement. However what if I only want it to be 2/3 of the Frame? Or half the width and height of the frame? Is it possible to do that?
Maybe I suck at Googling, but I can't seem to find any info on this online :\