creation class label image

This commit is contained in:
vincent 2018-08-21 11:24:47 +02:00
parent 3ea7891753
commit 05362a9d9c

View File

@ -22,6 +22,15 @@ class Labbelink (Label):
def _openlink(self,evt):
webbrowser.open(self.link)
class LabelImage(Label):
def __init__(self,parent,url):
raw_data = urllib.request.urlopen(url).read()
image = ImageTk.PhotoImage(file=io.BytesIO(raw_data))
Label.__init__(self,parent,image=image)
self.image = image
class Interface:
def __init__(self):
@ -74,16 +83,17 @@ class Interface:
if emision == "can't find show":
Label(self.resultframe,text="impssible de parser cette chaine").pack()
else:
raw_data = urllib.request.urlopen(emision['img']).read()
image = ImageTk.PhotoImage(file=io.BytesIO(raw_data))
photolabel=Label(self.resultframe,image=image)
photolabel.image = image
photolabel.pack()
#raw_data = urllib.request.urlopen(emision['img']).read()
#image = ImageTk.PhotoImage(file=io.BytesIO(raw_data))
#photolabel=Label(self.resultframe,image=image)
#photolabel.image = image
image=LabelImage(self.resultframe,emision['img'])
image.pack()
Labbelink(self.resultframe,("emmision ce soir: "+emision["title"]),emision['href']).pack()
if len(emision['casting']) > 0:
Label(self.resultframe,text="réalisateur: "+emision['casting'][0]).pack()
Label(self.resultframe,text="acteur: "+str(emision['casting'][1:])).pack()
Label(self.resultframe,text="synopsys: " +emision['synopsis'],wraplength=350).pack()
Label(self.resultframe,text="synopsys: " +emision['synopsis'],wraplength=350).pack()
else:
Label(self.resultframe,text="pas de connection internet impossible de determiner l'émission du soir").pack()