r/learnpython • u/L_Y_H_ • 2d ago
What is the point of getcanvas()? And the method get()
Hi, I'm currently on an assignment that requires me to use this function, but not only have we never seen it in class but all the research I've done haven't help me at all. My teacher also mentions the method get() in the instruction and I'm also confused by it.
Edit More details
Long story short, my assignement is to create a "forest". For that I created functions to draw the trees but I still have to create a window and a button that allows the user to choose how many trees will be drawn in it. It's at that point that I have to use the "getcanvas()" to supposedly make a window and the "get()" in a function that will be used as a command in the button.
from random import*#Used in functions
from turtle import*
from tkinter import*
from math import* #Used in functions
master= getcanvas().master #Exact line my teacher wants us to use
screen = Screen()
screen.setup(800,500)
colormode(255)
screen.bgcolor(0, 46, 122)
speed(2000)
#What I'd like to do with it
def nbreSapin(): #Function in which I have to use 'get()' to get the number of trees
nb= int(input("How many trees:"))
if nb<100 and nb>0:
getsapin(nb)
else:
pass