Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
ccb5b80d6d |
232
chaineTV.py
232
chaineTV.py
@ -8,21 +8,14 @@ import re
|
||||
import io
|
||||
from PIL import ImageTk
|
||||
from bs4 import BeautifulSoup
|
||||
from kivy.app import App
|
||||
from kivy.app import ObjectProperty
|
||||
from kivy.uix.widget import Widget
|
||||
from kivy.uix.label import Label
|
||||
from kivy.uix.button import Button
|
||||
from kivy.uix.image import Image
|
||||
from kivy.uix.textinput import TextInput
|
||||
from kivy.uix.boxlayout import BoxLayout
|
||||
from kivy.graphics import Color,Rectangle
|
||||
from tkinter import Label,Button,Frame,Tk,Entry,StringVar,LEFT,RIGHT,Scrollbar,VERTICAL,Canvas,Y,BOTH,NW
|
||||
|
||||
|
||||
|
||||
class Labbelink (Label):
|
||||
|
||||
def __init__(self,text,link):
|
||||
Label.__init__(self,text=text,fg="blue",cursor="hand2")
|
||||
def __init__(self,parent,text,link):
|
||||
Label.__init__(self,parent,text=text,fg="blue",cursor="hand2")
|
||||
self.link=link
|
||||
self.bind("<Button-1>",self._openlink)
|
||||
|
||||
@ -33,120 +26,146 @@ class LabelImage(Label):
|
||||
|
||||
def __init__(self,parent,url):
|
||||
raw_data = urllib.request.urlopen(url).read()
|
||||
imagetoinsert=Image(file=io.BytesIO(raw_data))
|
||||
Label.__init__(self,image=imagetoinsert)
|
||||
imagetoinsert=ImageTk.PhotoImage(file=io.BytesIO(raw_data))
|
||||
Label.__init__(self,parent,image=imagetoinsert)
|
||||
self.image = imagetoinsert
|
||||
|
||||
|
||||
class ScrollableCanvas(Frame):
|
||||
def __init__(self, parent, *args, **kw):
|
||||
Frame.__init__(self, parent, *args, **kw)
|
||||
|
||||
self.canvas=canvas=Canvas(self,width=300,height=300,scrollregion=(0,0,500,500))
|
||||
|
||||
vbar=Scrollbar(self,orient=VERTICAL)
|
||||
vbar.pack(side=RIGHT, fill=Y)
|
||||
vbar.config(command=canvas.yview)
|
||||
|
||||
canvas.config(width=200,height=200)
|
||||
canvas.config(yscrollcommand=vbar.set)
|
||||
canvas.pack(side=LEFT,expand=True,fill=BOTH)
|
||||
|
||||
# create a frame inside the canvas which will be scrolled with it
|
||||
self.interior = interior = Frame(canvas)
|
||||
interior_id = canvas.create_window(0, 0, window=interior, anchor=NW )
|
||||
# track changes to the canvas and frame width and sync them,
|
||||
# also updating the scrollbar
|
||||
def _configure_interior(event):
|
||||
# update the scrollbars to match the size of the inner frame
|
||||
size = (interior.winfo_reqwidth(), interior.winfo_reqheight())
|
||||
canvas.config(scrollregion="0 0 %s %s" % size)
|
||||
if interior.winfo_reqwidth() != canvas.winfo_width():
|
||||
# update the canvas's width to fit the inner frame
|
||||
canvas.config(width=interior.winfo_reqwidth())
|
||||
interior.bind('<Configure>', _configure_interior)
|
||||
|
||||
def _configure_canvas(event):
|
||||
if interior.winfo_reqwidth() != canvas.winfo_width():
|
||||
# update the inner frame's width to fill the canvas
|
||||
canvas.itemconfigure(interior_id, width=canvas.winfo_width())
|
||||
canvas.bind('<Configure>', _configure_canvas)
|
||||
|
||||
def _MouseWhell(event):
|
||||
print (event.delta/120)
|
||||
canvas.yview_scroll(-1*(event.delta/120), "units")
|
||||
self.bind("<MouseWheel>",_MouseWhell)
|
||||
|
||||
|
||||
class emmisionGUI(BoxLayout):
|
||||
|
||||
class emmisionGUI(Frame):
|
||||
def __init__(self,parent,**kwarg):
|
||||
BoxLayout.__init__(self)
|
||||
Frame.__init__(self,parent)
|
||||
self.image=LabelImage(self,kwarg['img'])
|
||||
self.image.pack()
|
||||
self.LabelTitle=Labbelink(("emmision ce soir: "+kwarg["title"]),kwarg['href'])
|
||||
self.LabelTitle=Labbelink(self,("emmision ce soir: "+kwarg["title"]),kwarg['href'])
|
||||
self.LabelTitle.pack()
|
||||
if len(kwarg['casting']) > 0:
|
||||
self.LabelReal=Label(text="réalisateur: "+kwarg['casting'][0])
|
||||
self.LabelReal=Label(self,text="réalisateur: "+kwarg['casting'][0])
|
||||
self.LabelReal.pack()
|
||||
self.labelCasting=Label(text="acteur: "+str(kwarg['casting'][1:]))
|
||||
self.labelCasting=Label(self,text="acteur: "+str(kwarg['casting'][1:]))
|
||||
self.labelCasting.pack()
|
||||
self.LabelSynopsys=Label(text="synopsys: " +kwarg['synopsis'],wraplength=350)
|
||||
self.LabelSynopsys=Label(self,text="synopsys: " +kwarg['synopsis'],wraplength=350)
|
||||
self.LabelSynopsys.pack()
|
||||
|
||||
|
||||
class RootWidget(BoxLayout):
|
||||
txt_inpt = ObjectProperty(None)
|
||||
|
||||
class InterfaceApp(App):
|
||||
class Interface:
|
||||
|
||||
def __init__(self,data):
|
||||
App.__init__(self)
|
||||
self.data=data
|
||||
def build(self):
|
||||
return RootWidget()
|
||||
self.data = data
|
||||
self.fenetre = Tk()
|
||||
self.fenetre.title("recherche de chaine")
|
||||
self.value = StringVar()
|
||||
self.label = Label(self.fenetre, text="entrer numero de chaine")
|
||||
self.entree = Entry(self.fenetre, textvariable=self.value, width=30)
|
||||
self.frame = Frame(self.fenetre)
|
||||
self.resultframe = ScrollableCanvas(self.fenetre)
|
||||
self.bouton_update_base = Button(self.fenetre, text="update la base de chaine", command=self.click_update)
|
||||
self.bouton = Button(self.frame, text="OK", command=self.click)
|
||||
self.reset = Button(self.frame, text="reset", command=self.click_reset)
|
||||
self.label.pack()
|
||||
self.entree.pack()
|
||||
self.entree.focus_set()
|
||||
self.resultframe.pack(expand=1,fill='both')
|
||||
self.frame.pack()
|
||||
self.bouton.pack(side=LEFT)
|
||||
self.reset.pack(side=RIGHT)
|
||||
self.bouton_update_base.pack()
|
||||
self.fenetre.bind("<Key-Return>", self.enter)
|
||||
self.fenetre.bind("<Key-Escape>", self.eventreset)
|
||||
|
||||
|
||||
def enter(self,evt):
|
||||
self.click()
|
||||
|
||||
def eventreset(self,evt):
|
||||
self.click_reset()
|
||||
|
||||
def mainloop(self):
|
||||
self.fenetre.mainloop()
|
||||
|
||||
def click(self):
|
||||
print(self.value.get())
|
||||
Arrayvalue=self.value.get().split(" ")
|
||||
for value in Arrayvalue:
|
||||
|
||||
|
||||
try:
|
||||
strlink=geturlprogrammetv(self.data.get_chaine(value))
|
||||
link= Labbelink(self.resultframe.interior,self.data.get_chaine(value),strlink)
|
||||
link.pack()
|
||||
self.resultframe.update()
|
||||
print(self.data.get_chaine(value))
|
||||
emision=parse_emmission(strlink)
|
||||
if emision:
|
||||
if emision == "can't find show":
|
||||
Label(self.resultframe.interior,text="impssible de parser cette chaine").pack()
|
||||
else:
|
||||
emmisionGUI(self.resultframe.interior,**emision).pack()
|
||||
else:
|
||||
Label(self.resultframe.interior,text="pas de connection internet impossible de determiner l'émission du soir").pack()
|
||||
|
||||
|
||||
except KeyError:
|
||||
print("numero de chaine inconnue")
|
||||
unknow=Label(self.resultframe.interior, text="numero de chaine inconnue")
|
||||
unknow.pack()
|
||||
self.resultframe.canvas.yview_moveto(1)
|
||||
|
||||
self.value.set("")
|
||||
|
||||
def click_reset(self):
|
||||
print("reset")
|
||||
for child in self.resultframe.interior.winfo_children():
|
||||
child.destroy()
|
||||
|
||||
|
||||
#
|
||||
#class Interface:
|
||||
#
|
||||
# def __init__(self,data):
|
||||
# self.data = data
|
||||
# self.fenetre = Tk()
|
||||
# self.fenetre.title("recherche de chaine")
|
||||
# self.value = StringVar()
|
||||
# self.label = Label(self.fenetre, text="entrer numero de chaine")
|
||||
# self.entree = Entry(self.fenetre, textvariable=self.value, width=30)
|
||||
# self.frame = Frame(self.fenetre)
|
||||
# self.resultframe = ScrollableCanvas(self.fenetre)
|
||||
# self.bouton_update_base = Button(self.fenetre, text="update la base de chaine", command=self.click_update)
|
||||
# self.bouton = Button(self.frame, text="OK", command=self.click)
|
||||
# self.reset = Button(self.frame, text="reset", command=self.click_reset)
|
||||
# self.label.pack()
|
||||
# self.entree.pack()
|
||||
# self.entree.focus_set()
|
||||
# self.resultframe.pack(expand=1,fill='both')
|
||||
# self.frame.pack()
|
||||
# self.bouton.pack(side=LEFT)
|
||||
# self.reset.pack(side=RIGHT)
|
||||
# self.bouton_update_base.pack()
|
||||
# self.fenetre.bind("<Key-Return>", self.enter)
|
||||
# self.fenetre.bind("<Key-Escape>", self.eventreset)
|
||||
#
|
||||
#
|
||||
# def enter(self,evt):
|
||||
# self.click()
|
||||
#
|
||||
# def eventreset(self,evt):
|
||||
# self.click_reset()
|
||||
#
|
||||
# def mainloop(self):
|
||||
# self.fenetre.mainloop()
|
||||
#
|
||||
# def click(self):
|
||||
# print(self.value.get())
|
||||
# Arrayvalue=self.value.get().split(" ")
|
||||
# for value in Arrayvalue:
|
||||
#
|
||||
#
|
||||
# try:
|
||||
# strlink=geturlprogrammetv(self.data.get_chaine(value))
|
||||
# link= Labbelink(self.resultframe.interior,self.data.get_chaine(value),strlink)
|
||||
# link.pack()
|
||||
# self.resultframe.update()
|
||||
# print(self.data.get_chaine(value))
|
||||
# emision=parse_emmission(strlink)
|
||||
# if emision:
|
||||
# if emision == "can't find show":
|
||||
# Label(self.resultframe.interior,text="impssible de parser cette chaine").pack()
|
||||
# else:
|
||||
# emmisionGUI(self.resultframe.interior,**emision).pack()
|
||||
# else:
|
||||
# Label(self.resultframe.interior,text="pas de connection internet impossible de determiner l'émission du soir").pack()
|
||||
#
|
||||
#
|
||||
# except KeyError:
|
||||
# print("numero de chaine inconnue")
|
||||
# unknow=Label(self.resultframe.interior, text="numero de chaine inconnue")
|
||||
# unknow.pack()
|
||||
#
|
||||
# self.value.set("")
|
||||
#
|
||||
# def click_reset(self):
|
||||
# print("reset")
|
||||
# for child in self.resultframe.interior.winfo_children():
|
||||
# child.destroy()
|
||||
#
|
||||
#
|
||||
# def click_update(self):
|
||||
# self.data.parsechaine()
|
||||
# labelupdate = Label(self.resultframe.interior, text="update chaine done"+"\r")
|
||||
# labelupdate.pack()
|
||||
#
|
||||
# def _openlink(self,link):
|
||||
# webbrowser.open_new(link)
|
||||
def click_update(self):
|
||||
self.data.parsechaine()
|
||||
labelupdate = Label(self.resultframe.interior, text="update chaine done"+"\r")
|
||||
labelupdate.pack()
|
||||
|
||||
def _openlink(self,link):
|
||||
webbrowser.open_new(link)
|
||||
|
||||
|
||||
class JSONfile:
|
||||
@ -274,5 +293,4 @@ if len(sys.argv) > 1:
|
||||
else:
|
||||
cli(arg,data.data)
|
||||
else:
|
||||
interface=InterfaceApp(data)
|
||||
interface.run()
|
||||
Interface(data).mainloop()
|
22
interface.kv
22
interface.kv
@ -1,22 +0,0 @@
|
||||
#:kivy!
|
||||
<RootWidget>:
|
||||
txt_inpt: txt_inpt
|
||||
orientation:"vertical"
|
||||
canvas.before:
|
||||
Color:
|
||||
rgba: 1, 1, 1, 1
|
||||
Rectangle:
|
||||
pos: self.pos
|
||||
size: self.size
|
||||
Label:
|
||||
text:"entrer numéros de chaine"
|
||||
color:0,0,0,1
|
||||
|
||||
TextInput:
|
||||
id: txt_inpt
|
||||
row:1
|
||||
multiline:False
|
||||
focus:True
|
||||
Label:
|
||||
text: txt_inpt.text
|
||||
color:0,0,0,1
|
Loading…
Reference in New Issue
Block a user