def pythonTargetCommandSet(name, commands):
	commandSet = CommandSet( name, commands )
	pythonTargetCommands.registerCommandSet( commandSet )
	return commandSet
Exemplo n.º 2
0
	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 )


	@property
	def documentSubject(self):
def worksheetCommandSet(name, commands):
    commandSet = CommandSet(name, commands)
    worksheetCommands.registerCommandSet(commandSet)
    return commandSet
@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 ) )

pythonCommandSet( 'LarchTools.PythonTools.TraceVis', [ _tvCommand ] )
Exemplo n.º 5
0
        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


_WorksheetEditorPathEntry.instance = _WorksheetEditorPathEntry()
Exemplo n.º 6
0
                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))


_psCommand = Command(
    '&Python &S&tepper',
    chainActions(_newStepperAtStatementRange, _newStepperAtCaret))
Exemplo n.º 7
0
def inlineTestCommandSet(name, commands):
	commandSet = CommandSet( name, commands )
	inlineTestCommands.registerCommandSet( commandSet )
	return commandSet