How to use the guizero.utilities.GUIZeroImage function in guizero

To help you get started, we’ve selected a few guizero examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lawsie / guizero / guizero / Picture.py View on Github external
def _load_image(self):
        if self._height == "fill" or self._width == "fill":
            utils.raise_error("{}\nCannot use 'fill' for width and height.".format(self.description))

        if self._image_source is not None:

            # stop any animation which might still be playing
            if self._image_player:
                self._image_player.stop()

            # load the image and set its properties
            self._image = utils.GUIZeroImage(self._image_source, self._width, self._height)

            self._width = self._image.width
            self._height = self._image.height

            # if its an animation, start it up
            if self._image.animation:
                self._image_player = utils.AnimationPlayer(self, self._image, self._update_tk_image)
            else:
                self._update_tk_image(self._image.tk_image)

            self.tk.config(width=self._width)
            self.tk.config(height=self._height)
github lawsie / guizero / guizero / PushButton.py View on Github external
def _load_image(self):
        if self._height == "fill" or self._width == "fill":
            utils.raise_error("{}\nCannot use 'fill' for width and height when using a image.".format(self.description))

        # stop any animation which might still be playing
        if self._image_player:
            self._image_player.stop()

        self._image = utils.GUIZeroImage(self._image_source, self._width, self._height)

        # update the tk image
        # if its an animation, start it up
        if self._image.animation:
            self._image_player = utils.AnimationPlayer(self, self._image, self._update_tk_image)
        else:
            self._update_tk_image(self._image.tk_image)

        # set the width and height of the widget to match the image if they are None
        super(PushButton, self.__class__).resize(
            self, 
            self._image.width if self.width is None else self.width, 
            self._image.height if self.height is None else self.height)
github lawsie / guizero / guizero / Drawing.py View on Github external
:param str image:
            The file path or a PhotoImage or PIL.Image object.

        :param str width:
            The width to scale the image too, setting to `None` will use the
            actual width of the Image. Default to `None`.

        :param str height:
            The width to scale the image too, setting to `None` will use the 
            actual height of the Image. Default to `None`.

        :return:
            The id of the image.
        """
        # load the image and add to the dict (otherwise tk destroys the reference to them!)
        _image = utils.GUIZeroImage(image, width, height)
        id = self.tk.create_image(x, y, image=_image.tk_image, anchor="nw")
        self._images[id] = _image
        return id