1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
| #!/usr/bin/env python
# -*- coding: UTF-8 -*-
#
#
from Tkinter import *
# A vous de remplir le dico:
dico = {'default': ('default.gif', "Merci de rentrer votre recherche"), ('a', 'ala', 'alanine'): ('Alanine.gif', "Alanine"), ('r', 'arg', 'arginine'): ('Arginine.gif', "Arginine"), ('n', 'asp', 'asparagine'): ('Asparagine.gif', "Asparagine")}
def recherche1():
aa = entr1.get().lower()
result = [dico[cle] for cle in dico if cle[0].lower() == aa]
if result:
img = result[0][0]
desc = result[0][1]
# Optionnel
if len(result) > 1:
desc = desc + "\n(Plusieurs choix. Veuilliez préciser)"
else:
img = dico['default'][0]
desc = dico['default'][1]
affiche(img, desc)
def recherche3():
aa = entr1.get().lower()
result = [dico[cle] for cle in dico if cle[1].lower() == aa]
if result:
img = result[0][0]
desc = result[0][1]
# Optionnel
if len(result) > 1:
desc = desc + "\n(Plusieurs choix. Veuilliez préciser)"
else:
img = dico['default'][0]
desc = dico['default'][1]
affiche(img, desc)
def recherchecomplet():
aa = entr1.get().lower()
result = [dico[cle] for cle in dico if cle[2].lower() == aa]
if result:
img = result[0][0]
desc = result[0][1]
# Optionnel
if len(result) > 1:
desc = desc + "\n(Plusieurs choix. Veuilliez préciser)"
else:
img = dico['default'][0]
desc = dico['default'][1]
affiche(img, desc)
def affiche(img, desc):
photo = PhotoImage(file=img)
labimg.configure(image=photo)
labimg.image = photo
labdesc.configure(text=desc)
def Efface():
entr1.delete(0, END)
img = dico['default'][0]
desc = dico['default'][1]
affiche(img, desc)
def lettre():
recherche1()
def trois():
recherche3()
def complet():
recherchecomplet()
fen = Tk()
fen.title("base de données acide aminés")
Label(fen, text="Votre recherche :").pack(padx=5, pady=5)
entr1= Entry(fen)
entr1.pack(padx=5, pady=5)
entr1.focus_set()
conteneur = Frame(fen)
labimg = Label(conteneur)
labimg.pack(side=LEFT, ipadx=10, ipady=10, padx=5, pady=5)
labdesc = Label(conteneur, justify=LEFT)
labdesc.pack(side=LEFT, ipadx=10, ipady=10, padx=5, pady=5)
conteneur.pack(fill=BOTH, expand=1, padx=10, pady=5)
Button(fen, text="1 lettre", fg="purple", command=lettre).pack(side=LEFT, padx=15, pady=15)
Button(fen, text="3 lettres", fg="blue", command=trois).pack(side=LEFT, padx=15, pady=15)
Button(fen, text="nom complet", fg="cyan", command=complet).pack(side=LEFT, padx=15, pady=15)
Button(fen, text="Effacer", fg="red", command=Efface).pack(side=LEFT, padx=15, pady=15)
Button(fen, text="Quitter", fg="maroon", command=fen.quit).pack(side=LEFT, padx=15, pady=15)
Efface()
fen.mainloop() |
Partager