CustomTkinter icon indicating copy to clipboard operation
CustomTkinter copied to clipboard

Issues loading "pyimage1"

Open yoboy1102 opened this issue 1 year ago • 0 comments

I have an Airline Project that was working perfectly untill randomly has stopped runneing and is showing errors,

  • python --3.12.6
  • pillow --10.4.0
  • customtkinter --5.2.2
import customtkinter as ctk
from customtkinter import *
from tkinter import *
from tkinter import messagebox
from PIL import Image, ImageTk
from pathlib import Path
from tkinter import Canvas
from tkinter import PhotoImage
from Homepage import HomePage
from TopMenu import TopMenu
from Departure import DepartuePage
from Spinbox import FloatSpinbox
from tkcalendar import Calendar

OUTPUT_PATH = Path(__file__).parent
ASSETS_PATH = OUTPUT_PATH / Path(r"c:\Users\Arubaaa\OneDrive\Desktop\DESKTOP\kama 2024\build\assets\frame0")

def relative_to_assets(path: str) -> Path:
    return ASSETS_PATH / Path(path)

web = ctk.CTk()
ctk.set_appearance_mode('light')
ctk.set_default_color_theme('dark-blue')
web.geometry("1880x1000")
web.configure(bg = "#FCFFDD")

canvas = Canvas(
    web,
    bg = "#FCFFDD",
    height = 1000,
    width = 1880,
    bd = 0,
    highlightthickness = 0,
    relief = "ridge"
)
canvas.place(x = 0, y = 0)
image_image_1 = PhotoImage(
    file=relative_to_assets("image_1.png"))
image_1 = canvas.create_image(
    940.0,
    500.0,
    image=image_image_1
)

#-----rest of the code is too big and irrevalent to the issue------#

web.mainloop()

This isnt the finished code but the code does stop working here,

Traceback (most recent call last):
  File "c:\Users\Arubaaa\OneDrive\Desktop\DESKTOP\kama 2024\Project\MAIN.py", line 40, in <module>
    image_1 = canvas.create_image(
              ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Arubaaa\AppData\Local\Programs\Python\Python311\Lib\tkinter\__init__.py", line 2846, in create_image
    return self._create('image', args, kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Arubaaa\AppData\Local\Programs\Python\Python311\Lib\tkinter\__init__.py", line 2832, in _create     
    return self.tk.getint(self.tk.call(
                          ^^^^^^^^^^^^^
_tkinter.TclError: image "pyimage1" doesn't exist

Here`s the Error, if I comment out image_1, the next image I get "pyimage2" doesnt exist

Note: the files I import, SpinBox, DeparturePage, TopMenu, etc are just other .py files, they work individually aswell

Any Idea what would help

yoboy1102 avatar Sep 25 '24 05:09 yoboy1102