LoginSignup
1
1

More than 3 years have passed since last update.

PythonのTinkerを使ってお絵かき

Last updated at Posted at 2020-03-29

完成イメージ

スクリーンショット 2020-03-29 午後10.19.21.png

コード

sample.py
import tkinter as tk

# 黒(black)の点を描画(数字を大きくすると、大きな点になります。)
def myMotion(mouse):
    cv.create_oval(mouse.x - 1, mouse.y - 1, mouse.x + 1, mouse.y + 1, fill = "black")

win = tk.Tk()
cv = tk.Canvas(win, width = 600, height = 400)
cv.create_rectangle(0, 0, 600, 400, fill = "white")
cv.pack()

win.bind("<B1-Motion>", myMotion)

win.mainloop()

解説

クリックを押している間だけマウスの位置に点(小さい円)を描画しています。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1