简体   繁体   English

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

[英]What is PyQt's equivalent to tkinter's canvas?

I've recently decided to try switching from tkinter to PyQt , but I'm having trouble figuring out how to do what I could do with tkinter 's canvas widget. 我最近决定尝试从tkinter切换到PyQt ,但我无法弄清楚如何使用tkinter的canvas小部件做我能做的事情。

After some googling, it seems like it's either QPainter , QPixMap , or some combination thereof. 经过一些谷歌搜索,它似乎是QPainterQPixMap或其中的一些组合。 There also seems to be something in Qt called canvas but I don't think that's what I'm looking for. Qt似乎还有一些叫做canvas东西,但我不认为这就是我在寻找的东西。

Could someone explain what I should be using to draw lines and shapes on the screen, and point me to a good tutorial on how to use it? 有人可以解释我应该使用什么来在屏幕上绘制线条和形状,并指出我如何使用它的一个很好的教程?

Thanks 谢谢

I think what you need here is QPainter class, Quoting from PyQt Sourceforge documentation: 我认为你需要的是QPainter类,从PyQt Sourceforge文档引用:

The QPainter class performs low-level painting on widgets and other paint devices. QPainter类在小部件和其他绘图设备上执行低级绘制。

QPainter provides highly optimized functions to do most of the drawing GUI programs require. QPainter提供高度优化的功能,以满足大多数绘图GUI程序的要求。 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. QPainter可以对继承QPaintDevice类的任何对象进行操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM