Skip to content
This repository has been archived by the owner on Mar 29, 2024. It is now read-only.

Towards pure python interactors: registering observable #1

Open
renoust opened this issue Jun 23, 2016 · 0 comments
Open

Towards pure python interactors: registering observable #1

renoust opened this issue Jun 23, 2016 · 0 comments

Comments

@renoust
Copy link

renoust commented Jun 23, 2016

We'll need to fasten the development of interaction through pure python Tulip.
It is currently possible through the python script view to create pseudo interactors. They are observable classes waiting for events, here is a dummy example we worked on with @guywiz :

from tulip import *
import random
import time
class Interactor(tlp.Observable):
    """docstring for Interactor"""
    def __init__(self, graph):
        super(tlp.Observable, self).__init__()
        self.graph = graph

    def treatEvent(self, event):
        if event.getType() == tlp.GraphEvent.TLP_ADD_NODE:
            print 'Add node event'
            node = event.getNode()
            self.graph.getBooleanProperty('viewSelection')[node] = True
            self.changeNodeColor()

    def changeNodeColor(self):
        c = tlp.Color(random.randint(0,255), random.randint(0,255), random.randint(0,255))
        self.graph.getColorProperty('viewColor').setAllNodeValue(c)
        updateVisualization()

def main(graph):

    inter = Interactor(graph)
    graph.addListener(inter)

    while(True):
        time.sleep(.1)

This interactor, when a node is added to the graph, automatically selects the node and changes randomly the color of all nodes.

Note that this doesn't work if we register it with graph.addObserver(inter)

Tulip already allows the development of plugins, and to register them automatically through the development perspective. I think we can provide a mechanism to register (and unregister) Observables they would be a special class of plugins, with the automatic management of the loop, and the check function would fit perfectly that purpose.

bpinaud referenced this issue Jan 29, 2019
TravisCI: Migrate Linux builds from trusty to xenial
p-mary referenced this issue Mar 12, 2019
…bProcessEngineProcess is still running after a geographic has been created, so force an exit call
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant