예제 #1
0
def test_message_widget_runs():

    hub = Hub()

    widget = MessageWidget()
    widget.register_to_hub(hub)
    widget.show()

    message = Message('test_message_widget_runs', tag='1234')

    hub.broadcast(message)
예제 #2
0
def test_message_widget_runs():

    hub = Hub()

    widget = MessageWidget()
    widget.register_to_hub(hub)
    widget.show()

    message = Message('test_message_widget_runs', tag='1234')

    hub.broadcast(message)
예제 #3
0
def main():

    app = QApplication(sys.argv)
    win = QMainWindow()

    data = example_data.simple_image()
    dc = DataCollection([data])
    histo_client = HistogramWidget(dc)

    hub = Hub(dc, histo_client)
    win.setCentralWidget(histo_client)
    win.show()
    sys.exit(app.exec_())
예제 #4
0
    def __init__(self, data=None):
        """
        :param data: :class:`~glue.core.data.Data` object, or list of such objects
        """
        super(DataCollection, self).__init__()
        self._link_manager = LinkManager()
        self._data = []

        self.hub = None

        self._subset_groups = []
        self.register_to_hub(Hub())
        self.extend(as_list(data or []))
        self._sg_count = 0
예제 #5
0
    def __init__(self, data=None):
        super(DataCollection, self).__init__()

        self._link_manager = LinkManager(self)
        self._data = []

        self.hub = None

        self._disable_sync_link_manager = 0
        self._subset_groups = []
        self.register_to_hub(Hub())
        self.extend(as_list(data or []))
        self._sg_count = 0

        self._link_manager.register_to_hub(self.hub)
예제 #6
0
class MyClient(HubListener):
    def register_to_hub(self, hub):
        """ Sign up to receive DataMessages from the hub """
        hub.subscribe(self,                     # subscribing object
                      DataMessage, # message type to subscribe to
                      handler = self.receive_message) # method to call


    def receive_message(self, message):
        """ Receives each DataMessage relay """
        print "    MyClient received a message \n"


# create objects
hub = Hub()
client = MyClient()
data = Data()
subset = data.new_subset()
data_collection = DataCollection()

# connect them to each other
data_collection.append(data)
data_collection.register_to_hub(hub)
client.register_to_hub(hub)

# manually send a DataMessage. Relayed to MyClient
print 'Manually sending DataMessage'
message = DataMessage(data)
hub.broadcast(message)