Drawing with Python Tinker

Complete image

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

code

sample.py


import tkinter as tk

#Draw a black dot (the larger the number, the bigger the dot)
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()

Commentary

A point (small circle) is drawn at the mouse position only while the click is pressed.

Recommended Posts

Drawing with Python Tinker
[python] Streamline drawing
FizzBuzz with Python3
Scraping with Python
Statistics with python
Scraping with Python
Twilio with Python
Integrate with Python
Play with 2016-Python
AES256 with python
python starts with ()
Bingo with python
Zundokokiyoshi with python
Excel with Python
Microcomputer with Python
Cast with python
[Python] Drawing a swirl pattern with turtle
Drawing with Matrix-Reinventor of Python Image Processing-
Try drawing a map with python + cartopy 0.18.0
Serial communication with Python
Django 1.11 started with Python3.6
Primality test with Python
Python with eclipse + PyDev.
Socket communication with Python
Data analysis with python 2
Scraping with Python (preparation)
Try scraping with Python.
Learning Python with ChemTHEATER 03
"Object-oriented" learning with python
Run Python with VBA
Handling yaml with python
Solve AtCoder 167 with python
Serial communication with python
[Python] Use JSON with Python
Learning Python with ChemTHEATER 05-1
Learn Python with ChemTHEATER
Run prepDE.py with python3
1.1 Getting Started with Python
Collecting tweets with Python
Binarization with OpenCV / Python
3. 3. AI programming with Python
Kernel Method with Python
Non-blocking with Python + uWSGI
Scraping with Python + PhantomJS
Graph drawing in python
Posting tweets with python
Drive WebDriver with python
Use mecab with Python3
[Python] Redirect with CGIHTTPServer
Voice analysis with python
Think yaml with python
Getting Started with Python
Use DynamoDB with Python
Zundko getter with python
Handle Excel with python
Ohm's Law with Python
Primality test with python
Solve Sudoku with Python
Python starting with Windows 7
Heatmap with Python + matplotlib
Python programming with Atom