def __init__(self, fileName): scriptEnv = Python.CreateRuntime() self.fileName = fileName self.engine = scriptEnv.GetEngine("python") self.context = HostingHelpers.GetLanguageContext(self.engine) scriptEnv.LoadAssembly(Type.GetType("System.String").Assembly) #mscorlib.dll scriptEnv.LoadAssembly(UriBuilder().GetType().Assembly) #System.dll self.InitializePath() executable = Assembly.GetEntryAssembly().Location prefix = Path.GetDirectoryName(executable) self.context.SystemState.executable = executable self.context.SystemState.exec_prefix = self.context.SystemState.prefix = prefix import imp mod = imp.new_module('__main__') mod.__file__ = fileName mod.__builtins__ = sys.modules['__builtin__'] self.context.SystemState.modules['__main__'] = mod self.mainScope = scriptEnv.CreateScope(mod.__dict__)
SolidColorBrush(Color.FromArgb(255, 25, 23, 124)), TokenCategory.StringLiteral: SolidColorBrush(Color.FromArgb(255, 186, 33, 33)), TokenCategory.Comment: SolidColorBrush(Color.FromArgb(255, 64, 128, 128)), TokenCategory.Error: SolidColorBrush(Color.FromArgb(255, 255, 0, 0)), TokenCategory.None: SolidColorBrush(Color.FromArgb(255, 255, 255, 255)), } default_style = SolidColorBrush(Color.FromArgb(255, 0, 0, 0)) blue = SolidColorBrush(Color.FromArgb(255, 0, 0, 128)) engine = Python.CreateEngine() context = HostingHelpers.GetLanguageContext(engine) def get_prompt(prompt): run = Run() run.Text = prompt run.Foreground = blue return run def get_run(text, foreground): run = Run() run.Text = text if foreground is not None: run.Foreground = foreground return run