-
Notifications
You must be signed in to change notification settings - Fork 85
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
Photo Image Error #7
Comments
Yeah, it looks like there is a thread running where PhotoImage objects are created even after the window is closed. I will try to catch these errors or stop the thread in time. |
The error should be resolved now with version 1.6, if you experience it again, just mention it here... |
Thank you greatly for looking into it. :) |
I have a new problem ! Even if i download version 1.6 i have this f*cking error again... How do i do ? I'm really confuse because i see many people making apps with this and all of their apps works and mine not working for none reasons ! Anyway, good bye ! |
Can you post your code or a smaller example where the error appears? |
from tkinter import *
from tkinter.ttk import *
from tkinter import ttk
from PIL import *
import tkintermapview
import tkinter
import tkinter.messagebox as mb
def mapsapp():
# create tkinter window
root_tk = tkinter.Tk()
root_tk.geometry(f"{1000}x{700}")
root_tk.title("map_view_simple_example.py")
# create map widget
map_widget = tkintermapview.TkinterMapView(root_tk, width=1000, height=700, corner_radius=0)
map_widget.pack(fill="both", expand=True)
# set other tile server (standard is OpenStreetMap)
# map_widget.set_tile_server("https://mt0.google.com/vt/lyrs=m&hl=en&x={x}&y={y}&z={z}&s=Ga", max_zoom=22) # google normal
# map_widget.set_tile_server("https://mt0.google.com/vt/lyrs=s&hl=en&x={x}&y={y}&z={z}&s=Ga", max_zoom=22) # google satellite
# set current position and zoom
# map_widget.set_position(52.516268, 13.377695, marker=False) # Berlin, Germany
# map_widget.set_zoom(17)
# set current position with address
# map_widget.set_address("Berlin Germany", marker=False)
def marker_click(marker):
print(f"marker clicked - text: {marker.text} position: {marker.position}")
# set a position marker (also with a custom color and command on click)
marker_2 = map_widget.set_marker(52.516268, 13.377695, text="Brandenburger Tor", command=marker_click)
marker_3 = map_widget.set_marker(52.55, 13.4, text="52.55, 13.4")
# marker_3.set_position(...)
# marker_3.set_text(...)
# marker_3.delete()
# set a path
path_1 = map_widget.set_path([marker_2.position, marker_3.position, (52.568, 13.4), (52.569, 13.35)])
# path_1.add_position(...)
# path_1.remove_position(...)
# path_1.delete()
root_tk.mainloop() This is my code ! |
Which operating system are you working on? |
I'm working on Windows 10 ! |
I have tkintermapview on an install on my work laptop and it seems to run fine. However, when I try to get it to work on my private laptop, it keeps throwing this error: File "***\anaconda3\lib\site-packages\PIL\ImageTk.py", line 118, in del EDIT: it seems this error pops up when the .mainloop() command is not active (it was for some reason I can't remember commented in my code) |
Same problem in raspberrypi os. It's because lack of Pillow module. Installing pillow >9.0.1 will slove the problem. |
I have the same error running it with your map_view_simple_example.py code. I am using mac 12.0.1. |
I have this same issue too even after upgrading pillow. It seems to only happen if I don't use the default mainloop like BlaatVogel noted. It works fine when I use mainloop - however my (existing) script is using cefpython3, so I'm running a custom main loop that looks like this:
to combine both the tkinter GUI loop with the cef message loop. I think it's possible to have cef run on another thread, but I'll probably be getting rid of it anyways if this map widget works for me, as I was using the integrated browser to display an HTML map file anyways :) What's relying on the mainloop that's causing an issue with PhotoImage? |
It looks like the loop is still running but parts of the PhotoImage class don't exist anymore when the program gets closed. Like if they are garbage collected earlier than the loop, I don't know. I will try to put in some more try except blocks to catch these. |
I also gets the same error :-( |
I'm getting the same error. I have version 1.29. I'm using Python 3.9 and IDLE on a Windows 10 Pro computer with lots of horsepower and RAM. If there is an error anywhere in my code, this Photoimage class error keeps running. I have to kill the application completely, which means I can't read what my errors are because they continue to scroll off. I managed to take a snapshot of the error message. AttributeError: 'PhotoImage' object has no attribute '_PhotoImage__photo' I love this package, but it would be nice if the 403 error and this Photoimage error were eliminated. |
I just fixed my issue with the previously mentioned AttributeError: 'PhotoImage' object has no attribute '_PhotoImage__photo'. This error continues to scroll indefinitely after any other error is triggered in your code. It scrolls so fast that I cannot read my offending error message in the shell. Even CTRL-C and breakpoints are ignored with this AttributeError. I would have to kill the shell to end the program, and thus lose my error messages. I fixed the problem as follows: I opened ImageTk.py file in the site-packages\PIL folder and moved the "try" statement up by two rows. This put it in front of the problem line -- #118. Now when I get any other error, the code actually stops after that error instead of continuing infinitely with the AttributeError messages. I have not seen any other errors triggered by this edit. It's not elegant, but it has solved my problem. |
i see that error too, i assume that the cause is an exception in during the constructor init before __photo is created (line 126 in my version 10.4.0 of Pillow). this exception isnt logged and thus not visibile. i have no clue where that can happen but could that be a hint for someone knowing the code better? |
Hi. I love this project, but I sometimes receive these errors upon closing a window containing this widget. I experimented a bit, but I couldn't find a pattern for when it happens. It looks like it's trying to update the images and when you close the window right while the update happens, you get this error. But I could be wrong. It was never harmful anyways. It's just a mysterious text in the console, but it causes no problems. Still, I would like to find a way to remove/avoid this error. Can you give me some insight into it?
The text was updated successfully, but these errors were encountered: