def __init__(self, parent, controller): super().__init__(parent, controller) self.set_info_text("SelectWindow") from_tables_frame = tk.Frame() self.tables_checkbox = ttkwidgets.CheckboxTreeview(from_tables_frame) self.tables_checkbox.pack(fill = tk.BOTH, expand = True) for table in self.controller.parent.get_db().get_tables().get_one_column(): iid = self.tables_checkbox.insert("", tk.END, tags = (table, ), text = table, iid = table) for table, field in self.controller.parent.get_db().get_fields().get_all_columns(): self.tables_checkbox.insert(table, tk.END, tags = (table, field), text = field) self.add_page(from_tables_frame, text = help_text.HELP_TEXT["SELECT"]["Fields"], title = "Fields") joins_frame = tk.Frame() cols = ("Type", "Table", "On") self.img_tick = tk.PhotoImage(file = os.path.join("assets", "tick.png")) self.img_cross = tk.PhotoImage(file = os.path.join("assets", "cross.png")) self.joins_table = ttk.Treeview(joins_frame, columns = cols, displaycolumns = cols) self.joins_table.column("#0", width = 48, stretch = tk.NO) for col in cols: self.joins_table.heading(col, text = col) self.joins_table.pack(fill = tk.BOTH, expand = True) self.joins_table.bind("<Double-1>", self.onTreeClick) self.add_page(joins_frame, text = help_text.HELP_TEXT["SELECT"]["Joins"], title = "Joins", onPageOpen = self.joins_page_selected)
def __init__(self, master, state, **kw) -> None: super().__init__(master=master, **kw) self.state = state r = 0 ## Upload button b = ttk.Label(self, text="Your sequences") b.grid(row=r, column=0, padx=10, pady=10, columnspan=3, sticky="news") b = ttk.Label(self, text="Log") b.grid(row=r, column=3, padx=10, pady=10, columnspan=3, sticky="news") r += 1 ## Upload menu self.tree = ttkwidgets.CheckboxTreeview(self) self.tree.grid(row=r, column=0, padx=10, pady=10, columnspan=3, sticky="news") rootpath = f"{self.state.mode.sequences}/personal" for dirpath, dirnames, files in os.walk(rootpath): parent = "" if dirpath == rootpath else dirpath[ dirpath.index(rootpath):].replace("\\", "/") for d in dirnames: self.tree.insert(parent, "end", f"{dirpath}/{d}", text=d) for f in files: iid = self.tree.insert(parent, "end", f"{dirpath}/{f}", text=f) if not f.replace(".txt", "").replace("_", "").isdigit(): self.tree.change_state(iid, 'checked') self.text = tk.Text(self) self.text.grid(row=r, column=3, padx=10, pady=10, columnspan=3, sticky="news") r += 1 b = ttk.Button(self, text="Upload changes", command=self.upload) b.grid(row=r, column=3, padx=10, pady=10, columnspan=1, sticky="news")
def __init__(self, parent, *args, **kwargs): super().__init__(master=parent, bg='white', *args, **kwargs) self.pack(side=tk.RIGHT, fill=tk.Y) # buttons self.button_toggle_check_automatically = tk.Button(master=self, text='Check new automatically.', command=self.toggle_check_new_automatically, relief='flat', overrelief='solid', bd=1, bg='white', activebackground='white', fg='black', activeforeground='black') self.button_toggle_check_automatically.pack() self._is_toggle_set_to_check_new_automatically = True self.button_toggle_checkbuttons = tk.Button(master=self, text='Disable all. (toggle)', command=self.toggle_all_checkbuttons, relief='flat', overrelief='solid', bd=1, bg='white', activebackground='white', fg='black', activeforeground='black') self.button_toggle_checkbuttons.pack() self._is_toggle_set_to_disabled = True self.button_toggle_collapse = tk.Button(master=self, text='Collapse all. (toggle)', command=self.toggle_all_collapse, relief='flat', overrelief='solid', bd=1, bg='white', activebackground='white', fg='black', activeforeground='black') self.button_toggle_collapse.pack() self._is_toggle_set_to_collapsed = True # checkbutton tree # https://github.com/RedFantom/ttkwidgets/blob/master/ttkwidgets/checkboxtreeview.py # https://docs.python.org/3.6/library/tkinter.ttk.html#ttk-treeview self._checkbutton_tree = ttkwidgets.CheckboxTreeview(master=self, show='tree') # only 'tree ' no 'headings' self._checkbutton_tree.pack(side=tk.LEFT, fill=tk.Y) # workaround for Windows/Microsoft to remove border --> https://stackoverflow.com/a/23690759/3108856 ttk.Style().layout('Treeview', [('Treeview.treearea', {'sticky': 'nswe'})]) self._checkbutton_tree.bind('<Button-1>', self._row_click, add=True) # add=True to trigger also # internal event handling # scrollbar scrollbar = ttk.Scrollbar(master=self, orient="vertical", command=self._checkbutton_tree.yview) self._checkbutton_tree.configure(yscrollcommand=scrollbar.set) scrollbar.config(command=self._checkbutton_tree.yview) scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
def __init__(self, master): self.master = master self._queue_media = q.SimpleQueue() self._tcounter_update = ThreadCounter() self._executor_update = concurr.ThreadPoolExecutor() self._tcounter_download = ThreadCounter() self._executor_download = concurr.ThreadPoolExecutor() self.map_media = {} self.frame_view = ttk.Frame(self.master) self.frame_control = ttk.Frame(self.master) self.frame_add = ttk.Frame(self.frame_control) self.frame_dir = ttk.Frame(self.frame_control) self.style_progress = ttk.Style(self.master) self.style_progress.layout( 'Horizontal.TProgressbar', [('Horizontal.Progressbar.trough', { 'children': [('Horizontal.Progressbar.pbar', { 'side': 'left', 'sticky': 'ns' })], 'sticky': 'nswe' }), ('Horizontal.Profressbar.label', { 'sticky': '' })]) # widgets # frame_setup # frame_add - adding urls self.button_clipboard = ttk.Button(self.frame_add, text="Add from clipboard", command=self.event_add) self.var_check_audio = tk.StringVar() self.var_check_audio.set(dl.Format.VIDEO) self.check_audio = ttk.Checkbutton(self.frame_add, text="Audio only (mp3)", onvalue=dl.Format.AUDIO, offvalue=dl.Format.VIDEO, variable=self.var_check_audio, command=self.event_check_audio) # frame_dir - default directory label_dir_default = ttk.Label(self.frame_dir, text="Default directory:") self.var_dir_default = tk.StringVar() self.var_dir_default.set( os.path.sep.join([os.path.expanduser('~'), "YouTube"])) self.entry_dir_default = ttk.Entry(self.frame_dir, textvariable=self.var_dir_default, state=tk.DISABLED) self.entry_dir_default.bind("<Double-1>", self.event_open_dir) self.entry_dir_default.bind("<Button-4>", self.event_dir_scroll_up) self.entry_dir_default.bind("<Button-5>", self.event_dir_scroll_down) self.button_dir_default = ttk.Button(self.frame_dir, text="...", width=2, command=self.event_dir_default) self.var_check_subdir = tk.BooleanVar() self.var_check_subdir.set(True) self.check_subdir = ttk.Checkbutton(self.frame_dir, text="Playlists in subfolders", onvalue=True, offvalue=False, variable=self.var_check_subdir) # no subframe self.button_download = ttk.Button(self.frame_control, text="Download selected", command=self.event_download) self.button_clear = ttk.Button(self.frame_control, text="Clear", width=5, command=self.event_clear) # frame_view self.tree_media = ttkwidgets.CheckboxTreeview( self.frame_view, columns=self.Column.to_columns(), selectmode='none') self.tree_media.bind("<Button-1>", self.event_tree_click) self.tree_media.bind("<Double-1>", self.event_tree_doubleclick) self.tree_media.heading(self.Column.URL, text="URL ID") self.tree_media.heading(self.Column.STATUS, text="Status") self.tree_media.heading(self.Column.TITLE, text="Title") self.tree_media.heading(self.Column.FORMAT, text="Format") self.tree_media.heading(self.Column.DESTINATION, text="Destination") self.tree_media.column(self.Column.URL, minwidth=70, width=130, stretch=True) self.tree_media.column(self.Column.STATUS, minwidth=120, width=150, stretch=True) self.tree_media.column(self.Column.TITLE, width=300, minwidth=100, stretch=True) self.tree_media.column(self.Column.FORMAT, anchor="center", minwidth=100, width=100, stretch=False) self.tree_media.column(self.Column.DESTINATION, minwidth=100, stretch=True) self.progress_info = ttk.Progressbar(self.frame_view, maximum=0) # layout settings # mainframe self.master.grid_columnconfigure(0, weight=1) self.master.grid_rowconfigure(0, weight=1) self.frame_view.grid(row=0, column=0, sticky="nswe", padx=15, pady=5) self.frame_control.grid(row=0, column=1, sticky="ns", padx=5, pady=10) # frame_view self.frame_view.grid_columnconfigure(0, weight=1) self.frame_view.grid_rowconfigure(0, weight=1) self.tree_media.grid(sticky="nswe", pady=5) self.progress_info.grid(row=1, column=0, sticky="we", pady=7) # frame_control self.frame_dir.grid(row=0, column=0, columnspan=2, sticky="nwe", padx=10, pady=10) self.frame_add.grid(row=1, column=0, columnspan=2, sticky="we", padx=10, pady=10) self.button_download.grid(row=2, column=0, sticky="ws", pady=15, padx=10) self.button_clear.grid(row=2, column=1, sticky='se', pady=15, padx=10) # frame_dir label_dir_default.grid(row=0, column=0, columnspan=2, sticky='swe', pady=5) self.entry_dir_default.grid(row=1, column=0, sticky='nwe', ipady=3) self.button_dir_default.grid(row=1, column=1, sticky='e', padx=5) self.check_subdir.grid(row=2, column=0, columnspan=2, sticky='nw', pady=5) # frame_add self.button_clipboard.pack(fill='x') self.check_audio.pack(fill='x', pady=5) # window self.image_icon = Image.open('assets' + os.sep + '/Youtube-icon.ico') self.imagetk_icon = ImageTk.PhotoImage( self.image_icon.resize((100, 100))) self.master.iconphoto(False, self.imagetk_icon) self.master.title("YouTube downloader") self.master.update() w_max = self.master.winfo_screenwidth() w_opt = self.master.winfo_width() h_max = self.master.winfo_screenheight() h_opt = self.master.winfo_height() w_min = min(w_max, w_opt - 350) h_min = min(h_max, h_opt) w_out = min(w_opt, w_max) h_out = h_min pos_x = int((w_max - w_out) / 2) pos_y = int((h_max - h_out) / 5) self.master.geometry(f"{w_out}x{h_out}+{pos_x}+{pos_y}") self.master.minsize(w_min, h_min)
def troisieme_fenetrefunc(): troisieme_fenetre = tk.Frame() labelresultat = tk.Label(troisieme_fenetre, text='Resultat').grid() matrice = parsehmmsearch() tree = ttkwidgets.CheckboxTreeview(troisieme_fenetre) tree['columns'] = ('one', 'two', 'three', 'four', 'five', 'six', '7', '8', '9', '10', '11', '12', '13') #tailles colonnes tree.column("#0", width=50) tree.column("one", width=100) tree.column("two", width=100) tree.column("three", width=100) tree.column('four', width=100) tree.column('five', width=100) tree.column('six', width=100) tree.column('7', width=100) tree.column('8', width=100) tree.column('9', width=100) tree.column('10', width=100) tree.column('11', width=100) tree.column('12', width=100) tree.column('13', width=100) #nom colonnes tree.heading('#0', text='select') tree.heading('one', text='target') tree.heading('two', text='tlen') tree.heading('three', text='query') tree.heading('four', text='qlen') tree.heading('five', text='evalue') tree.heading('six', text='score') tree.heading('7', text='#') tree.heading('8', text='of') tree.heading('9', text='c-evalue') tree.heading('10', text='hmm from') tree.heading('11', text='hmm to') tree.heading('12', text='ali to') tree.heading('13', text='ali from') j = 0 for i in matrice: j += 1 tree.insert('', j, text='', values=(i[0], i[2], i[3], i[5], i[6], i[7], i[9], i[10], i[11], i[15], i[16], i[17], i[18])) # tree["columns"]= [i for i in range(len(dataframe.columns.values[1:]))] # for i in range(len(dataframe.columns.values[1:])): # tree.heading(i,text=dataframe.columns.values[i],anchor=tk.W) # tree.column(i,width=100) # for i in dataframe.iterrows(): # for j in range(2): # tree.insert('','end',values=(i[j])) #configuration def popup(): tk.messagebox.showinfo(title='coucou', message='{0}'.format(tree.get_checked())) send_check = tk.Button(troisieme_fenetre, text='Ajouter a la base de donnee', command=popup) tree.grid() send_check.grid() troisieme_fenetre.grid(row=0, column=1, sticky='news') troisieme_fenetre.grid_rowconfigure(0, pad=50)
def __init__(self, parent, controller): ttk.Frame.__init__(self, parent) self.controller = controller self.edit_mode = False self.event_id = None self.error_text = StringVar() title = ttk.Label(self, text="Create event", font=("TkDefaultFont", "15")) error_label = ttk.Label(self, textvariable=self.error_text, font=("TkDefaultFont", "7")) error_label.configure(style="Red.TLabel") buttons_frame = ttk.Frame(self) back_button = ttk.Button(buttons_frame, text='Back', command=partial(self.controller.show_frame, "EventsPage")) # And of course, the button to save it all save_button = ttk.Button(buttons_frame, text="Save", command=self.save) # Event form self.name = StringVar() name_label = ttk.Label(self, text="Name") self.name_entry = ttk.Entry(self, textvariable=self.name) # Variables to get the values after input self.begin_text = StringVar() self.hour_text = StringVar() self.running_time_text = StringVar() self.hour_text.set('12') self.running_time_text.set('60') # Input for the date of the event begin = ttk.Label(self, text="Day") begin_entry = EntryDate(self, textvariable=self.begin_text) # Input for the hour of the event hour = ttk.Label(self, text="Hour") hour_entry = Spinbox(self, from_=0, to=24, textvariable=self.hour_text) # Input for the running time, in minutes # TODO actually we can type anything in this widget # do something to prevent that by using regex # When clicking on the save button, there may be a label # if the input is wrong running_time = ttk.Label(self, text="Running time (minutes)") running_time_entry = Spinbox(self, from_=0, to=500, textvariable=self.running_time_text) # Dropdown list for the type of the projection (film, docu) pj_label = ttk.Label(self, text="Projection type") self.projection_type_choosen = StringVar() projection_types = ttk.Combobox(self, textvariable=self.projection_type_choosen, state='readonly') projection_types['values'] = ["Film", "Documentary"] projection_types.current(0) pjs = [pj['location'] for pj in controller.get_projection_rooms().dicts()] # Dropdown list for the location of the event pr_label = ttk.Label(self, text="Projection room") self.projection_room_choosen = StringVar() projection_rooms = ttk.Combobox(self, textvariable=self.projection_room_choosen, state='readonly') projection_rooms['values'] = pjs projection_rooms.current(0) # Inputs for the event's status to go 'finished' self.room_reserved = IntVar() self.management = IntVar() self.equipment_reserved = IntVar() self.guest_attendance = IntVar() check_frame = ttk.Frame(self) room_chbutton = ttk.Checkbutton(check_frame, text="Room reserved", variable=self.room_reserved) equipment_chbutton = ttk.Checkbutton(check_frame, text="Equipment reserved", variable=self.equipment_reserved) management_chbutton = ttk.Checkbutton(check_frame, text="Management reserved", variable=self.management) guest_attendance_chbutton = ttk.Checkbutton(check_frame, text="Guest attendance confirmed", variable=self.guest_attendance) members_frame = ttk.Frame(self) members_label = ttk.Label(self, text="Add members") members_scrollbar = ttk.Scrollbar(members_frame, orient=VERTICAL) # List of users; the manager has to choose among them # members that'll participate in the event's organisation self.members_tree = tkw.CheckboxTreeview(members_frame, columns=('Events'), selectmode='browse', yscrollcommand=members_scrollbar.set) members_scrollbar.configure(command=self.members_tree.yview) self.members_tree.column("Events", anchor='center') self.members_tree.heading("#0", text="Name") self.members_tree.heading("Events", text="Events") self.members_tree.tag_configure('odd', background="#F0F0F0") self.members_tree.tag_configure('even', background="#FAFAFA") tkw.frames.Balloon(self.members_tree, text='Double click on users to see their timetable') self.members_tree.bind('<Double-1>', self.timetable) self.display_members(event_id=None) # CATEGORIES categories_label = ttk.Label(self, text="Add categories") cats_frame = ttk.Frame(self) cats_scrollbar = ttk.Scrollbar(cats_frame, orient=VERTICAL) self.cats_tree = tkw.CheckboxTreeview(cats_frame, columns=('Price'), selectmode='none') cats_scrollbar.configure(command=self.cats_tree.yview) self.cats_tree.column("#0", width=140) self.cats_tree.column("Price", anchor='center') self.cats_tree.heading("#0", text="Title") self.cats_tree.heading("Price", text="Price") self.cats_tree.tag_configure('odd', background="#F0F0F0") self.cats_tree.tag_configure('even', background="#FAFAFA") self.display_categories(event_id=None) # PRESENTATION self.presentation = IntVar() self.author = StringVar() self.context = StringVar() presentation_frame = ttk.Frame(self) presentation_check = ttk.Checkbutton(presentation_frame, text="Author presentation", variable=self.presentation) # DEBATE self.debate = IntVar() self.speaker = StringVar() self.contact_details = StringVar() debate_frame = ttk.Frame(self) debate_check = ttk.Checkbutton(debate_frame, text="Debate", variable=self.debate) # Placing the components # ROW 0 title.grid(row=0, column=0, sticky=(W+N)) error_label.grid(row=0, column=1, sticky=W+N+S, columnspan=3, padx=(10, 0)) buttons_frame.grid(row=0, column=5, sticky=E) back_button.grid(row=0, column=2, pady=5, padx=5, sticky=E) save_button.grid(row=0, column=3, pady=5, padx=5, sticky=E) # ROW 1 name_label.grid(row=1, column=0, sticky=W, pady=5, padx=5) self.name_entry.grid(row=1, column=1, pady=5, padx=5, sticky=E) running_time.grid(row=1, column=2, pady=5, padx=5, sticky=W) running_time_entry.grid(row=1, column=3, pady=5, padx=5, sticky=E) # ROW 2 begin.grid(row=2, column=0, sticky=W, pady=5, padx=5) begin_entry.grid(row=2, column=1, sticky=E, pady=5, padx=5) hour.grid(row=2, column=2, sticky=W, pady=5, padx=5) hour_entry.grid(row=2, column=3, sticky=E, pady=5, padx=5) # ROW 3 pj_label.grid(row=3, column=0, sticky=W, pady=5, padx=5) projection_types.grid(row=3, column=1, sticky=E, pady=5, padx=5) pr_label.grid(row=3, column=2, pady=5, sticky=W, padx=5) projection_rooms.grid(row=3, column=3, sticky=E, pady=5, padx=5) # ROW 0 RIGHT SIDE presentation_frame.grid(row=1, column=4, sticky=NSEW, columnspan=2, rowspan=2, pady=5, padx=5) presentation_check.grid(row=0, column=0, sticky=W) # ROW 3 RIGHT SIDE debate_frame.grid(row=3, column=4, sticky=NSEW, rowspan=2, columnspan=2, pady=5, padx=5) debate_check.grid(row=0, column=0, sticky=W) # ROW 5 RIGHT SIDE check_frame.grid(row=5, column=4, rowspan=2, columnspan=2, sticky=N+W, pady=5, padx=5) room_chbutton.grid(row=4, column=2, sticky=W) equipment_chbutton.grid(row=5, column=2, sticky=W) management_chbutton.grid(row=6, column=2, sticky=W) guest_attendance_chbutton.grid(row=7, column=2, sticky=W) # ROW 6 members_frame.grid(row=5, column=0, columnspan=2, pady=5, padx=5, sticky=NSEW) members_label.grid(row=4, column=0, pady=5, padx=5, sticky=W) self.members_tree.pack(side=LEFT) members_scrollbar.pack() categories_label.grid(row=4, column=2, pady=5, padx=5, sticky=W) cats_frame.grid(row=5, column=2, columnspan=2, pady=5, padx=5, sticky=NSEW) self.cats_tree.pack(side=LEFT, expand=True) cats_scrollbar.pack()
def update_tree(self): '''Efface l'ancien tableau et le reconstruit en appliquant les conditions : evalue max et recouvrement mini''' #verifie que la evalue est sous le bon format sinon retourne un message d'erreur try: evalue = float(self.filtre_evalue.get()) except ValueError: tk.messagebox.showerror( title='Erreur', message= 'La evalue doit etre un reel \nEcriture scientifique accepté sous la forme 1e-N' ) return False recouvrement = int(self.recouvrement.get()) #Oublie l'ancien tableau et recreer le avec les conditions self.tree.grid_forget() self.tree = ttkwidgets.CheckboxTreeview(self, height=20) self.tree['columns'] = ('target', 'tlen', 'query', 'qlen', 'evalue', 'score', '#', 'of', 'c-evalue', 'hmm from', 'hmm to', 'ali from', 'ali to') #tailles colonnes self.tree.column("#0", width=50) self.tree.column("target", width=130, anchor=tk.CENTER) self.tree.column("tlen", width=50, anchor=tk.CENTER) self.tree.column("query", width=150, anchor=tk.CENTER) self.tree.column('qlen', width=50, anchor=tk.CENTER) self.tree.column('evalue', width=100, anchor=tk.CENTER) self.tree.column('score', width=100, anchor=tk.CENTER) self.tree.column('#', width=25, anchor=tk.CENTER) self.tree.column('of', width=25, anchor=tk.CENTER) self.tree.column('c-evalue', width=100, anchor=tk.CENTER) self.tree.column('hmm from', width=100, anchor=tk.CENTER) self.tree.column('hmm to', width=100, anchor=tk.CENTER) self.tree.column('ali from', width=100, anchor=tk.CENTER) self.tree.column('ali to', width=100, anchor=tk.CENTER) #nom colonnes for col in self.tree['columns']: self.tree.heading( col, text=col, command=lambda _col=col: self.tree_sort_column(_col, False)) #Pour chaque ligne du domtblout, les inseres si elles respectent les #conditions donnees j = 0 passe_selection = 0 self.index_indices = {} if self.matrice[0] == 'hmmsearch': for i in self.matrice[1:]: j += 1 if float(i[6]) <= evalue: if int(recouvrement) <= (int(i[16]) - int(i[15]) + 1) / int(i[5]) * 100: indice = self.tree.insert( '', j, text='', values=(i[0], i[2], i[3], i[5], i[6], i[7], i[9], i[10], i[11], i[15], i[16], i[17], i[18])) self.index_indices[indice] = (i[0], i[2], i[3], i[5], i[6], i[7], i[9], i[10], i[11], i[15], i[16], i[17], i[18]) passe_selection += 1 else: for i in self.matrice[1:]: j += 1 if float(i[6]) <= evalue: if int(recouvrement) <= (int(i[16]) - int(i[15]) + 1) / int(i[2]) * 100: indice = self.tree.insert( '', j, text='', values=(i[0], i[2], i[3], i[5], i[6], i[7], i[9], i[10], i[11], i[15], i[16], i[17], i[18])) self.index_indices[indice] = (i[0], i[2], i[3], i[5], i[6], i[7], i[9], i[10], i[11], i[15], i[16], i[17], i[18]) passe_selection += 1 #Met a jour le label indiquant le nombre de resultat self.labelresultat.grid_forget() self.labelresultat = ttk.Label( self, text='Résultats trouvés : {0}, après filtrage : {1}'.format( len(self.matrice) - 1, passe_selection)) self.labelresultat.grid(row=1, columnspan=3, pady=20) #Bouton d'ajout a la DB self.send_check = ttk.Button(self, text='Ajouter a la base de donnee', command=self.add_to_DB) self.send_check.grid(row=6, column=1) self.tree.grid(row=2, columnspan=3)
def __init__(self, master, result_file): ttk.Frame.__init__(self, master) self.master = master self.result_file = result_file #stock dans matrice les resultats parsé (une ligne -> une liste) self.matrice = self.parsehmmer() self.labelresultat = ttk.Label( self, text='Resultat trouvé : {}'.format(len(self.matrice) - 1)) #Creer un tableau des resultats self.tree = ttkwidgets.CheckboxTreeview(self, height=20) self.tree['columns'] = ('target', 'tlen', 'query', 'qlen', 'evalue', 'score', '#', 'of', 'c-evalue', 'hmm from', 'hmm to', 'ali from', 'ali to') #tailles colonnes self.tree.column("#0", width=50) self.tree.column("target", width=130, anchor=tk.CENTER) self.tree.column("tlen", width=50, anchor=tk.CENTER) self.tree.column("query", width=150, anchor=tk.CENTER) self.tree.column('qlen', width=50, anchor=tk.CENTER) self.tree.column('evalue', width=100, anchor=tk.CENTER) self.tree.column('score', width=100, anchor=tk.CENTER) self.tree.column('#', width=25, anchor=tk.CENTER) self.tree.column('of', width=25, anchor=tk.CENTER) self.tree.column('c-evalue', width=100, anchor=tk.CENTER) self.tree.column('hmm from', width=100, anchor=tk.CENTER) self.tree.column('hmm to', width=100, anchor=tk.CENTER) self.tree.column('ali from', width=100, anchor=tk.CENTER) self.tree.column('ali to', width=100, anchor=tk.CENTER) #nom colonnes for col in self.tree['columns']: self.tree.heading( col, text=col, command=lambda _col=col: self.tree_sort_column(_col, False)) j = 0 #dictionnaire pour associer les elements de la matrice avec les checkbox self.index_indices = {} #Insere toutes les lignes du domtblout for i in self.matrice[1:]: indice = self.tree.insert('', j, text='', values=(i[0], int(i[2]), i[3], int(i[5]), float(i[6]), float(i[7]), int(i[9]), int(i[10]), float(i[11]), int(i[15]), int(i[16]), int(i[17]), int(i[18]))) self.index_indices[indice] = (i[0], i[2], i[3], i[5], i[6], i[7], i[9], i[10], i[11], i[15], i[16], i[17], i[18]) j += 1 self.tree.grid(row=2, columnspan=3) self.filtre_label = ttk.Label(self, text='').grid(row=3) #Choix evalue self.filtre_evalue_label = ttk.Label( self, text='e-value inférieur à :').grid(row=4, column=0) self.filtre_evalue = tk.StringVar() self.filtre_evalue_entry = ttk.Entry(self, textvariable=self.filtre_evalue, width=10, justify='center') self.filtre_evalue_entry.insert(0, '10') self.filtre_evalue_entry.grid(row=5, column=0) #Choix recouvrement self.filtre_recouvrement_label = ttk.Label( self, text='% recouvrement min :').grid(row=4, column=1) self.recouvrement = ttkwidgets.TickScale(self, from_=0, to=100, orient='horizontal', resolution=1, length=200) #bouton de mise a jour self.majbutton = ttk.Button(self, text='Mettre à jour', command=self.update_tree).grid(row=5, column=2) #Bouton d'ajout a la DB self.send_check = ttk.Button(self, text='Ajouter a la base de donnee', command=self.add_to_DB) #Bouton retour recherche self.NouvelleRecherche = ttk.Button(self, text='Nouvelle recherche', command=self.fenetre_recherche) #bouton retour accueil self.Accueil = ttk.Button(self, text='Retour accueil', command=self.fenetre_accueil) #Configuration du layout self.labelresultat.grid(row=1, columnspan=3, pady=20) self.recouvrement.grid(row=5, column=1) self.send_check.grid(row=6, column=1) self.NouvelleRecherche.grid(row=6, column=2) self.Accueil.grid(row=6, column=0) self.grid(row=0, column=1, sticky='news') self.grid_rowconfigure(0, pad=50) self.grid_rowconfigure(6, pad=50) self.grid()
def update_tree(matrice, evalue, recouvrement, tree, labelresultat, frame): '''Efface l'ancien tableau et le reconstruit en appliquant les conditions : evalue max et recouvrement mini''' #verifie que la evalue est sous le bon format sinon retourne un message d'erreur try: evalue = float(evalue) except ValueError: tk.messagebox.showerror( title='Erreur', message= 'La evalue doit etre un reel \nEcriture scientifique accepté sous la forme 1e-N' ) return False recouvrement = int(recouvrement) #Oublie l'ancien tableau et recreer le avec les conditions tree.grid_forget() tree = ttkwidgets.CheckboxTreeview(frame, height=20) tree['columns'] = ('one', 'two', 'three', 'four', 'five', 'six', '7', '8', '9', '10', '11', '12', '13') #tailles colonnes tree.column("#0", width=50, anchor=tk.CENTER) tree.column("one", width=130, anchor=tk.CENTER) tree.column("two", width=50, anchor=tk.CENTER) tree.column("three", width=150, anchor=tk.CENTER) tree.column('four', width=50, anchor=tk.CENTER) tree.column('five', width=100, anchor=tk.CENTER) tree.column('six', width=100, anchor=tk.CENTER) tree.column('7', width=20, anchor=tk.CENTER) tree.column('8', width=20, anchor=tk.CENTER) tree.column('9', width=100, anchor=tk.CENTER) tree.column('10', width=100, anchor=tk.CENTER) tree.column('11', width=100, anchor=tk.CENTER) tree.column('12', width=100, anchor=tk.CENTER) tree.column('13', width=100, anchor=tk.CENTER) #nom colonnes tree.heading('#0', text='select') tree.heading('one', text='target') tree.heading('two', text='tlen') tree.heading('three', text='query') tree.heading('four', text='qlen') tree.heading('five', text='evalue') tree.heading('six', text='score') tree.heading('7', text='#') tree.heading('8', text='of') tree.heading('9', text='c-evalue') tree.heading('10', text='hmm from') tree.heading('11', text='hmm to') tree.heading('12', text='ali to') tree.heading('13', text='ali from') #Pour chaque ligne du domtblout, les inseres si elles respectent les #conditions donnees j = 0 passe_selection = 0 index_indices = {} for i in matrice: j += 1 if float(i[6]) <= evalue: if int(recouvrement) <= (int(i[16]) - int(i[15])) / int( i[5]) * 100: indice = tree.insert('', j, text='', values=(i[0], i[2], i[3], i[5], i[6], i[7], i[9], i[10], i[11], i[15], i[16], i[17], i[18])) index_indices[indice] = (i[0], i[2], i[3], i[5], i[6], i[7], i[9], i[10], i[11], i[15], i[16], i[17], i[18]) passe_selection += 1 #Met a jour le label indiquant le nombre de resultat labelresultat.grid_forget() labelresultat = ttk.Label( frame, text='Résultats trouvés : {0}, après filtrage : {1}'.format( len(matrice), passe_selection)) labelresultat.grid(row=1, columnspan=3, pady=20) #Bouton d'ajout a la DB send_check = ttk.Button(frame, text='Ajouter a la base de donnee', command=lambda: add_to_DB(tree, index_indices)) send_check.grid(row=6, column=1) tree.grid(row=2, columnspan=3)
def troisieme_fenetrefunc(file): '''Fenetre affichant les resultats sous la forme d'un tableau ''' troisieme_fenetre = ttk.Frame() #stock dans matrice les resultats parsé (une ligne -> une liste) matrice = parsehmmsearch(troisieme_fenetre, file) labelresultat = ttk.Label(troisieme_fenetre, text='Resultat trouvé : {}'.format(len(matrice))) #Creer un tableau des resultats tree = ttkwidgets.CheckboxTreeview(troisieme_fenetre, height=20) tree['columns'] = ('one', 'two', 'three', 'four', 'five', 'six', '7', '8', '9', '10', '11', '12', '13') #tailles colonnes tree.column("#0", width=50) tree.column("one", width=130, anchor=tk.CENTER) tree.column("two", width=50, anchor=tk.CENTER) tree.column("three", width=150, anchor=tk.CENTER) tree.column('four', width=50, anchor=tk.CENTER) tree.column('five', width=100, anchor=tk.CENTER) tree.column('six', width=100, anchor=tk.CENTER) tree.column('7', width=20, anchor=tk.CENTER) tree.column('8', width=20, anchor=tk.CENTER) tree.column('9', width=100, anchor=tk.CENTER) tree.column('10', width=100, anchor=tk.CENTER) tree.column('11', width=100, anchor=tk.CENTER) tree.column('12', width=100, anchor=tk.CENTER) tree.column('13', width=100, anchor=tk.CENTER) #nom colonnes tree.heading('#0', text='') tree.heading('one', text='target') tree.heading('two', text='tlen') tree.heading('three', text='query') tree.heading('four', text='qlen') tree.heading('five', text='evalue') tree.heading('six', text='score') tree.heading('7', text='#') tree.heading('8', text='of') tree.heading('9', text='c-evalue') tree.heading('10', text='hmm from') tree.heading('11', text='hmm to') tree.heading('12', text='ali to') tree.heading('13', text='ali from') j = 0 #dictionnaire pour associer les elements de la matrice avec les checkbox index_indices = {} #Insere toutes les lignes du domtblout for i in matrice: indice = tree.insert('', j, text='', values=(i[0], i[2], i[3], i[5], i[6], i[7], i[9], i[10], i[11], i[15], i[16], i[17], i[18])) index_indices[indice] = (i[0], i[2], i[3], i[5], i[6], i[7], i[9], i[10], i[11], i[15], i[16], i[17], i[18]) j += 1 tree.grid(row=2, columnspan=3) filtre_label = ttk.Label(troisieme_fenetre, text='').grid(row=3) #Choix evalue filtre_evalue_label = ttk.Label(troisieme_fenetre, text='e-value inférieur à :').grid( row=4, column=0) filtre_evalue = tk.StringVar() filtre_evalue_entry = ttk.Entry(troisieme_fenetre, textvariable=filtre_evalue, width=10, justify='center') filtre_evalue_entry.insert(0, '10') filtre_evalue_entry.grid(row=5, column=0) #Choix recouvrement filtre_recouvrement_label = ttk.Label(troisieme_fenetre, text='% recouvrement min :').grid( row=4, column=1) recouvrement = ttkwidgets.TickScale(troisieme_fenetre, from_=0, to=100, orient='horizontal', resolution=1, length=200) #bouton de mise a jour majbutton = ttk.Button( troisieme_fenetre, text='Mettre à jour', command=lambda: update_tree(matrice, filtre_evalue.get( ), recouvrement.get(), tree, labelresultat, troisieme_fenetre)).grid( row=5, column=2) ttk.Label(troisieme_fenetre).grid() #Bouton d'ajout a la DB send_check = ttk.Button(troisieme_fenetre, text='Ajouter a la base de donnee', command=lambda: add_to_DB(tree, index_indices)) #Bouton retour recherche NouvelleRecherche = ttk.Button( troisieme_fenetre, text='Nouvelle recherche', command=lambda: retour_recherche(troisieme_fenetre)) #bouton retour accueil Accueil = ttk.Button(troisieme_fenetre, text='Retour accueil', command=lambda: retour_accueil(troisieme_fenetre)) #Configuration du layout labelresultat.grid(row=1, columnspan=3, pady=20) recouvrement.grid(row=5, column=1) send_check.grid(row=6, column=1) NouvelleRecherche.grid(row=6, column=2) Accueil.grid(row=6, column=0) ttk.Label(troisieme_fenetre).grid() troisieme_fenetre.grid(row=0, column=1, sticky='news') troisieme_fenetre.grid_rowconfigure(0, pad=50) troisieme_fenetre.grid_rowconfigure(6, pad=50)
def create_fusion(): global domains_filename domains_filename = tk.filedialog.askopenfilename( initialdir="/", title="Select Domains file", filetypes=(("txt files", "*.txt"), ("all files", "*.*"))) secondary_structure_filename = tk.filedialog.askopenfilename( initialdir="/", title="Select Secondary Structure file", filetypes=(("txt files", "*.txt"), ("all files", "*.*"))) if secondary_structure_filename != "" and domains_filename != "": if is_domain_file(domains_filename) and is_structure_file( secondary_structure_filename): for x in tab3.grid_slaves(): if int(x.grid_info()["row"]) > 1: x.grid_forget() global target_cuts global protein_len target_cuts, protein_len, target_domain = fusion( domains_filename, secondary_structure_filename) Heading = ttk.Label(tab3, text="Target Domains", font=('Calibri', '12', 'bold')) Heading.grid(row=4, column=5, padx=15, pady=10) Domain = ttk.Label(tab3, text="Name", font=('Calibri', '10', 'bold'), foreground=StColors.dark_grey) Domain.grid(row=4, column=7, columnspan=2, padx=15, pady=10) Start = ttk.Label(tab3, text="Start", font=('Calibri', '10', 'bold'), foreground=StColors.dark_grey) Start.grid(row=4, column=10, columnspan=2, padx=15, pady=10) End = ttk.Label(tab3, text="End", font=('Calibri', '10', 'bold'), foreground=StColors.dark_grey) End.grid(row=4, column=12, columnspan=2, padx=15, pady=10) for i in range(len(target_domain)): Domain = ttk.Label(tab3, text=target_domain[i][2], font=('Calibri', '10'), foreground=StColors.dark_grey) Domain.grid(row=5 + i, column=7, columnspan=2) Start = ttk.Label(tab3, text=target_domain[i][0], font=('Calibri', '10'), foreground=StColors.dark_grey) Start.grid(row=5 + i, column=10, columnspan=2) End = ttk.Label(tab3, text=target_domain[i][1], font=('Calibri', '10'), foreground=StColors.dark_grey) End.grid(row=5 + i, column=12, columnspan=2) global nextrow nextrow = 5 + i EmptyRow = ttk.Label(tab3) EmptyRow.grid(row=nextrow, column=0, padx=15, pady=0) Cutting_Headling = ttk.Label(tab3, text="Available Cutting Location", font=('Calibri', '12', 'bold')) Cutting_Headling.grid(row=nextrow + 1, column=5, columnspan=2, padx=15, pady=10) Pyocin_Domains_Headling = ttk.Label(tab3, text="Pyocin:", font=('Calibri', '12', 'bold')) Pyocin_Domains_Headling.grid(row=nextrow + 2, column=5, padx=15, pady=10) global Pyocin_Domains_Table global Target_Domains_Table Pyocin_Domains_Table = ttkwidgets.CheckboxTreeview(tab3) for cut in pyocin_cuts: Pyocin_Domains_Table.insert("", "end", text=str(cut[0]) + '-' + str(cut[1])) Pyocin_Domains_Table.grid(row=nextrow + 3, column=5) Target_Domains_Headling = ttk.Label(tab3, text="Target:", font=('Calibri', '12', 'bold')) Target_Domains_Headling.grid(row=nextrow + 2, column=8, padx=15, pady=10) Target_Domains_Table = ttkwidgets.CheckboxTreeview(tab3) for cut in target_cuts: Target_Domains_Table.insert("", "end", text=str(cut[0]) + '-' + str(cut[1])) Target_Domains_Table.grid(row=nextrow + 3, column=8) ysb = ttk.Scrollbar(tab3, orient='vertical', command=Pyocin_Domains_Table.yview) ysb.grid(row=nextrow + 3, column=6, sticky='ns') Pyocin_Domains_Table.configure(yscroll=ysb.set) ysb = ttk.Scrollbar(tab3, orient='vertical', command=Target_Domains_Table.yview) ysb.grid(row=nextrow + 3, column=9, sticky='ns') Target_Domains_Table.configure(yscroll=ysb.set) EmptyRow = ttk.Label(tab3) EmptyRow.grid(row=nextrow + 4, column=0, padx=15, pady=0) Continue_Label = ttk.Label( tab3, text= "Please choose cutting location for the Pyocin and the target") Continue_Label.grid(row=nextrow + 5, column=5, columnspan=4, padx=15, pady=0) NewSearchButton = ttk.Button(tab3, text='New Search', command=new_search) ExportButton = ttk.Button(tab3, text='Get the Sequence', command=create_fusion_sequence) EmptyRow = ttk.Label(tab3) EmptyRow.grid(row=nextrow + 6, column=0, padx=15, pady=0) NewSearchButton.grid(row=0, column=12) ExportButton.grid(row=nextrow + 5, column=11) else: EmptyRow = ttk.Label(tab3) EmptyRow.grid(row=5, column=0, padx=15, pady=0) ErrorFiles = ttk.Label( tab3, text= 'Please Load Domains file first and Secondary Structure file second' ) ErrorFiles.grid(row=7, column=5, columnspan=5) else: EmptyRow = ttk.Label(tab3) EmptyRow.grid(row=5, column=0, padx=15, pady=0) ErrorFiles = ttk.Label(tab3, text='Please Load all files!') ErrorFiles.grid(row=7, column=5, columnspan=5)