def setup_connects(self, grandparent, ui_dict): for key in ui_dict: setattr(self, key, getattr(grandparent, ui_dict[key])) self.table.cellDoubleClicked.connect(self.load_picture) self.table.pressed.connect(self.set_current_table) self.checkbox.clicked.connect(self.table_from_list) output = int(self.parent.settings.value((self.name + '_checkbox'), QtCore.Qt.Unchecked)) self.checkbox.setCheckState(output) self.table.itemDropped.connect(self.process_drop) self.table.itemUrlPasted.connect(self.process_paste) self.table.itemImageDelete.connect(self.delete_selection) self.table.itemImagePasted.connect(self.pre_image_paste) if self.name is not 'transfer_table': self.directory_comboBox.setInsertPolicy(QtGui.QComboBox.InsertAtTop) self.directory_comboBox.setMaxCount(10) self.init_sort_comboBox() self.sort_comboBox.setCurrentIndex(int(self.parent.settings.value(self.name + 'sort_comboBox', 0))) if self.parent.settings.value(self.name + '_combo_items', []): self.directory_comboBox.insertItems(0, self.parent.settings.value(self.name + '_combo_items', [])) self.directory_comboBox.setCurrentIndex(int(self.parent.settings.value( self.name + '_combo_items_index', 0))) self.browse_button.clicked.connect(self.browse_directory) self.refresh_button.clicked.connect(self.refresh_table) self.directory_comboBox.currentIndexChanged.connect(self.sort_directory_combobox) self.sort_comboBox.currentIndexChanged.connect(self.refresh_table) self.directory_path = kustomWidgets.dir_clean(self.directory_comboBox.currentText())
def create_dir_table_data(self): self.pics_in_dir = [] if self.name is 'transfer_table': self.pics_in_dir = self.parent.transfer_table_list.copy() return self.directory_path = kustomWidgets.dir_clean(self.directory_comboBox.currentText()) try: self.db_is_up = self.parent.parent.run_db_conn.status except AttributeError: self.db_is_up = False for pic_type in self.picture_type_list: tl = glob.glob(self.directory_path + '\\' + pic_type) for file_path in tl: file_pack = self.create_file_pack(file_path) self.get_run_number(file_pack) if file_pack not in self.parent.transfer_table_list: self.pics_in_dir.append(file_pack) (sort_index, reverse_boolean) = self.sort_dict[self.sort_comboBox.currentText()] self.pics_in_dir = sorted(self.pics_in_dir, key=lambda x: x[sort_index], reverse=reverse_boolean)