tkintermapview PhotoImage object has no attribute '_PhotoImage__photo' - python

I am making a project based on tkintermapview, but it throws the error when the following code is run.
import tkintermapview as tkmap
self.map = tkmap.TkinterMapView(self.__map_frame, width=self.__map_width,
height=self.__height, corner_radius=0)
# google normal tile server
self.map.set_tile_server("https://mt0.google.com/vt/lyrs=m&hl=en&x={x}&y={y}&z={z}&s=Ga", max_zoom=22)
# google satellite tile server
# self.map.set_tile_server("https://mt0.google.com/vt/lyrs=s&hl=en&x={x}&y={y}&z={z}&s=Ga", max_zoom=22)
# self.map.set_tile_server("http://c.tile.stamen.com/watercolor/{z}/{x}/{y}.png") # painting style
self.map.pack(fill=tk.BOTH)
self.map.set_address("kathmandu")
if the last line i.e. set_address() is removed then it runs fine otherwise it throws the error.
following is the error message:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/PIL/ImageTk.py", line 118, in __del__
name = self.__photo.name
AttributeError: 'PhotoImage' object has no attribute '_PhotoImage__photo'
Exception ignored in: <function PhotoImage.__del__ at 0x7fa9e10ed510>
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/PIL/ImageTk.py", line 118, in __del__
name = self.__photo.name
AttributeError: 'PhotoImage' object has no attribute '_PhotoImage__photo'
Process finished with exit code 0
I tried the following code as well to reproduce the error
from tkintermapview import TkinterMapView
root_tk = tkinter.Tk()
root_tk.geometry(f"{600}x{400}")
root_tk.title("map_view_simple_example.py")
# create map widget
map_widget = TkinterMapView(root_tk, width=600, height=400, corner_radius=0)
map_widget.pack(fill="both", expand=True)
# google normal tile server
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)
map_widget.set_address("chyasal")
root_tk.mainloop()
But this time the error is shown for the first time only. After that the program works correctly.
But again when I change the place to new location say set_address("Manang") again for the first launch, the same error is occured.
But this is not the case with all the places, I tried many different places inside the set_address() method, but only some of them caused the error.
I have one more question
My project should enable a user to pick the pick up and drop off location on the map and the map should calculate the shortest road and its distance(length of road) between the two locations.
Is tkintermapview good choice or is there a better way to display google map and implement this requirement in tkinter...?

Related

AttributeError: 'Application' object has no attribute 'tunes_list'

I am attempting to create an app that allows me to generate a tune for a game I play. But regardless, my goal is to save and load data from a sqlite3 database. But what is happening instead is:
Traceback (most recent call last):
File "d:\Visual Studio\DRIFT_TUNER\gui.py", line 360, in <module>
app = Application(master=root)
File "d:\Visual Studio\DRIFT_TUNER\gui.py", line 16, in __init__
self.populate_list()
File "d:\Visual Studio\DRIFT_TUNER\gui.py", line 350, in populate_list
self.tunes_list.delete(0, tk.END)
AttributeError: 'Application' object has no attribute 'tunes_list'
That happens when I call a function populate_list() which is this:
def populate_list(self):
self.tunes_list.delete(0, tk.END)
for row in db.fetch():
self.tunes_list.insert(tk.END, row)
Here are the Pastebins of my two files:
gui.py: https://pastebin.com/aJ5qAwtS
db.py: https://pastebin.com/mp3RnVK2
populate_list() is supposed to clear the text in the Listbox, then fetch data from the database and insert that data row by row into the Listbox. I'm using Python 3.9.5 with tkinter and sqlite3.
Things I've tried:
Converting all indents to spaces, and all spaces to indents.
Redeclaring the tunes_list
I do not know fully what this error means in the first place so any help would be nice.
self.tunes_list is created in your load_window method. Your load_window is called only when the button (named self.load_button) is pressed. But as soon as you create your Application object, you try calling populate_list which uses self.tunes_list. Therefore, you create a variable only when the button is pressed but try accessing it before that.
You can solve this problem by adding self.tunes_list = tk.Entry() in your __init__ or idk whatever your tunes_list is

AttributeError: 'FFmpegWriter' object has no attribute '_proc'

I have some problem which i cannot find answer to. After installing scikit-video and FFmpeg i got this error:
AttributeError: 'FFmpegWriter' object has no attribute '_proc'
can you help me to find solution to this.
from skvideo.io import FFmpegWriter
def main():
...
video_writer = FFmpegWriter('video.mp4')
...
if __name__ == '__main__':
main()
Already tried to install pyaudio, reinstall FFmpeg and skvideo and install different versions of packages. Does not help at all.
Edit: an example of the full traceback resulting from /skvideo/io/abstract.py is below.
Traceback (most recent call last):
File "run_modules.py", line 93, in <module>
Pipeline.create_videos(video_attr, args.output_path, args.padded)
File "/home/leuko/.local/lib/python3.6/site-packages/skvideo/io/abstract.py", line 474, in close
if self._proc is None: # pragma: no cover
AttributeError: 'FFmpegWriter' object has no attribute '_proc'
I just ran into this issue, and found that FFmpegWriter was actually masking another error. My code was roughly like this:
with FFmpegWriter('/tmp/tmp.webm') as writer:
for frame in frames:
<code to generate out>
writer.writeFrame(out)
The code block before writer.writeFrame was raising an error, but I didn't see that because I didn't look at the full stack trace. I couldn't figure out why FFmpegWriter was throwing this error, but it made sense once I realized I wasn't actually writing any frames but was then trying to close the writer.

'Check' object has no attribute 'image' while using sightengine api

I am using sightengine API to detect child sexual abuse in images. In order to do that I am trying to detect the nudity level in an image using sightengine API. The following example is provided in the documentation itself.
from sightengine.client import SightengineClient
client = SightengineClient('api_user', 'api_key')
output = client.check('nudity').image('https://d3m9459r9kwism.cloudfront.net/img/examples/example7.jpg')
Apart from copying the same code I am getting the following error.
Traceback (most recent call last):
File "driver.py", line 3, in <module>
output = client.check('nudity').image('https://d3m9459r9kwism.cloudfront.net/img/examples/example7.jpg')
AttributeError: 'Check' object has no attribute 'image'
I have used both Python 2 and Python 3 for the same code but both raise the same error.
Try This:
from sightengine.client import SightengineClient
client = SightengineClient('API user', 'API secret')
checkNudity = client.check('nudity')
output1 = checkNudity.set_url('https://d3m9459r9kwism.cloudfront.net/img/examples/example7.jpg')
print(output1)

Why can't run DestroyWindow function in Python

I write a program that can open a particular file, i.e., a Flash file, positioning it at particular position and closing it(not minimizing but exitting).
The first second target is ok by os.startfile('file.swf'), finding its hwnd by win32gui.FindWindow(None, file.swf) and positioning it by win32gui.MoveWindow(hwnd,0,0,800,600,True), however, the win32gui.DestroyWindow(hwnd) can't work and I don't know why.
Here is the error message below:
Traceback (most recent call last):
File "<pyshell#30>", line 1, in <module>
win32gui.DestroyWindow(hwnd1)
error: (5, 'DestroyWindow', '\xa6s\xa8\xfa\xb3Q\xa9\xda\xa1C')
What is wrong with it? How to fix it?
edit:
my code is:
import win32gui
import os
"""
monitoring a folder which will be updated per one miniute
if the temperature changed the program will open a particular file to display
"""
FLASH_PATH="santa"
PIC_PATH=""
TEMP_PATH="Temperatures/"
file_name="led_20.swf"
filePath=os.path.join(FLASH_PATH,file_name)
os.startfile(filePath)
hwnd=win32gui.FindWindow(None,file_name)
win32gui.MoveWindow(hwnd,0,0,800,600,True)
"""
display it for a few minute and close it
"""
Error 5 is ERROR_ACCESS_DENIED. DestroyWindow() can only be called by the thread that created the window. Post or send a WM_DESTROY message instead.

python webbrowser

I've been using this module without problems by calling it as:
webbrowser.open("http link...")
now, however, I wanted to select a different browser, and according to the docs (http://docs.python.org/library/webbrowser.html#webbrowser.get) I wrote this
controller = webbrowser.get('firefox')
controller("http link...")
... and I get an error I'm unable to get rid of:
Exception in Tkinter callback
Traceback (most recent call last):
....
TypeError: 'Mozilla' object is not callable
any idea about it???
A Controller object is not callable. Do this:
controller.open(url)

Categories