import sys
import tkinter as tk
import tkinter.messagebox as tkm
import random
root = tk.Tk()
root.title(u'Buttonを使ってみる')
root.geometry('400x300')
def draw(event):
canvas.create_rectangle(random.randint(0, 300), random.randint(0, 200), random.randint(0, 400), random.randint(0, 250), tag="rectangle", fill='green', outline='#00f')
def erase(event):
canvas.delete("rectangle")
canvas = tk.Canvas(root, width = 400, height = 250)
canvas.place(x=0, y=0)
button_draw = tk.Button(root, text=u'描く', width=15)
button_draw.bind("<Button-1>", draw)
button_draw.place(x=50, y=260)
button_draw = tk.Button(root, text=u'消す', width=15)
button_draw.bind("<Button-1>", erase)
button_draw.place(x=200, y=260)
root.mainloop()