Skip to content

Commit eddb774

Browse files
Menubar exit fix
1 parent a9a083d commit eddb774

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

Source/image_viewer.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,20 @@
66
# Define the image file path
77
image_path = "data_image.png"
88

9+
window = None # Declare the window variable
10+
911
def open_image():
1012
file_path = filedialog.askopenfilename(filetypes=[("Image files", "*.png *.jpg *.jpeg *.gif *.bmp *.ppm *.pgm *.tif *.tiff")])
1113
if file_path:
1214
display_image(file_path)
1315

1416
def exit_viewer():
15-
window.destroy()
17+
if window:
18+
window.destroy()
1619

1720
def display_image(image_path, resize_width=None, resize_height=None):
21+
global window # Use the global window variable
22+
1823
# Create a new window
1924
window = tk.Tk()
2025
window.title("Pixel Data Image Viewer")

0 commit comments

Comments
 (0)