add image togui

This commit is contained in:
vincent 2018-08-20 23:07:50 +02:00
parent 0b7130d4e6
commit 3ea7891753

View File

@ -1,4 +1,3 @@
from tkinter import Label,Button,Frame,Tk,Entry,StringVar,LEFT,RIGHT
import json import json
import sys import sys
import os import os
@ -6,7 +5,12 @@ import unicodedata
import webbrowser import webbrowser
import urllib.request import urllib.request
import re import re
import io
from PIL import Image,ImageTk
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
from tkinter import Label,Button,Frame,Tk,Entry,StringVar,LEFT,RIGHT,PhotoImage,Image
class Labbelink (Label): class Labbelink (Label):
@ -65,17 +69,21 @@ class Interface:
print(self.data[self.value.get()]) print(self.data[self.value.get()])
self.resultframe.update() self.resultframe.update()
emision=parse_emmission(strlink) emision=parse_emmission(strlink)
if emision: if emision:
if emision == "can't find show": if emision == "can't find show":
Label(self.resultframe,text="impssible de parser cette chaine").pack() Label(self.resultframe,text="impssible de parser cette chaine").pack()
else: 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()
Labbelink(self.resultframe,("emmision ce soir: "+emision["title"]),emision['href']).pack() Labbelink(self.resultframe,("emmision ce soir: "+emision["title"]),emision['href']).pack()
if len(emision['casting']) > 0: if len(emision['casting']) > 0:
Label(self.resultframe,text="réalisateur: "+emision['casting'][0]).pack() Label(self.resultframe,text="réalisateur: "+emision['casting'][0]).pack()
Label(self.resultframe,text="acteur: "+str(emision['casting'][1:])).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: else:
Label(self.resultframe,text="pas de connection internet impossible de determiner l'émission du soir").pack() Label(self.resultframe,text="pas de connection internet impossible de determiner l'émission du soir").pack()