Aug-31-2020, 10:14 AM
I have a beginners question about importing files and not being able to use a function in this file because it can't 'look back'.
I have two files. main.py:
I have two files. main.py:
from tkinter import * from function import drawLine master = Tk() canvas_width = 80 canvas_height = 40 w = Canvas(master, width=canvas_width, height=canvas_height) w.pack() y = int(canvas_height / 2) drawLine() mainloop()and function.py:
def drawLine(): w.create_line(0, y, canvas_width, y, fill="#476042")I understand that 'function.py' cannot look into 'main.py'. How to write a function in 'function.py' that draws a line in the 'main.py' canvas? I hope someone can teach me about the way people work usually with drawing something on a canvas that is in another file :)