Aug-02-2018, 10:40 AM
Hello:
Sorry for my bad english.
I am a beginner of python.
I have made an application in python3 in windows 10 with tkinter and it works perfectly for me.
In Ubuntu 18.04 with python3 version 3.6.5 I get an error. I have tried with raspberry pi 3 with python3 version 3.5.3 and I have the same error.
This is the script:
import tkinter
from tkinter import *
import os
raiz=tkinter.Tk()
raiz.title("Ver png")
raiz.config(bg="White")
# medida ventana
w = raiz.winfo_screenwidth()
h = raiz.winfo_screenheight()
raiz.geometry("%dx%d+0+0" % (w, h))
# Bloqueo cambio tamaño pantalla
raiz.resizable(width=False, height=False)
directorio=os.path.dirname(__file__)
print(w,h,directorio)
Imagenfondo0=PhotoImage(file=directorio+"/Hydrisgrande.png")
canvas=tkinter.Canvas(raiz,width=w,height=h,bg="white")
canvas.place(x=1,y=1)
image = canvas.create_image(1, 1, anchor=NW, image=Imagenfondo0)
This is the error:
================ RESTART: /home/pi/Hydris/python/verimagen.py ================
1824 984 /home/pi/Hydris/python
Traceback (most recent call last):
File "/home/pi/Hydris/python/verimagen.py", line 21, in <module>
Imagenfondo0=PhotoImage(file=directorio+"/Hydrisgrande.png")
File "/usr/lib/python3.5/tkinter/__init__.py", line 3406, in __init__
Image.__init__(self, 'photo', name, cnf, master, **kw)
File "/usr/lib/python3.5/tkinter/__init__.py", line 3362, in __init__
self.tk.call(('image', 'create', imgtype, name,) + options)
_tkinter.TclError: couldn't open "/home/pi/Hydris/python/Hydrisgrande.png": no such file or directory
Thank you in advance for trying to help me
Sorry for my bad english.
I am a beginner of python.
I have made an application in python3 in windows 10 with tkinter and it works perfectly for me.
In Ubuntu 18.04 with python3 version 3.6.5 I get an error. I have tried with raspberry pi 3 with python3 version 3.5.3 and I have the same error.
This is the script:
import tkinter
from tkinter import *
import os
raiz=tkinter.Tk()
raiz.title("Ver png")
raiz.config(bg="White")
# medida ventana
w = raiz.winfo_screenwidth()
h = raiz.winfo_screenheight()
raiz.geometry("%dx%d+0+0" % (w, h))
# Bloqueo cambio tamaño pantalla
raiz.resizable(width=False, height=False)
directorio=os.path.dirname(__file__)
print(w,h,directorio)
Imagenfondo0=PhotoImage(file=directorio+"/Hydrisgrande.png")
canvas=tkinter.Canvas(raiz,width=w,height=h,bg="white")
canvas.place(x=1,y=1)
image = canvas.create_image(1, 1, anchor=NW, image=Imagenfondo0)
This is the error:
================ RESTART: /home/pi/Hydris/python/verimagen.py ================
1824 984 /home/pi/Hydris/python
Traceback (most recent call last):
File "/home/pi/Hydris/python/verimagen.py", line 21, in <module>
Imagenfondo0=PhotoImage(file=directorio+"/Hydrisgrande.png")
File "/usr/lib/python3.5/tkinter/__init__.py", line 3406, in __init__
Image.__init__(self, 'photo', name, cnf, master, **kw)
File "/usr/lib/python3.5/tkinter/__init__.py", line 3362, in __init__
self.tk.call(('image', 'create', imgtype, name,) + options)
_tkinter.TclError: couldn't open "/home/pi/Hydris/python/Hydrisgrande.png": no such file or directory
Thank you in advance for trying to help me