def openPythonWindow(self, event=None): """Open Python's Idle debugger in a separate process.""" m = g.import_module('idlelib') if not m: g.trace('can not open idlelib') return idle_path = os.path.dirname(m.__file__) idle = g.os_path_join(idle_path, 'idle.py') args = [sys.executable, idle] if 1: # Use present environment. os.spawnv(os.P_NOWAIT, sys.executable, args) else: # Use a pristine environment. os.spawnve(os.P_NOWAIT, sys.executable, args, os.environ)
pal.setColor(QtGui.QPalette.WindowText, fg) self.UI.label.setPalette(pal) self.UI.label.setText(msg) #@+node:ekr.20140920145803.17993: *3* enableDelete def enableDelete(self, enable): self.UI.deleteBtn.setChecked(False) self.UI.deleteBtn.setEnabled(enable) #@-others #@+node:ekr.20140920145803.17994: ** class backlinkTkUI if g.app.gui.guiName() == "tkinter": Tk = g.import_module('tkinter') class backlinkTkUI: # pylint: disable=no-member # This is old code. #@+others #@+node:ekr.20140920145803.17975: *3* __init__ def __init__(self, owner): '''Ctor for backlinkTkUI class.''' self.owner = owner self.c = c = self.owner.c c.frame.log.createTab('Links', createText=False) w = c.frame.log.frameDict['Links'] f = Tk.Frame(w) scrollbar = Tk.Scrollbar(f, orient=Tk.VERTICAL) self.listbox = Tk.Listbox(f,
- Selecting a headline containing \@clip appends the contents of the clipboard to the end of the body pane. - The double-click-icon-box command on a node whose headline contains \@view *<path-to-file>* places the contents of the file in the body pane. - The double-click-icon-box command on a node whose headline contains \@strip *<path-to-file>* places the contents of the file in the body pane, with all sentinels removed. This plugin also accumulates the effect of all \@path nodes. ''' #@-<< docstring >> from leo.core import leoGlobals as g path = g.import_module('path') win32clipboard = g.import_module('win32clipboard') #@+others #@+node:ekr.20111104210837.9693: ** init def init(): '''Return True if the plugin has loaded successfully.''' ok = path and win32clipboard # Ok for unit testing. if ok: g.registerHandler("after-create-leo-frame", onCreate) elif not g.app.unitTesting: s = 'at_view plugin not loaded: win32Clipboard not present.' g.es_print(s) return ok
def writeToDocutils(self, p, s, ext): """Send s to docutils using the writer implied by ext and return the result.""" if not docutils: g.error('writeToDocutils: docutils not present') return None join = g.os_path_finalize_join openDirectory = self.c.frame.openDirectory overrides = {'output_encoding': self.encoding} # # Compute the args list if the stylesheet path does not exist. styleSheetArgsDict = self.handleMissingStyleSheetArgs(p) if ext == '.pdf': module = g.import_module('leo.plugins.leo_pdf') if not module: return None writer = module.Writer() # Get an instance. writer_name = None else: writer = None for ext2, writer_name in ( ('.html', 'html'), ('.htm', 'html'), ('.tex', 'latex'), ('.pdf', 'leo.plugins.leo_pdf'), ('.s5', 's5'), ('.odt', 'odt'), ): if ext2 == ext: break else: g.error(f"unknown docutils extension: {ext}") return None # # Make the stylesheet path relative to open directory. rel_stylesheet_path = self.stylesheet_path or '' stylesheet_path = join(openDirectory, rel_stylesheet_path) assert self.stylesheet_name path = join(self.stylesheet_path, self.stylesheet_name) if not self.stylesheet_embed: rel_path = join(rel_stylesheet_path, self.stylesheet_name) rel_path = rel_path.replace('\\', '/') overrides['stylesheet'] = rel_path overrides['stylesheet_path'] = None overrides['embed_stylesheet'] = None elif os.path.exists(path): if ext != '.pdf': overrides['stylesheet'] = path overrides['stylesheet_path'] = None elif styleSheetArgsDict: g.es_print('using publish_argv_for_missing_stylesheets', styleSheetArgsDict) overrides.update(styleSheetArgsDict) # MWC add args to settings elif rel_stylesheet_path == stylesheet_path: g.error(f"stylesheet not found: {path}") else: g.error('stylesheet not found\n', path) if self.path: g.es_print('@path:', self.path) g.es_print('open path:', openDirectory) if rel_stylesheet_path: g.es_print('relative path:', rel_stylesheet_path) try: result = None result = docutils.core.publish_string(source=s, reader_name='standalone', parser_name='restructuredtext', writer=writer, writer_name=writer_name, settings_overrides=overrides) if isinstance(result, bytes): result = g.toUnicode(result) except docutils.ApplicationError as error: g.error('Docutils error:') g.blue(error) except Exception: g.es_print('Unexpected docutils exception') g.es_exception() return result