From 05362a9d9c658fb1beb29b7783aac102ed2be4ca Mon Sep 17 00:00:00 2001 From: vincent Date: Tue, 21 Aug 2018 11:24:47 +0200 Subject: [PATCH] creation class label image --- chaineTV.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/chaineTV.py b/chaineTV.py index e75c6a7..2590c2e 100644 --- a/chaineTV.py +++ b/chaineTV.py @@ -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()