May 2019
Intermediate to advanced
542 pages
13h 37m
English
Now that our GUI is squared away, it's time to create MainView.build_image(). This method will contain all of the image manipulation and painting methods.
We'll begin by adding the following code:
def build_image(self, data): if not data.get('image_source'): self.image.fill(qtg.QColor('black')) else: self.image.load(data.get('image_source')) if not (self.max_size - self.image.size()).isValid(): # isValid returns false if either dimension is negative self.image = self.image.scaled( self.max_size, qtc.Qt.KeepAspectRatio)
Our first task is to set up the base image of our meme. If we don't have an image_source value in the form data, then we'll just fill our QImage object with the color black, providing us a blank canvas ...
Read now
Unlock full access