from tkinter import *
from tkinter import ttk

lastx, lasty = 0, 0

def xy(event):
  global lastx, lasty
  lastx, lasty = event.x, event.y

def addLine(event):
  global lastx, lasty
  canvas.create_line((lastx, lasty, event.x, event.y))

root = Tk()
root.columnconfigure(0, weight = 1)
root.rowconfigure(0, weight = 1)

canvas = Canvas(root)
canvas.grid(column = 0, row = 0, sticky = (N, W, E, S))
canvas.bind("<Button-1>", xy)
canvas.bind("<B1-Motion>", addLine)

root.mainloop()

