更改画布、Tkinter、Python 中像素的颜色 [英] Change the color of a pixel in a canvas, Tkinter, Python
问题描述
有人知道是否可以在不使用 un 对象的情况下更改画布中像素的颜色,因此不使用诸如 canvas.create_oval
或 canvas.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屋!