There are so many options provided by Python to develop GUI application and PyQt5 is one of them. PyQt5 is cross-platform GUI toolkit, a set of python bindings for Qt v5. One can develop an interactive desktop application with so much ease because of the tools and simplicity provided by this library.
In this tutorial we’ll take a look how to save canvas in
pyqt5. We draw things on canvas using
QPainter : Qt’s painting system is able to render vector graphics, images, and outline font-based text with sub-pixel accuracy using anti-aliasing to improve rendering quality.
In this article, we create a canvas and will draw a line on it and see how to save that canvas as image file at desired location on the system. Below is the implementation.
After running the code window will appear with a canvas of white color on which line is drawn.
After clicking on the file menu save button will appear.
When save button is pressed it will ask for the location and name and image will get saved at desirable location.
This code will save the canvas in
png format at the desired location.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course