def on_apply_clicked(self, widget, clear=False): if clear: self.reset() flip_horizontal = self.check_horizontal.get_active() flip_vertical = self.check_vertical.get_active() if self.rotate_90.get_active(): rotation_angle = 1.0 elif self.rotate_180.get_active(): rotation_angle = 2.0 elif self.rotate_270.get_active(): rotation_angle = 3.0 else: rotation_angle = 0.0 to_update = [] if self.check_this.get_active(): to_update = [ self.no_page ] elif self.check_all.get_active(): to_update = range(0, self.document.get_n_pages()) elif self.check_range.get_active(): to_update = get_pages_from_ranges( get_ranges(self.range.get_text())) for i in to_update: if clear and str(i) in self.pages.keys(): del self.pages[str(i)] else: self.pages[str(i)] = PageOptions(rotation_angle, flip_horizontal, flip_vertical) if self.no_page in to_update: self.preview()
def rotate_some_pages(self, selected): files = tools.get_files(selected) if files: file0 = files[0] filename, filext = os.path.splitext(file0) file_out = filename + '_rotated.pdf' last_page = cairoapi.get_num_of_pages(file0) spd = SelectPagesRotateDialog(_('Rotate some pages'), last_page, file_out) if spd.run() == Gtk.ResponseType.ACCEPT: ranges = tools.get_ranges(spd.entry1.get_text()) if spd.rbutton1.get_active(): degrees = 270 elif spd.rbutton2.get_active(): degrees = 90 else: degrees = 180 spd.destroy() if len(ranges) > 0: dialog = Progreso(_('Rotate some pages in pdf'), None, 1) diboo = DoitInBackgroundOnlyOne( pdfapi.rotate_ranges_in_pdf, file0, file_out, degrees, ranges) diboo.connect('done', dialog.increase) diboo.start() dialog.run() else: spd.destroy()
def on_apply_clicked(self, widget, clear=False): if clear: self.reset() text = self.textmark.get_text() color = self.button_color.get_rgba() font = self.button_font.get_font() size = int(self.button_font.get_font_desc().get_size()/1000) x = self.x y = self.y if self.check_this.get_active(): to_update = [ self.no_page] elif self.check_all.get_active(): to_update = range(0, self.document.get_n_pages()) elif self.check_range.get_active(): to_update = get_pages_from_ranges( get_ranges(self.range.get_text())) for i in to_update: if clear and str(i) in self.pages.keys(): del self.pages[str(i)] else: self.pages[str(i)] = PageOptions(text_text=text, text_color=color, text_font=font, text_size=size, text_x=x, text_y=y) if self.no_page in to_update: self.preview()
def _create_inputs(tartemplate): def rewrite_res_section(base, fil=None): # for line in inpfil: # if line.strip() == '[Sequence_Restraints]': # break # print(line, end='', file=fil) # print('[Sequence_Restraints]', file=fil) if "_dyn" in base and '08_dyn' not in base: idx = int(base[:2]) print(" {1} {2} {0}".format(dyn[idx][0], *solute_range), file=fil) if len(dyn[idx]) == 2: print(" {1} {2} {0}".format(dyn[idx][1], *solvent_range), file=fil) else: for feprange in reversed(fepranges): print(" {1} {2} {0}".format(fep, *feprange), file=fil) print('', file=fil) print('', file=fil) fil.close() pdbfil = 'mutant.pdb' fepfil = 'mutant.fep' if not os.path.isfile(pdbfil): errmsg = 'PDBFile {0} does not exist: {1}'.format(pdbfil, os.getcwd()) raise Exception(errmsg) if not os.path.isfile(fepfil): errmsg = 'FEPFile {0} does not exist: {1}'.format(fepfil, os.getcwd()) raise Exception(errmsg) # determine the ranges for solute, solvent, and fepatoms solute_range, solvent_range = tools.get_solute_and_solvent_ranges(pdbfil) indexes = tools.get_fep_atom_pdbindexes(fepfil) fepranges = tools.get_ranges(indexes) tartemplate.extractall() for inp in os.listdir('.'): if inp[-4:] == ".inp": if "_eq" in inp or "_fep" in inp or "_dyn" in inp: base = os.path.basename(inp) rewrite_res_section(base, open(inp, 'a'))
def handle_update_availability(put_data): """ Helper method to handle the update_availability API call. """ response = {} try: if not 'id' in session: raise Exception('No id given') if 'availability' not in put_data: raise Exception('No availability provided.') if len(put_data['availability']) < 1: avail = [] else: avail = tools.get_ranges( [int(x) for x in put_data['availability'].split(';')]) return handle_edit_user({'availability': pickle.dumps(avail)}) except Exception as e: response['status'] = 'failure' response['message'] = e.message return response
def handle_update_availability(put_data): """ Helper method to handle the update_availability API call. """ response = {} try: if not 'id' in session: raise Exception('No id given') if 'availability' not in put_data: raise Exception('No availability provided.') if len(put_data['availability']) < 1: avail = [] else: avail = tools.get_ranges([int(x) for x in put_data['availability'].split(';')]) return handle_edit_user({'availability': pickle.dumps(avail)}) except Exception as e: response['status'] = 'failure' response['message'] = e.message return response
def extract_some_pages(selected, window): files = tools.get_files(selected) if files: spd = SelectPagesDialog(_('Extract pages from PDF'), None, window) if spd.run() == Gtk.ResponseType.ACCEPT: ranges = tools.get_ranges(spd.entry1.get_text()) spd.hide() if ranges: dialog = Progreso(_('Extract pages from PDF'), window, 1) diboo = doitinbackground.DoitInBackgroundExtractSomePages( files, ranges) diboo.connect('todo', dialog.set_todo_label) diboo.connect('donef', dialog.set_fraction) diboo.connect('finished', dialog.end_progress) diboo.connect('interrupted', dialog.end_progress) dialog.connect('i-want-stop', diboo.stop_it) diboo.start() dialog.run() spd.destroy()
def extract_some_pages(self, selected): files = tools.get_files(selected) if files: file0 = files[0] filename, filext = os.path.splitext(file0) file_out = filename + '_extracted_pages.pdf' last_page = cairoapi.get_num_of_pages(file0) spd = SelectPagesDialog(_('Extract some pages'), last_page, file_out) if spd.run() == Gtk.ResponseType.ACCEPT: ranges = tools.get_ranges(spd.entry1.get_text()) file_out = spd.get_file_out() spd.destroy() if len(ranges) > 0: dialog = Progreso(_('Extract some pages in pdf'), None, 1) diboo = DoitInBackgroundOnlyOne( pdfapi.extract_ranges, file0, file_out, ranges) diboo.connect('done', dialog.increase) diboo.start() dialog.run() else: spd.destroy()
def on_apply_clicked(self, widget, clear=False): if clear: self.reset() file_watermark = self.file_entry.get_label() if not os.path.exists(file_watermark): file_watermark = None zoom = float(self.zoom_entry.get_value() / 100.0) if self.check_this.get_active(): to_update = [ self.no_page] elif self.check_all.get_active(): to_update = range(0, self.document.get_n_pages()) elif self.check_range.get_active(): to_update = get_pages_from_ranges( get_ranges(self.range.get_text())) for i in to_update: if clear and str(i) in self.pages.keys(): del self.pages[str(i)] else: self.pages[str(i)] = PageOptions(image_x=self.x, image_y=self.y, image_zoom=zoom, image_file=file_watermark) if self.no_page in to_update: self.preview()
def remove_some_pages(selected, window): files = tools.get_files(selected) if files: file0 = files[0] filename = os.path.splitext(file0)[0] file_out = filename + '_removed_pages.pdf' spd = SelectPagesDialog(_('Remove PDF'), file_out, window) if spd.run() == Gtk.ResponseType.ACCEPT: ranges = tools.get_ranges(spd.entry1.get_text()) file_out = spd.get_file_out() spd.hide() if ranges: dialog = Progreso(_('Remove PDF'), window, 1) diboo = doitinbackground.DoitInBackgroundRemoveSomePages( file0, file_out, ranges) diboo.connect('start', dialog.set_max_value) diboo.connect('done', dialog.increase) diboo.connect('finished', dialog.end_progress) diboo.connect('interrupted', dialog.end_progress) dialog.connect('i-want-stop', diboo.stop_it) diboo.start() dialog.run() spd.destroy()