PyQt 等同于 tkinter 的 canvas 是什么?
What is PyQt's equivalent to tkinter's canvas?
我最近决定尝试从 tkinter
切换到 PyQt
,但我无法弄清楚如何使用 tkinter
的 canvas 小部件。
谷歌搜索后,它似乎是 QPainter
、QPixMap
或它们的某种组合。 Qt
中似乎也有一些叫做 canvas
的东西,但我认为这不是我要找的东西。
谁能解释一下我应该使用什么在屏幕上绘制线条和形状,并指出有关如何使用它的好教程?
谢谢
我想你这里需要的是QPainter
class,引用自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.
我最近决定尝试从 tkinter
切换到 PyQt
,但我无法弄清楚如何使用 tkinter
的 canvas 小部件。
谷歌搜索后,它似乎是 QPainter
、QPixMap
或它们的某种组合。 Qt
中似乎也有一些叫做 canvas
的东西,但我认为这不是我要找的东西。
谁能解释一下我应该使用什么在屏幕上绘制线条和形状,并指出有关如何使用它的好教程?
谢谢
我想你这里需要的是QPainter
class,引用自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.