Beispiel #1
0
class ConsoleNode(Node):
    """Node providing a console for showing results and debugging

	Input terminals:
	- title: the title of current results. Title won't be printed until it is changed
	- added inputs: item to be print in the console
	"""

    nodeName = 'Console'
    nodePaths = [('Debug', )]

    def __init__(self, name):
        super().__init__(name,
                         terminals={'title': {
                             'io': 'in'
                         }},
                         allowAddInput=True)
        self.console = ConsoleWidget()
        self.title = None

    def process(self, title, display=True, **kwargs):
        if title is not None:
            if self.title != title:
                self.console.write('<b>%s</b><br>' % title, html=True)
                self.title = title
        for k, v in sorted(kwargs.items()):
            if v is None:
                continue
            self.console.locals()[k + '_'] = v
            self.console.write('%s: %s\n' % (k, v))
        self.console.write('\n')

    def widget(self):
        return self.console

    def saveState(self):
        state = super().saveState()
        state['geometry'] = self.subwin.geometry()
        return state

    def restoreState(self, state):
        super().restoreState(state)
        self.subwin.setGeometry(state['geometry'])
Beispiel #2
0
class ConsoleNode(Node):
	"""Node providing a console for showing results and debugging

	Input terminals:
	- title: the title of current results. Title won't be printed until it is changed
	- added inputs: item to be print in the console
	"""

	nodeName = 'Console'
	nodePaths = [('Debug',)]

	def __init__(self, name):
		super().__init__(name, terminals={'title':{'io':'in'}}, allowAddInput=True)
		self.console = ConsoleWidget()
		self.title = None

	def process(self, title, display=True, **kwargs):
		if title is not None:
			if self.title != title:
				self.console.write('<b>%s</b><br>' % title, html=True)
				self.title = title
		for k, v in sorted(kwargs.items()):
			if v is None:
				continue
			self.console.locals()[k+'_'] = v
			self.console.write('%s: %s\n' % (k, v))
		self.console.write('\n')

	def widget(self):
		return self.console

	def saveState(self):
		state = super().saveState()
		state['geometry'] = self.subwin.geometry()
		return state

	def restoreState(self, state):
		super().restoreState(state)
		self.subwin.setGeometry(state['geometry'])