Exemple #1
0
    def update_list(self):
        """update list.

        Updates preset list from database array
        """
        #clear all entries in preset tree
        self.presettree.delete(*self.presettree.get_children())

        #loop over all items in list
        for preset in item_list.get():
            #call filter function from item to check if it should be shown
            show = True
            if self._search_filter != "":
                show = item_list.get()[preset].check_filter(
                    self._search_filter)

            #show item based on filter function result
            if show:
                self.presettree.insert(
                    "",
                    END,
                    text=item_list.get()[preset].preset_name,
                    values=(item_list.get()[preset].plugin_name, ))

        self.update_ui()
Exemple #2
0
    def update_ui(self):
        """update UI.

        Updates status of controls based on current selectios
        """
        if item_list.initialized():
            self.lbl_database['text'] = item_list.file_path()
            self.btn_save_preset['state'] = NORMAL
            self.btn_import_folder['state'] = NORMAL

            #check if an item in tree is selected, if not reset internal variable
            if len(self.presettree.selection()) == 0:
                self._selected_item = None

            #enabe or disable save button if there is something in the database
            if len(item_list.get()) == 0:
                self.btn_save_database['state'] = DISABLED
            else:
                self.btn_save_database['state'] = NORMAL

            #enable or disable load button if an item is selected
            if self._selected_item == None:
                self.btn_load_preset['state'] = DISABLED
            else:
                self.btn_load_preset['state'] = NORMAL

        else:
            self.btn_load_preset['state'] = DISABLED
            self.btn_save_preset['state'] = DISABLED
            self.btn_import_folder['state'] = DISABLED
            self.btn_save_database['state'] = DISABLED
Exemple #3
0
    def update_info(self):
        """update info.

        Updates info tree with selected item
        """
        #clear all entries in info tree
        self.presetinfo.delete(*self.presetinfo.get_children())
        selected_items = self.presettree.selection()

        #check if an item in preset tree is selected
        if len(selected_items) > 0:
            for it in self.presettree.selection():
                index = self.presettree.item(it)["text"]
                selected_item = item_list.get("",[])[index]
                preset_entry = self.presetinfo.insert("", END, text=selected_item.preset_name)
                #loop over properties from selected item and display them in info tree
                for key, value in selected_item.properties.items():
                    if key != "Tags":
                        self.presetinfo.insert(preset_entry, END, text=key, values=(value,))
                
                alltags = selected_item.properties["Tags"]
                tags_entry = self.presetinfo.insert(preset_entry, END, text="Tags", values=(len(alltags),))
                for prop in alltags:
                    self.presetinfo.insert(tags_entry, END, text="", values=(prop,))
                
                self.presetinfo.item(preset_entry, open=True)
                self.presetinfo.item(tags_entry, open=True)
Exemple #4
0
    def update_select(self):
        """Update selected tags list.

        Updates the list wit possible selectable tags
        """
        #build list of search tags from the current item list
        #initialize list with selected items, otherwise this can lead to empty lists
        search_tags = self.selected_tags.copy()
        for preset in item_list.get(self._search_filter, self.selected_tags):
            props = item_list.get("", [])[preset].search_tags()
            for prop in props:
                if prop not in search_tags:
                    search_tags.append(prop)

        #delete all tags from the UI to rebuild it
        for child in self._cb_frame.scrollable_frame.winfo_children():
            child.destroy()

        #dictionary where the variables are stored in
        self.filter_tags = {}
        #counter for making 2 columns
        row = 0
        column = 0
        for tag in search_tags:
            #create a var that is later used for getting status of checboxes
            checked = IntVar()

            #check if tag is selected, if so set value to 1
            if tag in self.selected_tags:
                checked.set(1)

            #create new checkbutton for search tag
            cb = Checkbutton(self._cb_frame.scrollable_frame, text=tag, variable=checked, command=self.update_list)
            cb.grid(row=row, column=column, sticky='ew')
            self.filter_tags[tag] = checked

            #counter for columns
            column += 1
            if column >= 2:
                column = 0
                row += 1
Exemple #5
0
    def select_item(self, evt):
        """select item.

        Event that is called when user clicks on the treeview with the preset

        Parameters
        ----------
            evt: event armgument passed from tkinter
        """
        #get selected item from tree and select from list
        selected_item = self.presettree.item(self.presettree.focus())
        index = selected_item["text"]
        self._selected_item = item_list.get()[index]
        self._selected_item.onclick()

        self.update_info()
        self.update_ui()
Exemple #6
0
def load_preset():
    """load.

    Loads selected preset
    """
    #call load function from selected item
    selected_items = glob.main_window.presettree.selection()
    if len(selected_items) == 1:
        glob.main_window._selected_item.load()
        logging.debug('Loading Preset: ' +
                      glob.main_window._selected_item.preset_name)
    elif len(selected_items) > 1:
        for it in selected_items:
            index = glob.main_window.presettree.item(it)["text"]
            selected_item = item_list.get("", [])[index]
            selected_item.load(True)
            logging.debug('Loading Preset: ' + selected_item.preset_name)
    else:
        pass
Exemple #7
0
    def update_list(self):
        """update list.

        Updates preset list from database array
        """
        #clear all entries in preset tree
        self.presettree.delete(*self.presettree.get_children())

        self.selected_tags = []
        for key, value in self.filter_tags.items():
            if value.get():
                self.selected_tags.append(key)

        filtered_list = item_list.get(self._search_filter, self.selected_tags)

        for preset in filtered_list:
            self.presettree.insert("", END, 
                                        text=filtered_list[preset].preset_name, 
                                        values=(filtered_list[preset].plugin_name,))

        self.update_ui()