pass the canvas in the function.
or
example
def show_stim(canvas, stim, side, verpos, police): #etc canvas.create_text(x, y, text=stim.value, fill=stim.color, font=police)
or
example
import tkinter as tk import tkinter.font as font # global container class PrimTask: pass def show_stim(stim, side, verpos, police): x = PrimTask.screensize[0]/2 + side y = PrimTask.screensize[1]/2 + verpos PrimTask.canvas.create_text(x, y, text=stim, fill='blue', font=police) def main(): PrimTask.screensize = 800, 600 PrimTask.root = tk.Tk() PrimTask.canvas = tk.Canvas(PrimTask.root, background='black', height = PrimTask.screensize[1], width = PrimTask.screensize[0]) PrimTask.canvas.pack() #fonts definition italic = font.Font(PrimTask.root, family='Times', size=50, slant='italic') underline = font.Font(PrimTask.root, family='Times', size=50, underline=1) polices=[italic, underline] show_stim('lettre', 150, 150, italic) PrimTask.root.mainloop() if __name__ == '__main__': main()
99 percent of computer problems exists between chair and keyboard.