cave/chaineTV.py
2018-01-22 19:11:29 +01:00

48 lines
988 B
Python

#!/usr/bin/env python
# -*- coding: utf-8 -*-
from tkinter import *
from bs4 import BeautifulSoup
import urllib.request
import json
def click ():
print (value.get())
try:
label2["text"]+=data[value.get()]+"\r"
except KeyError:
label2["text"]+="numero de chaine inconnue"+"\r"
def click_reset ():
print ("exit")
fenetre.quit
label2["text"]=""
fenetre.mainloop
def load_jsonfile(file):
with open(file, 'r', encoding='utf-8') as f:
return json.load(f)
data=load_jsonfile('chaine.json')
fenetre = Tk()
value = StringVar()
value.set("")
label=Label(fenetre,text="entrer numero de chaine")
entree = Entry(fenetre, textvariable=value, width=30)
frame =Frame(fenetre)
label2=Label(fenetre, text="")
bouton=Button(frame, text="OK", command=click)
reset=Button(frame, text="reset",command=click_reset)
label.pack()
entree.pack()
frame.pack()
bouton.pack(side = LEFT)
reset.pack(side = RIGHT)
label2.pack()
fenetre.mainloop()