def __init__(self, configFile = None): global conf conf = self if not configFile: configFile = os.path.join(scripting.get_config_dir(), "BioImageXD.ini") self.configItems = {} self.installPath = os.getcwd() self.parser = FlexConfigParser() cfgfile = self.getPath(configFile) self.configFile = cfgfile try: fp = codecs.open(cfgfile, "r","utf-8") self.parser.readfp(fp, cfgfile) except IOError: pass # Set the initial values if platform.system() == "Windows": vtkpath = self.getPath(["C:\\VTK-build"]) else: vtkpath = "/home/kalpaha/BioImageXD/VTK-current" self.setConfigItem("ShowTip", "General", "False", 0) self.setConfigItem("AskOnQuit", "General", "True", 0) self.setConfigItem("TipNumber", "General", 0, 0) self.setConfigItem("RestoreFiles", "General", "True", 0) self.setConfigItem("ReportCrash", "General", "True", 0) self.setConfigItem("CleanExit", "General", "True", 0) self.readConfigItem("ShowTip", "General") self.readConfigItem("RestoreFiles", "General") self.readConfigItem("TipNumber", "General") self.readConfigItem("AskOnQuit", "General") self.readConfigItem("RescaleOnLoading", "Performance") self.readConfigItem("AutoRescaleMapping", "Performance") self.readConfigItem("RestoreFiles", "General") self.readConfigItem("ReportCrash", "General") self.readConfigItem("CleanExit", "General") self.readConfigItem("BeginnerColor", "General") self.readConfigItem("IntermediateColor", "General") self.readConfigItem("ExperiencedColor", "General") configItem = self.getConfigItem("BeginnerColor", "General") if configItem: scripting.COLOR_BEGINNER = eval(configItem) configItem = self.getConfigItem("IntermediateColor", "General") if configItem: scripting.COLOR_INTERMEDIATE = eval(configItem) configItem = self.getConfigItem("ExperiencedColor", "General") if configItem: scripting.COLOR_EXPERIENCED = eval(configItem) self.setConfigItem("RemoveOldVTK", "VTK", 1, 0) self.setConfigItem("VTKPath", "VTK", vtkpath, 0) self.setConfigItem("ImageFormat", "Output", "png", 0) fpath = os.path.expanduser("~") self.setConfigItem("FramePath", "Paths", fpath, 0) self.setConfigItem("VideoPath", "Paths", os.path.join(fpath, "video.avi"), 0) self.setConfigItem("DataPath", "Paths", "/home/kalpaha/BioImageXD/Data/", 0) self.setConfigItem("LastPath", "Paths", "/home/kalpaha/BioImageXD/Data/", 0) self.setConfigItem("LogPath", "Paths", "", 0) self.setConfigItem("PreviewPath", "Paths", "", 0) self.setConfigItem("RememberPath", "Paths", 1) # Then read the settings file self.readPathSettings() self.insertModuleDirectories() self.processPathSettings()
sys.path.insert(0, itkpydir) path = os.getenv("PATH") path = path + os.path.pathsep + itklibdir os.putenv("PATH", path) if scripting.main_is_frozen() and platform.system()=="Darwin": import site site.addsitedir(os.environ["RESOURCEPATH"]+"/InsightToolkit/WrapITK/Python") site.addsitedir(os.environ["RESOURCEPATH"]+"/InsightToolkit/WrapITK/lib") # This will fix the VTK paths using either values from the # configuration file, or sensible defaults conffile = os.path.join(scripting.get_config_dir(), "BioImageXD.ini") conf = Configuration.Configuration(conffile) w = vtk.vtkOutputWindow() i = w.GetInstance() def exceptHook(type, value, traceback): """ mark an unhandled exception as happened """ scripting.unhandledException = 1 sys.__excepthook__(type, value, traceback) sys.excepthook = exceptHook def onWarning(obj, evt, *args):