Could you help me? I'm trying to close my main window and then create a new window. I'm using withdraw() instead of destroy() since I'm planning to use that widget later.
Here is my code, but I just get: tkinter.TclError: image "pyimage10" doesn't exist
I separated the codes of the main window and a new window into two python file, which are "Page1" and "Page2".
Sorry for my rough English. Any help to fix this would be much appreciated:)
tkinter.TclError: image "pyimage10" doesn't existseems to occur at image_2 = canvas.create_image(
Page1
from tkinter import Tk, Canvas, Entry, Text, Button, PhotoImage
OUTPUT_PATH = Path(__file__).parent
ASSETS_PATH = OUTPUT_PATH / Path("./assets")
def relative_to_assets(path: str) -> Path:
return ASSETS_PATH / Path(path)
window = Tk()
window.geometry("703x981")
window.configure(bg = "#FFFFFF")
button_image_6 = PhotoImage(
file=relative_to_assets("button_6.png"))
button_6 = Button(
image=button_image_6,
borderwidth=0,
highlightthickness=0,
command=lambda: ("WM_DELETE_WINDOW", nextPage()),
relief="flat"
)
button_6.place(
x=415.0,
y=793.0,
width=86.0,
height=78.0
)
def nextPage():
window.withdraw()
import Page2
Page2
from tkinter import Tk, Canvas, Entry, Text, Button, PhotoImage
window = Tk()
def relative_to_assets(path: str) -> Path:
return ASSETS_PATH / Path(path)
window.geometry("545x470")
window.configure(bg = "#FFFFFF")
window.title('PythonGuides')
canvas = Canvas(
window,
bg = "#FFFFFF",
height = 470,
width = 545,
bd = 0,
highlightthickness = 0,
relief = "ridge"
)
canvas.place(x = 0, y = 0)
image_image_2 = PhotoImage(
file=relative_to_assets("image_2.png"))
image_2 = canvas.create_image(
272.0,
175.0,
image=image_image_2
)