# cPy - show an svg drawing in a Tk GUI
# provided by Anthony Vogelaar,  Perth Scotland
# rev 0.10  2024-09-16  initial release

# remark: both Tk and PIL do not support SVG

import  os;         os.system('clear')
import  tkinter     as      tk
import  cairosvg    as      svg
import  io
from    PIL         import  Image, ImageTk

# ============================ main ===========================

def main():
    app     = tk.Tk()
    app.geometry('200x200')
    stream  = io.BytesIO()
    svg.svg2png(url='img.svg', write_to=stream)
    pil_img = Image.open(stream)
    tk_img  = ImageTk.PhotoImage(pil_img)
    lb      = tk.Label(app, image=tk_img)
    lb.pack(expand='yes')
    app.mainloop()


main()

# ============================= end ===========================
