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 93 94 95 96 97 98 99 100 101 102 103 104
| #!/usr/bin/env python
# -*- coding: Utf-8 -*-
import csv
import tkinter as TK
import tkinter.filedialog as FD
import tkinter.messagebox as MB
from tkinter import ttk
class FileEntry (ttk.Frame):
def __init__ (self, master=None, **kw):
# super class inits
ttk.Frame.__init__(self, master)
# widget inits
self.init_widget(**kw)
# end def
def init_widget (self, **kw):
# component inits
self.label = ttk.Label(self, text=kw.get("label", "Veuillez sélectionner un fichier, SVP:"))
self.file_path = TK.StringVar()
self.entry = ttk.Entry(self, textvariable=self.file_path)
self.button = ttk.Button(self, text="Parcourir", command=self.slot_browse, underline=0,)
# layout inits
self.label.pack(side=TK.TOP, expand=0, fill=TK.X)
self.entry.pack(side=TK.LEFT, expand=1, fill=TK.X)
self.button.pack(side=TK.LEFT, expand=0, fill=TK.NONE, padx=5)
# end def
def slot_browse (self, tk_event=None, *args, **kw):
# browse file path
_fpath = FD.askopenfilename()
# set entry's contents with file_path control variable
self.file_path.set(_fpath)
# end def
def get_path (self):
return self.file_path.get()
# end def
# end class FileEntry
# Interface
root = TK.Tk()
root.title("Programme")
labelframe = ttk.LabelFrame(root, text="Sélection des fichiers", padding="5px",)
# Size
ttk.Sizegrip(root).pack(side=TK.RIGHT, expand=0, fill=TK.Y, padx=5, pady=5,)
# FileEntry subcomponents
fileentry_sequence = FileEntry(labelframe, label="Séquence de référence :")
fileentry_coverage = FileEntry(labelframe, label="Coverage :")
fileentry_conflicts = FileEntry(labelframe, label="Conflits :", underline=0,)
# Bouton quitter
btn_quit = ttk.Button(root, text="Quitter", command=root.quit)
# Labelframe layout inits
labelframe.pack(side=TK.TOP, expand=1, fill=TK.BOTH, padx=5, pady=5)
# Fileentry layout inits
fileentry_sequence.pack(expand=0, fill=TK.X)
fileentry_coverage.pack(expand=0, fill=TK.X)
fileentry_conflicts.pack(expand=0, fill=TK.X)
# Boutons layout inits
btn_quit.pack(side = TK.RIGHT, padx=20, pady=5)
#####################################################
# récupération de fichier
filepath_sequence = fileentry_sequence.get_path()
filepath_coverage = fileentry_coverage.get_path()
filepath_conflicts = fileentry_conflicts.get_path()
#####################################################
def sequence(filepath_sequence):
seq_ref = []
file_seq = open(filepath_sequence, "r")
read_seq = file_seq.readlines()
for line in read_seq:
if line[0] == ">":
ID = line[1:]
ID = ID.split()
ID = ID[0].split('|')
ID = ID[len(ID)-1].lower() #Nom de la seq de référence utilisée
else :
for i in line :
i = i.upper()
i = i.strip()
if i != "":
seq_ref.append(i)
else :
pass
print (seq_ref)
#Bouton test
btn_test = ttk.Button(root, text="Test", command = sequence)
# Boutons layout inits
btn_quit.pack(side = TK.RIGHT, padx=20, pady=5)
btn_test.pack(side = TK.RIGHT, padx=10, pady=5)
root.mainloop() |
Partager