保存图像时出现问题
我在保存图像时遇到问题。我有以下部分代码:
self.canvas.postscript(file = filename, colormode = "color")
它工作得很好,但是当我在画布构造函数中设置背景颜色时(fe bg='red'), 最后图像没有这种背景颜色。它仍然是白色的。
有人可以帮助我吗?
I have a problem with saving an image. I have following part of code:
self.canvas.postscript(file = filename, colormode = "color")
It works good, but when I set background color in canvas constructor (f.e. bg='red'),
finally image doesn't have this background color. It is still white.
Could anybody help me ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来您正在使用 Tkinter:是吗?
我认为问题在于 bg 参数是所有小部件共享的通用属性。它实际上是小部件在屏幕上绘制方式的一部分,而不是您在画布中构建的图像的一部分。我认为对您来说最简单的事情就是在画布上绘制一个红色框作为背景 - 然后将其作为保存在 postscript 文件中的图像的一部分包含在内。
Sounds like you're using Tkinter: is that right?
I believe the problem is that the bg argument is a general property shared by all widgets. It's really a part of how the widget is drawn on the screen and not a part of the image you're constructing in your canvas. I think the easiest thing for you to do is to draw a red box in your canvas for your background - that will then be included as part of the image saved in your postscript file.