python - 将绘图板输入保存为 JPEG
问题描述
我创建了一个简单的绘图板:
from tkinter import *
canvas_width = 500
canvas_height = 150
def paint( event ):
python_green = "#476042"
x1, y1 = ( event.x - 1 ), ( event.y - 1 )
x2, y2 = ( event.x + 1 ), ( event.y + 1 )
w.create_oval( x1, y1, x2, y2, fill = python_green )
master = Tk()
master.title( "Painting using Ovals" )
w = Canvas(master,
width=canvas_width,
height=canvas_height)
w.pack(expand = YES, fill = BOTH)
w.bind( "<B1-Motion>", paint )
message = Label( master, text = "Press and Drag the mouse to draw" )
message.pack( side = BOTTOM )
mainloop()
有没有办法将绘图保存和转换为白色背景的 JPG(也许通过添加按钮)?
解决方案
推荐阅读
- intellij-idea - IntelliJ 主题:自定义编辑器选项卡关闭按钮的 bg-color
- java - @JsonIgnore 不在不同的环境中工作
- amazon-ec2 - 从外部访问 EC2 实例内 minikube 的 NodePort 上运行的应用程序
- python - 识别沿堆叠二维 numpy 数组的第三维的所有唯一组合
- vue.js - 从 getter 设置数据字段并添加额外的计算字段
- c++ - 插入数字后 C++ 崩溃
- rest - 无法从 BizTalk 管理 REST Api 连接到 BizTalkMgmtDb 数据库
- r - 在 R 中应用将 Df 列乘以矩阵行的函数
- d3.js - 自定义对角线背景纹理
- reactjs - 每次构建都成功,但是开发服务器正在关闭