tkinter / 何かを描く

import tkinter as tk

# ウィンドウを設定する。
W = 318
H = 212
window = tk.Tk()
window.geometry(str(W)+"x"+str(H))

#描画領域を設定する。
gc = tk.Canvas(window, width=W, height=H)
gc.place(x=0, y=0)

#何かを描く。
gc.create_oval(0, 0, H, H) # 左上座標、右下座標
gc.create_line(10,10, 50,20, 100,70, 100, 220)
gc.create_text(W/2, H/2, text="hello, world", font=("Arial", int(H/5)))

window.mainloop()

f:id:ti-nspire:20180118121450p:plain