예제 #1
0
    def createUI(self):
        if len(self.images_list) != 0:
            self.buttons = [ImageButton(image_path) for image_path in self.images_list]
            images_dimensions = [Katana.getImageDimensions(image_path) for image_path in self.images_list]
            self.labels = [QtGui.QLabel("(%d x %d)\n(%s)"%(width, height, os.path.basename(image_path))) for ((width, height), image_path) in zip(images_dimensions,self.images_list)]
            self.has_image = True
        else:
            self.has_image = False
            na_image = os.path.join("essentials","na_parent_image.png")
            self.buttons = [ImageButton(na_image)]
            width, height = Katana.getImageDimensions(na_image)
            self.labels = [QtGui.QLabel("(%d x %d)"%(width, height))]
        self.layout = QtGui.QHBoxLayout()
        self.logic_group = QtGui.QButtonGroup()
        self.logic_group.setExclusive(True)
        button_label_layouts = []
        for button, label in zip(self.buttons, self.labels):
            button.setCheckable(True)
            button_label_layouts.append(QtGui.QVBoxLayout())
            button_label_layouts[-1].addWidget(button, 1, QtCore.Qt.AlignVCenter | QtCore.Qt.AlignHCenter)
            button_label_layouts[-1].addWidget(label,0, QtCore.Qt.AlignBottom | QtCore.Qt.AlignHCenter)
            self.layout.addLayout(button_label_layouts[-1])
            self.logic_group.addButton(button)

        self.layout.addStretch(10)
        self.buttons[0].setChecked(True)
        self.setLayout(self.layout)
예제 #2
0
 def checkIconsAvailability(self):
     import pandas as pd
     import xlsxwriter
     import Katana
     data = self.getData()
     icons = {}
     repo_path = str(QtGui.QFileDialog.getExistingDirectory(self, "Select the repository folder.", os.getcwd(), 
                                                 QtGui.QFileDialog.ShowDirsOnly | QtGui.QFileDialog.DontResolveSymlinks))
     if not repo_path:
         repo_path = os.path.join(os.getcwd(), "Images","Repository")
     for fsn_row in self.getData():
         category = fsn_row["Category"]
         for key in fsn_row.keys():
             if "Attribute" in key:
                 attribute = fsn_row[key].strip()
                 if attribute.strip() != "":
                     icon_status, folders = Katana.checkIcon(attribute, category, repository_path=repo_path)
                     if attribute not in icons.keys():
                         icons[attribute] = {
                                     "Category": category,
                                     "Icon in Folder(s)": folders
                         }
                     else:
                         if category not in icons[attribute]["Category"]:
                             icons[attribute]["Category"] = icons[attribute]["Category"] + ", "  +category
                         icons[attribute]["Icon in Folder(s)"] = [folder for folder in list(set(icons[attribute]["Icon in Folder(s)"] + folders)) if len(folder)>0]
     icons_data_frame = pd.DataFrame.from_dict(icons)
     icons_data_frame = icons_data_frame.apply(self.getMeaningfulPathText,axis=0)
     file_path = os.path.join(os.getcwd(),"cache","Icon_Search_Results_%s.csv"%datetime.datetime.now().strftime("%y%m%d_%H%M%S"))
     #file_handler = pd.ExcelWriter(file_path,engine="xlsxwriter")
     icons_data_frame.T.to_csv(file_path)
     os.startfile(file_path,"open")
예제 #3
0
    def setFSNs(self, fsn_list):
        self.fsn_data_dict = {}
        self.fsn_icon_table.setRowCount(0)
        row_counter = 0
        fsn_list.sort()
        self.fsn_icon_table.setRowCount(0)
        for fsn_string in fsn_list:
            #get a list of all possible parent images in the repo\Parent Images\ folder.
            fsn = fsn_string[fsn_string.rfind(" ")+1:].strip()

            parent_images_paths_list = Katana.getParentImagesList(fsn, self.repo_path)
            self.fsn_data_dict[fsn] = {
                            "Paths": parent_images_paths_list,
                            "Buttons": ImageButtonLine(parent_images_paths_list)
                            }
            #Add a row in the QTable. The first cell is the FSN.
            self.fsn_icon_table.insertRow(row_counter)
            fsn_column_index = 0
            self.fsn_icon_table.setItem(row_counter, fsn_column_index, QtGui.QTableWidgetItem(str(fsn_string)))
            buttons_column_index = 1
            #The second cell is a buttons group which contains an image button for each possible image.
            self.fsn_icon_table.setCellWidget(row_counter, buttons_column_index, self.fsn_data_dict[fsn]["Buttons"])
            self.fsn_icon_table.setHorizontalHeaderLabels(["FSN", "Images"])
            self.fsn_icon_table.resizeColumnsToContents()
            self.fsn_icon_table.resizeRowsToContents()

            row_counter+=1