def set_outputFolder(self): path = tkFileDialog.askdirectory( title='Please select output path').replace('/', '\\') if os.path.isdir(path): settings.set_values("output_path", path) self.outputPath_le.setText(path) else: print "wrong path"
def set_converter(self): path = tkFileDialog.askopenfilename( title='Please select converter file', filetypes=[('*.exe', '*.exe')]).replace('/', '\\') settings.set_values("converter_path", path) if os.path.basename(path) == 'iconvert.exe': settings.set_values('activeConverter', 'iconvert') self.__fill_labels()
def get_all_selected_ext(self): "return all selected extensions" filtered = [] items = self.selectAll() for i in range(self.count()): if self.item(i).checkState() == Qt.CheckState.Checked: filtered.append(self.item(i).text()) settings.set_values('filtered', filtered)
def ext_changed(self): value = self.outExt_cb.itemText(self.outExt_cb.currentIndex()) settings.set_values('convert_to_ext', value) if settings.parameters.get( 'convert_to_ext') in settings.parameters.get( 'support_compression'): self.compression_chb.setEnabled(1) self.compression_spb.setEnabled(1) else: self.compression_chb.setEnabled(0) self.compression_spb.setEnabled(0)
def check_format_support(self, ext=None ): if ext: ext_list = settings.parameters.get('extensions') converter = settings.parameters.get('activeConverter') ext_supported = settings.parameters.get(converter) if converter != '': if ext not in ext_list: if ext in ext_supported: ext_list.append(ext) settings.set_values('extensions', ext_list) return 1 else: # not supported by converter return -1 else: #already in list return 0 else: return -2 #call set converter function
def __init__(self): super(ImageConverterMainClass, self).__init__() self.setupUi(self) self.filesList = SourceFilesList.SourceFilesListClass() self.sourceFiles_ly.addWidget(self.filesList) self.setWindowFlags(Qt.WindowStaysOnTopHint) self.extManagerList = ExtList.ExtListClass() self.extList_ly.addWidget(self.extManagerList) self.outputPath_le = LineEdit.EditLineClass() self.outputPath_ly.addWidget(self.outputPath_le) self.outExt_cb = ComboBox.ComboBoxClass() self.outExt_ly.addWidget(self.outExt_cb) # connections self.convPath_btn.clicked.connect(self.set_converter) self.addExt_le.returnPressed.connect(self.add_ext) self.selectAll_btn.clicked.connect(self.extManagerList.select_all) self.selectNone_btn.clicked.connect(self.extManagerList.deselect_all) self.outputPath_btn.clicked.connect(self.set_outputFolder) self.startStop_btn.clicked.connect( self.filter_extensions) #convEngine.run_converter self.outExt_cb.currentIndexChanged.connect(self.ext_changed) self.compression_chb.stateChanged.connect(self.compression_on_off) self.compression_spb.valueChanged.connect(self.set_compression) self.scale_sldr.valueChanged.connect(self.change_scale) self.folder_btn.clicked.connect(self.add_folder_to_src) self.img_btn.clicked.connect(self.add_img_to_src) self.delAll_btn.clicked.connect(self.filesList.del_all_item) #CSS homework. Autoload css file on update. self.pathToWatch = os.path.dirname(__file__) self.style = os.path.join(os.path.dirname(__file__), 'IC.css') self.fs_watcher = QFileSystemWatcher([self.pathToWatch, self.style]) self.fs_watcher.directoryChanged.connect(self.directory_changed) self.fs_watcher.fileChanged.connect(self.file_changed) #check progress bar #self.progressBar.setValue(75) # start self.setStyleSheet(open(self.style).read()) settings.set_values('convert_to_ext', '.jpg') if not settings.parameters.get('convert_to_ext') == ".jpg": self.compression_chb.setEnabled(0) self.compression_spb.setEnabled(0) settings.set_values('scale', 100) settings.set_values('compress', False) self.scaleVal_le.setText(str(self.scale_sldr.value())) self.__fill_labels() self.__fill_extensions() root = Tkinter.Tk() root.withdraw()
def __init__(self): super(ImageConverterMainClass, self).__init__() self.setupUi(self) self.filesList = SourceFilesList.SourceFilesListClass() self.sourceFiles_ly.addWidget(self.filesList) self.setWindowFlags(Qt.WindowStaysOnTopHint) self.extManagerList = ExtList.ExtListClass() self.extList_ly.addWidget(self.extManagerList) self.outputPath_le = LineEdit.EditLineClass() self.outputPath_ly.addWidget(self.outputPath_le) self.outExt_cb = ComboBox.ComboBoxClass() self.outExt_ly.addWidget(self.outExt_cb) # connections self.convPath_btn.clicked.connect(self.set_converter) self.addExt_le.returnPressed.connect(self.add_ext) self.selectAll_btn.clicked.connect(self.extManagerList.select_all) self.selectNone_btn.clicked.connect(self.extManagerList.deselect_all) self.outputPath_btn.clicked.connect(self.set_outputFolder) self.startStop_btn.clicked.connect( self.filter_extensions) #convEngine.run_converter self.outExt_cb.currentIndexChanged.connect(self.ext_changed) self.compression_chb.stateChanged.connect(self.compression_on_off) self.compression_spb.valueChanged.connect(self.set_compression) self.scale_sldr.valueChanged.connect(self.change_scale) self.folder_btn.clicked.connect(self.add_folder_to_src) self.img_btn.clicked.connect(self.add_img_to_src) self.delAll_btn.clicked.connect(self.filesList.del_all_item) # start settings.set_values('convert_to_ext', '.jpg') if not settings.parameters.get('convert_to_ext') == ".jpg": self.compression_chb.setEnabled(0) self.compression_spb.setEnabled(0) settings.set_values('scale', 100) settings.set_values('compress', False) self.scaleVal_le.setText(str(self.scale_sldr.value())) self.__fill_labels() self.__fill_extensions() root = Tkinter.Tk() root.withdraw()
def change_scale(self): settings.set_values('scale', self.scale_sldr.value())
def set_compression(self): settings.set_values('quality_compression', self.compression_spb.value())
def compression_on_off(self): if self.compression_chb.isChecked(): settings.set_values('compress', True) self.set_compression() else: settings.set_values('compress', False)