python – 什么是PyQt相当于tkinter的画布?

我最近决定尝试从tkinter切换到PyQt,但我无法弄清楚如何使用tkinter的canvas小部件做我能做的事情.

经过一些谷歌搜索,它似乎是QPainter,QPixMap或其中的一些组合.在Qt中似乎还有一些叫做canvas的东西,但我不认为这就是我在寻找的东西.

有人可以解释我应该使用什么来在屏幕上绘制线条和形状,并指出我如何使用它的一个很好的教程?

谢谢

最佳答案 我认为你需要的是
QPainter类,引自PyQt Sourceforge文档:

The QPainter class performs low-level painting on widgets and other
paint devices.

QPainter provides highly optimized functions to do most of the drawing
GUI programs require. It can draw everything from simple lines to
complex shapes like pies and chords. It can also draw aligned text and
pixmaps. Normally, it draws in a “natural” coordinate system, but it
can also do view and world transformation. QPainter can operate on any
object that inherits the QPaintDevice class.

点赞