Reputation: 312
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
Upvotes: 6
Views: 8861
Reputation: 10951
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.
Upvotes: 5