def handleSaveDocumentAsFn(filename): document.saveAs( filename ) DocumentManagement.promptSaveDocumentAs( subject.world, None, handleSaveDocumentAsFn, document.getFilename() ) def _reset(subject, pageController): document = subject._document modules = document.unloadAllImportedModules() print 'LarchCore.Project.ProjectEditor.Subject: unloaded modules:' for module in modules: print '\t' + module _saveCommand = Command( CommandName( '&Save' ), _save, Shortcut( 'S', Modifier.CTRL ) ) _saveAsCommand = Command( CommandName( '&Save &as' ), _saveAs ) _resetCommand = Command( CommandName( 'R&eset' ), _reset, Shortcut( 'E', Modifier.CTRL ) ) _projectCommands = CommandSet( 'LarchCore.Project', [ _saveCommand, _saveAsCommand, _resetCommand ] ) class ProjectSubject (Subject): def __init__(self, document, model, enclosingSubject, path, importName, title): super( ProjectSubject, self ).__init__( enclosingSubject, path ) self._document = document self._model = model self._title = title packageFinder = PackageFinder( self, model ) self._rootFinder = RootFinder( self, model.pythonPackageName, packageFinder )
from LarchTools.EmbeddedData.BoolEditorCheckbox import BoolEditorCheckbox from LarchTools.EmbeddedData.IntEditorSpinEntry import IntEditorSpinEntry from LarchTools.EmbeddedData.RealEditorSpinEntry import RealEditorSpinEntry from LarchTools.EmbeddedData.StringEditorTextEntry import StringEditorTextEntry from LarchTools.EmbeddedData.StringEditorTextArea import StringEditorTextArea from LarchTools.EmbeddedData.ColourEditorPicker import ColourEditorPicker from LarchTools.EmbeddedData.PathEditorTextEntry import FilePathEditorTextEntry, DirPathEditorTextEntry @EmbeddedExpressionAtCaretAction def _newBoolCheckboxAtCaret(caret): return BoolEditorCheckbox() _boolCheckCommand = Command('&Boolean &Checkbox', _newBoolCheckboxAtCaret) @EmbeddedExpressionAtCaretAction def _newIntSpinEntryAtCaret(caret): return IntEditorSpinEntry() _intSpinCommand = Command('&Integer &Spin &Entry', _newIntSpinEntryAtCaret) @EmbeddedExpressionAtCaretAction def _newRealSpinEntryAtCaret(caret): return RealEditorSpinEntry()
self._incr.onAccess() #exprPres = pyPerspective.applyTo( self._expr ) exprPres = self._expr valuesPres = ObjectBox( 'Values', Column([Paragraph([value]) for value in self._values])) contents = Column([exprPres, valuesPres]) return ObjectBox( 'Embedded display', contents).withContextMenuInteractor(_embeddedDisplayMenu) @EmbeddedExpressionAtCaretAction def _newEmbeddedDisplayAtCaret(caret): return EmbeddedDisplay() @WrapSelectionInEmbeddedExpressionAction def _newEmbeddedDisplayAtSelection(expr, selection): d = EmbeddedDisplay() d._expr.model['expr'] = deepcopy(expr) return d _edCommand = Command( '&Embedded &Display', chainActions(_newEmbeddedDisplayAtSelection, _newEmbeddedDisplayAtCaret)) pythonCommandSet('LarchTools.PythonTools.EmbeddedDisplay', [_edCommand])
worksheet = self._model body = worksheet['body'] for i, node in enumerate(body['contents']): if node.isInstanceOf(Schema.PythonCode): code = compileForModuleExecution(mod, node['code'], fullname + '_' + str(i)) exec code in mod.__dict__ return mod def _refreshWorksheet(subject, pageController): subject._modelView.refreshResults() _refreshCommand = Command(CommandName('&Refresh worksheet'), _refreshWorksheet, Shortcut(KeyEvent.VK_ENTER, Modifier.CTRL)) _worksheetViewerCommands = CommandSet('LarchCore.Worksheet.Viewer', [_refreshCommand]) class _WorksheetEditorPathEntry(SubjectPathEntry): def follow(self, outerSubject): return outerSubject.editSubject def __getstate__(self): return False def __setstate__(self): pass
@EmbeddedExpressionAtCaretAction def _newMonitoredExpressionAtCaret(caret): return MonitoredExpression() @WrapSelectionInEmbeddedExpressionAction def _newMonitoredExpressionAtSelection(expr, selection): d = MonitoredExpression() d._expr.model['expr'] = deepcopy( expr ) if expr.isInstanceOf( Schema.Load ): d._name = expr['name'] return d _mxCommand = Command( '&Monitored E&xpression', chainActions( _newMonitoredExpressionAtSelection, _newMonitoredExpressionAtCaret ) ) _mxCommands = CommandSet( 'LarchTools.PythonTools.EmbeddedDisplay.MonitoredExpression', [ _mxCommand ] ) @WrapSelectedStatementRangeInEmbeddedObjectAction def _newTraceVisAtStatementRange(statements, selection): d = TraceVisualisation() d._suite.model['suite'][:] = deepcopy( statements ) return d _tvCommand = Command( '&Trace &Visualisation', chainActions( _newTraceVisAtStatementRange ) )
s = self.asString() return Py.strToStrLiteral(s) def __clipboard_copy__(self, memo): return VisualPythonRegex(memo.copy(self.regex)) def asString(self): return self._codeGen(self.regex) __embed_hide_frame__ = True def __present__(self, fragment, inherited_state): #return VREPerspective( self.regex ) e = Paragraph([ HiddenText(u'\ue000'), VREPerspective(self.regex), HiddenText(u'\ue000') ]) e = _vreBorder.surround(e) return e @EmbeddedExpressionAtCaretAction def _newVREAtCaret(caret): return VisualPythonRegex() _vreCommand = Command('&Visual &Regular &Expression', _newVREAtCaret) pythonCommandSet('LarchTools.PythonTools.VisualRegex', [_vreCommand])
assign = Py.AssignStmt(targets=[target], value=value) assigns.append(assign) return Py.PythonSuite(suite=assigns) __py_hide_expansion__ = True def __present__(self, fragment, inheritedState): return _tableEditor.editTable(self) @TrackedListProperty def _definitions(self): return self._definitions_ _targetColumn = AttributeColumn('Name', 'target', EmbeddedPython2Target) _valueColumn = AttributeColumn('Value', 'value', EmbeddedPython2Expr) _tableEditor = ObjectListTableEditor([_targetColumn, _valueColumn], ConstantDefinition, False, True, True, True) @EmbeddedStatementAtCaretAction def _newConstantTableAtCaret(caret): return ConstantTable() _ctCommand = Command('&Python &Constant &Table', _newConstantTableAtCaret) pythonCommandSet('LarchTools.PythonTools.ConstantTable', [_ctCommand])
SimpleInlineTableTestRow._codeColumn = AttributeColumn( 'Code', 'code', EmbeddedPython2Suite ) class SimpleInlineTableTest (AbstractInlineTestTable): pass SimpleInlineTableTest._tableEditor = ObjectListTableEditor( [ SimpleInlineTableTestRow._resultColumn, SimpleInlineTableTestRow._codeColumn, SimpleInlineTableTestRow._expectedColumn ], SimpleInlineTableTestRow, True, True, True, True ) # # Commands for inserting standard tests # @EmbeddedStatementAtCaretAction def _newSimpleInlineTableTestAtCaret(caret): return SimpleInlineTableTest() _sittCommand = Command( '&Simple &Inline &Table &Test', chainActions( _newSimpleInlineTableTestAtCaret ) ) inlineTestCommandSet( 'LarchTools.PythonTools.InlineTest.TableTests', [ _sittCommand ] )
header = _headerStyle( Row([ title.alignVCentre().alignHPack(), Pres.coerce(self._stepButton).alignHPack(), Pres.coerce(self._runButton).alignHPack() ])).alignHExpand() main = Column([header, Pres.coerce(self._code).alignHExpand()]) return _stepperBorder.surround(main).withCommands(_stepperCommands) @EmbeddedStatementAtCaretAction def _newBreakPointAtCaret(caret): return StepperBreakpoint() _bpCommand = Command('&Stepper &Break&point', _newBreakPointAtCaret) _stepperCommands = CommandSet( 'LarchTools.PythonTools.Stepper.StepperBreakpoint', [_bpCommand]) @EmbeddedStatementAtCaretAction def _newStepperAtCaret(caret): return Stepper() @WrapSelectedStatementRangeInEmbeddedObjectAction def _newStepperAtStatementRange(statements, selection): return Stepper(deepcopy(statements))
commandSet = CommandSet( name, commands ) inlineTestCommands.registerCommandSet( commandSet ) return commandSet # # Commands for inserting standard tests # @EmbeddedStatementAtCaretAction def _newStandardInlineTestAtCaret(caret): return StandardInlineTest() _sitCommand = Command( '&Standard &Inline &Test', chainActions( _newStandardInlineTestAtCaret ) ) inlineTestCommandSet( 'LarchTools.PythonTools.InlineTest.StandardTests', [ _sitCommand ] ) @EmbeddedStatementAtCaretAction def _newTestedBlockAtCaret(caret): return TestedBlock() @WrapSelectedStatementRangeInEmbeddedObjectAction def _newTestedBlockAtStatementRange(statements, selection): d = TestedBlock() d._suite.model['suite'][:] = deepcopy( statements ) return d
return [self.__root] def __clipboard_copy__(self, memo): instance = GUIEditor.__new__(GUIEditor) instance.__change_history__ = None instance.__root = memo.copy(self.__root) instance.__root._guiEditor = self return instance def __py_evalmodel__(self, codeGen): return self.__root.__py_evalmodel__(codeGen) __embed_hide_frame__ = True def __present__(self, fragment, inheritedState): p = Pres.coerce(self.__root) p = _guiEditorBorder.surround(p) p = p.withContextMenuInteractor(guiEditorContextMenu) p = p.withProperty(GUIEdProp.instance, self) return p @EmbeddedExpressionAtCaretAction def _newGUIEditorAtCaret(caret): return GUIEditor(None) _vreCommand = Command('&G&U&I Editor', _newGUIEditorAtCaret) pythonCommandSet('LarchTools.PythonTools.GUIEditor', [_vreCommand])
@WrapSelectionInEmbeddedExpressionAction def _newLiterateExpressionAtSelection(expr, selection): d = LiterateExpression() d._expr.model['expr'] = deepcopy(expr) return d @EmbeddedStatementAtCaretAction def _newLiterateSuiteAtCaret(caret): return LiterateSuite() @WrapSelectedStatementRangeInEmbeddedObjectAction def _newLiterateSuiteAtStatementRange(statements, selection): d = LiterateSuite() d._definition._suite.model['suite'][:] = deepcopy(statements) return d _lxCommand = Command( '&Literate E&xpression', chainActions(_newLiterateExpressionAtSelection, _newLiterateExpressionAtCaret)) _lsCommand = Command( '&Literate &Suite', chainActions(_newLiterateSuiteAtStatementRange, _newLiterateSuiteAtCaret)) pythonCommandSet('LarchTools.PythonTools.Literate', [_lxCommand, _lsCommand])