def generateScript(event): script = template % (str(datetime.now()), filter(lambda path: path.endswith("IsoView-GCaMP"), sys.path)[-1], srcDir, tgtDir, kernel_path, ", ".join(imap(str, calibration)), "".join("\n %i: [%s]," % (i, asString(aff)) for i, aff in enumerate(preCropAffines)), params.get("CM_0_1_n_iterations", 1), "\"CM_2_3_n_iterations\": %i" % params.get("CM_2_3_n_iterations", 1) if 4 == len(preCropAffines) else "", ", ".join(imap(str, ROI[0])), ", ".join(imap(str, ROI[1])), "".join("\n [%s]," % asString(postCropAffines[i]) for i in xrange(1, len(postCropAffines))), params["First time point"], params["Last time point"]) tab = None for frame in JFrame.getFrames(): if str(frame).find("org.scijava.ui.swing.script.TextEditor[") > -1: try: tab = frame.newTab(script, "python") break except: print sys.exc_info() if not tab: try: now = datetime.now() path = os.path.join(System.getProperty("java.io.tmpdir"), "script-%i-%i-%i_%i:%i.py" % (now.year, now.month, now.day, now.hour, now.minute)) with open(path, 'w') as f: f.write(script) print "Wrote script to " + path except: print sys.exc_info() print script
def addFontResizing(): global frames containers = [frame for frame in JFrame.getFrames() if frame.getTitle() == "File paths" and frame.isVisible()] frames = containers[:] from java.awt import Container while len(containers) > 0: for component in containers.pop(0).getComponents(): if isinstance(component, JTable): tables.append(component) components.append(component) components.append(component.getTableHeader()) elif isinstance(component, Container): containers.append(component) components.append(component) # for component in components: #print type(component).getSimpleName() component.addKeyListener(FontSizeAdjuster())
def generateScript(event): script = template % (str(datetime.now()), filter(lambda path: path.endswith("IsoView-GCaMP"), sys.path)[-1], srcDir, tgtDir, kernel_path, ", ".join(imap(str, calibration)), asString(preCropAffines[0]), asString(preCropAffines[1]), asString(preCropAffines[2]), asString(preCropAffines[3]), params["CM_0_1_n_iterations"], params["CM_2_3_n_iterations"], ", ".join(imap(str, ROI[0])), ", ".join(imap(str, ROI[1])), asString(postCropAffines[1]), asString(postCropAffines[2]), asString(postCropAffines[3]), params["First time point"], params["Last time point"]) tab = None for frame in JFrame.getFrames(): if str(frame).startswith("org.scijava.ui.swing.script.TextEditor["): try: tab = frame.newTab(script, "python") break except: print sys.exc_info() if not tab: try: now = datetime.now() with open(os.path.join(System.getProperty("java.io.tmpdir"), "script-%i-%i-%i_%i:%i.py" % (now.year, now.month, now.day, now.hour, now.minute)), 'w') as f: f.write(script) except: print sys.exc_info() print script