更改画布、Tkinter、Python 中像素的颜色 [英] Change the color of a pixel in a canvas, Tkinter, Python

查看:42
本文介绍了更改画布、Tkinter、Python 中像素的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道是否可以在不使用 un 对象的情况下更改画布中像素的颜色,因此不使用诸如 canvas.create_ovalcanvas.create_rectangle 之类的东西?

Someone know if it's possible to change the color of a pixel in a canvas without using un object, so without using something like canvas.create_oval or canvas.create_rectangle ?

推荐答案

tkinter 本身中,这是不可能的.

Within tkinter itself, it's impossible.

即使您设法更改画布窗口上的像素(这在 X11 和 Windows API 中以平台相关的方式是可能的),您也必须确保正确重新绘制.

Even if you manage to change a pixel on canvas window (which is possible with X11 and Windows APIs in a platform-dependent way), you'd have to ensure it's repainted properly.

当然,您可以在画布上放置一个大小为 1x1 的 frame,并带有您想要的背景颜色.这样,像素被改变"并且没有创建画布对象.如果问题背后有一个真正(虽然很奇怪)的问题,这个技巧可能是一个解决方案.

You can, of course, place a frame of size 1x1 over the canvas, with a background color you want. This way, pixel is "changed" and no canvas object is created. If there's a real (though strange) problem behind a question, this trick could be a solution.

这篇关于更改画布、Tkinter、Python 中像素的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆