def Activated(self): FreeCAD.Console.PrintWarning('opening ' + self.exFile + "\r\n") import os, sys # So we can open the "Open File" dialog mw = FreeCADGui.getMainWindow() # Start off defaulting to the Examples directory manp_base_path = mvr_locator.module_path() exs_dir_path = os.path.join(manp_base_path, 'help') abs_manp_path = mvr_locator.abs_module_path() # Append this script's directory to sys.path sys.path.append(os.path.dirname(exs_dir_path)) fnameDemo=(os.path.join(exs_dir_path, self.exFile)) ext = os.path.splitext(os.path.basename(fnameDemo))[1] nme = os.path.splitext(os.path.basename(fnameDemo))[0] # We've created a library that FreeCAD can use as well to open CQ files FC_majorV=int(float(FreeCAD.Version()[0])) FC_minorV=int(float(FreeCAD.Version()[1])) if ext.lower()==".pdf": import subprocess, sys if sys.platform == "linux" or sys.platform == "linux2": # linux subprocess.call(["xdg-open", fnameDemo]) if sys.platform == "darwin": # osx cmd_open = 'open '+fnameDemo os.system(cmd_open) #win, osx else: # win subprocess.Popen([fnameDemo],shell=True)
def ListDemos(): import os import mvr_locator dirs = [] # List all of the example files in an order that makes sense module_base_path = mvr_locator.module_path() help_dir_path = os.path.join(module_base_path, 'help') dirs = os.listdir(help_dir_path) dirs.sort() return dirs