Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

After some googling, it seems like it's either QPainter, QPixMap, or some combination thereof. There also seems to be something in Qt called canvas but I don't think that's what I'm looking for.

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

like image 511
sgfw Avatar asked Dec 29 '15 21:12

sgfw


People also ask

Which is faster Tkinter or PyQt?

Anyhow, in most situations, the best solution is using PyQt, considering the advantages and disadvantages of both PyQt and Tkinter. GUI programming with Qt is created around signals and slots for communication amongst objects. Thus, it allows flexibility, while it gets to the programmer access to a wide array of tools.

Which is better KIVY or Tkinter or PyQt?

In this article, we conclude that there is no much difference in Kivy or PyQt when speaking about working on GUI in Python, but they both are frameworks that work on different applications such Kivy is much better for mobile apps and other multi-touch apps than desktop apps, whereas PyQt is much better for desktop apps ...

What is the difference between Qt and PyQt?

PyQt is a Python binding for Qt, which is a set of C++ libraries and development tools providing platform-independent abstractions for graphical user interfaces (GUIs). Qt also provides tools for networking, threads, regular expressions, SQL databases, SVG, OpenGL, XML, and many other powerful features.

What is the difference between PyQt and Pyside?

The key difference in the two versions — in fact the entire reason PySide2 exists — is licensing. PyQt5 is available under a GPL or commercial license, and PySide2 under a LGPL license.


1 Answers

I think what you need here is QPainter class, Quoting from PyQt Sourceforge documentation:

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.

like image 196
Iron Fist Avatar answered Sep 20 '22 22:09

Iron Fist