2018-01-21 20:15:24 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from tkinter import *
|
2018-01-22 18:11:29 +00:00
|
|
|
from bs4 import BeautifulSoup
|
|
|
|
import urllib.request
|
|
|
|
import json
|
2018-01-21 20:15:24 +00:00
|
|
|
|
|
|
|
def click ():
|
2018-01-22 18:11:29 +00:00
|
|
|
print (value.get())
|
|
|
|
try:
|
|
|
|
label2["text"]+=data[value.get()]+"\r"
|
|
|
|
except KeyError:
|
|
|
|
label2["text"]+="numero de chaine inconnue"+"\r"
|
|
|
|
|
2018-01-21 20:15:24 +00:00
|
|
|
|
|
|
|
def click_reset ():
|
|
|
|
print ("exit")
|
|
|
|
fenetre.quit
|
|
|
|
label2["text"]=""
|
|
|
|
fenetre.mainloop
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-01-22 18:11:29 +00:00
|
|
|
def load_jsonfile(file):
|
|
|
|
with open(file, 'r', encoding='utf-8') as f:
|
|
|
|
return json.load(f)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data=load_jsonfile('chaine.json')
|
2018-01-21 20:15:24 +00:00
|
|
|
fenetre = Tk()
|
|
|
|
value = StringVar()
|
2018-01-22 18:11:29 +00:00
|
|
|
value.set("")
|
|
|
|
label=Label(fenetre,text="entrer numero de chaine")
|
2018-01-21 20:15:24 +00:00
|
|
|
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()
|