Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_tkinter.TclError: couldn't recognize image data #5

Open
Xenoman81 opened this issue Jan 23, 2025 · 0 comments
Open

_tkinter.TclError: couldn't recognize image data #5

Xenoman81 opened this issue Jan 23, 2025 · 0 comments

Comments

@Xenoman81
Copy link

Trying to open any NetCDF file, I get this tkinter error:

Traceback (most recent call last):
  File "/gpfs/work/-/temp/nc2/venv/bin/nc2", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/gpfs/work/-/temp/nc2/venv/lib/python3.12/site-packages/nc2/nc2.py", line 1367, in main
    root = tb.Window(themename='darkly')
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/gpfs/work/-/temp/nc2/venv/lib/python3.12/site-packages/ttkbootstrap/window.py", line 231, in __init__
    self._icon = tkinter.PhotoImage(master=self, data=Icon.icon)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/apps/shared/taifun/x86_64/apps/DATAPROCESSING/python/3.12.7/system/lib/python3.12/tkinter/__init__.py", line 4162, in __init__
    Image.__init__(self, 'photo', name, cnf, master, **kw)
  File "/apps/shared/taifun/x86_64/apps/DATAPROCESSING/python/3.12.7/system/lib/python3.12/tkinter/__init__.py", line 4109, in __init__
    self.tk.call(('image', 'create', imgtype, name,) + options)
_tkinter.TclError: couldn't recognize image data

This is clearly not caused by NC2 code, but by tkinter and/or ttkbootstrap. A quick search points to a TCL version issue, apparently requiring at least TCL 8.6:.

The reason for this is the limited image format support of TCL, as discussed here. And although Pillow is a NC2 dependency, it does not resolve this issue. Is seems that only upgrading from my TCL 8.5 to >=8.6 would help, but this requires admin rights.

A way to reproduce this error, or to confirm the correct functioning

from tkinter import *
root = Tk()

canv = Canvas(root, width=80, height=80, bg='white')
canv.grid(row=2, column=3)

img = PhotoImage(data=Icon.warning)  # It fails here already

canv.create_image(20,20, anchor=NW, image=img)

mainloop()
@Xenoman81 Xenoman81 marked this as a duplicate of #4 Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant