"""GUI utility functions.Specifically, this module provides :func:`ccu.fancyplots._gui.utils.open_image`,which opens a Tkinter-compatible version of an image shipped with:mod:`ccu`, and :func:`ccu.fancyplots._gui.utils.print_easter_egg`, which printsan Easter egg."""importimportlibfromPILimportImagefromPILimportImageTkfromccu.__about__import__version___EASTER_EGG_WIDTH=103
[docs]defopen_image(name:str,width:int,height:int)->ImageTk.PhotoImage:"""Open Tkinter-compatible version of a ``ccu`` image. Args: name: The name of the image to open. width: The width of the image when opened. height: The height of the image when opened. Returns: A Tkinter-compatible version of the opened image. """images_=importlib.resources.files("ccu.fancyplots.images")image=Image.open(images_.joinpath(name))resized_image=image.resize((width,height),Image.LANCZOS)tk_image=ImageTk.PhotoImage(resized_image)returntk_image