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
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.
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 ...
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With