コード例 #1
0
 def __init__(self, event_id=1000, name="", data=None):
     '''after id 1000 starts custom_user_event'''
     self.idType = QEvent.registerEventType(event_id)
     self.name = name
     self.data = data
     QEvent.__init__(self, self.idType)
     print("Created CustomEvent with id: ", self.idType)
コード例 #2
0
ファイル: articletag.py プロジェクト: asgrom/Pocket
 def __init__(self, tag: str):
     """
     Args:
         tag (str): Тег статьи.
     """
     # noinspection PyTypeChecker
     QEvent.__init__(self, DeleteArticleTagEvent.idType)
     self.tag = tag
コード例 #3
0
ファイル: settings.py プロジェクト: oasys-kit/orange-canvas
 def __init__(self, etype, key, value=None, oldValue=None):
     """
     Initialize the event instance
     """
     QEvent.__init__(self, etype)
     self.__key = key
     self.__value = value
     self.__oldValue = oldValue
コード例 #4
0
ファイル: outputview.py プロジェクト: oasys-kit/orange-canvas
 def __init__(self, function, args, kwargs, semaphore=None):
     QEvent.__init__(self, QueuedCallEvent.QueuedCall)
     self.function = function
     self.args = args
     self.kwargs = kwargs
     self.semaphore = semaphore
     self._result = None
     self._exc_info = None
     self._state = 0
コード例 #5
0
 def __init__(self, queue, exceptions_in_main, fn, *args, **kwargs):
     QEvent.__init__(self, self.EVENT_TYPE)
     self.fn = fn
     self.args = args
     self.kwargs = kwargs
     self._returnval = queue
     # Whether to raise exceptions in the main thread or store them
     # for raising in the calling thread:
     self._exceptions_in_main = exceptions_in_main
コード例 #6
0
ファイル: utils.py プロジェクト: perlboy/luckyLUKS
 def __init__(self, callback, response):
     """ A WorkerEvent encapsulates a function to be called in the main ui loop and its argument
         :param callback: The function to be called when the event gets processed
         :type callback: function
         :param response: Response message from the worker, passed as argument to the callback function
         :type response: str
     """
     QEvent.__init__(self, WorkerEvent.EVENT_TYPE)
     self.callback = callback
     self.response = response
コード例 #7
0
ファイル: utils.py プロジェクト: jas-per/luckyLUKS
 def __init__(self, callback, response):
     """ A WorkerEvent encapsulates a function to be called in the main ui loop and its argument
         :param callback: The function to be called when the event gets processed
         :type callback: function
         :param response: Response message from the worker, passed as argument to the callback function
         :type response: str
     """
     QEvent.__init__(self, WorkerEvent.EVENT_TYPE)
     self.callback = callback
     self.response = response
コード例 #8
0
    def processEvents(self):
        # Process incoming data, and send to sim
        while self.connection.poll():
            (eventtype, event) = self.connection.recv()
            if eventtype == SetNodeIdType:
                self.nodeid = event
            elif eventtype == SetActiveNodeType:
                self.active = event
            else:
                # Data over pipes is pickled/unpickled, this causes problems with
                # inherited classes. Solution is to call the ancestor's init
                QEvent.__init__(event, eventtype)
                self.sim.event(event)

        # Process timers
        Timer.updateTimers()
コード例 #9
0
ファイル: nodemanager.py プロジェクト: MAPTra/bluesky
    def processEvents(self):
        # Process incoming data, and send to sim
        while self.connection.poll():
            (eventtype, event) = self.connection.recv()
            if eventtype == SetNodeIdType:
                self.nodeid = event
            elif eventtype == SetActiveNodeType:
                self.active = event
            else:
                # Data over pipes is pickled/unpickled, this causes problems with
                # inherited classes. Solution is to call the ancestor's init
                QEvent.__init__(event, eventtype)
                self.sim.event(event)

        # Process timers
        Timer.updateTimers()
コード例 #10
0
 def __init__(self, id, data=None, *args):
     # Invoke parent init
     QEvent.__init__(self, id)
     self.data = data
     self.id = id
コード例 #11
0
 def __init__(self, error, data):
     QEvent.__init__(self, self.TYPE)
     self.error = error
     self.data = data
コード例 #12
0
 def __init__(self):
     QEvent.__init__(self, 2001)
     self.registerEventType(self.event_type)
コード例 #13
0
ファイル: signal.py プロジェクト: vasconl/linux-show-player
 def __init__(self, reference, *args, **kwargs):
     QEvent.__init__(self, QSlotEvent.EVENT_TYPE)
     self.reference = reference
     self.args = args
     self.kwargs = kwargs
コード例 #14
0
ファイル: webenginepage.py プロジェクト: asgrom/flibusta_prj
 def __init__(self, data):
     QEvent.__init__(self, MyEvent.idType)
     self.data = data
コード例 #15
0
 def __init__(self, _, event):
     QEvent.__init__(self, _)
     self.event = event
コード例 #16
0
ファイル: debugging.py プロジェクト: BlenderCN-Org/hive2_gui
    def __init__(self, func, *args, **kwargs):
        QEvent.__init__(self, self.EVENT_TYPE)

        self.func = func
        self.args = args
        self.kwargs = kwargs
コード例 #17
0
 def __init__(self, point):
     QEvent.__init__(self, ReleasePosEvent.EventType)
     self.point = point
コード例 #18
0
    def receiveFromNodes(self):
        # Only look for incoming data if we're not quitting
        if self.stopping:
            return

        # First look for new connections
        r, w, e = select.select((self.listener, ), (), (), 0)
        if self.listener in r:
            conn = self.listener.accept()
            address = self.listener.last_accepted[0]
            if address in self.hosts:
                nodeid = self.hosts[address]
            else:
                nodeid = (len(self.hosts), 0)
            # Store host number and its number of nodes
            self.hosts[address] = (nodeid[0], nodeid[1] + 1)
            # Send the node information about its nodeid
            connidx = len(self.connections)
            conn.send((SetNodeIdType, nodeid))
            self.connections.append([conn, nodeid, 0])
            self.nodes_changed.emit(address, nodeid, connidx)
            self.setActiveNode(connidx)

        # Then process any data in the active connections
        for idx, conn in enumerate(self.connections):
            if conn[0] is None or conn[0].closed:
                continue

            # Check for incoming events with poll
            while conn[0].poll():
                # Receive events that are waiting in the conn
                try:
                    (eventtype, event) = conn[0].recv()
                except:
                    continue

                # Sender id is connection index and node id
                self.sender_id = (idx, conn[1])

                if eventtype == AddNodeType:
                    # This event only consists of an int: the number of nodes to add
                    for i in range(event):
                        self.addNode()
                    continue
                # Data over connections is pickled/unpickled, this causes problems with
                # inherited classes. Solution is to call the ancestor's init
                QEvent.__init__(event, eventtype)

                # First check if this event is meant for the manager
                if event.type() == SimStateEventType:
                    # Save the state together with the connection object
                    conn[2] = event.state
                    if event.state == event.end:
                        # Quit the main loop. Afterwards, manager will also quit
                        qapp.instance().quit()

                    elif event.state == event.init or event.state == event.hold:
                        if len(self.scenarios) > 0:
                            self.sendScenario(conn)

                elif event.type() == BatchEventType:
                    self.scenarios = [scen for scen in split_scenarios(event.scentime, event.scencmd)]
                    # Check if the batch list contains scenarios
                    if len(self.scenarios) == 0:
                        qapp.sendEvent(qapp.instance(), StackTextEvent(disptext='No scenarios defined in batch file!'))

                    else:
                        qapp.sendEvent(qapp.instance(), StackTextEvent(disptext='Found %d scenarios in batch' % len(self.scenarios)))
                        # Available nodes (nodes that are in init or hold mode):
                        av_nodes = [n for n, conn in enumerate(self.connections) if conn[2] in [0, 2]]
                        for i in range(min(len(av_nodes), len(self.scenarios))):
                            self.sendScenario(self.connections[i])
                        # If there are still scenarios left, determine and start the required number of local nodes
                        reqd_nnodes = min(len(self.scenarios), max(0, self.max_nnodes - len(self.localnodes)))
                        for n in range(reqd_nnodes):
                            self.addNode()

                elif event.type() == StackTextEventType:
                    self.telnet_in.sendReply(event)

                    if not event.disptext == MSG_OK:
                        qapp.sendEvent(qapp.instance(), event)

                else:
                    # The event is meant for the gui
                    qapp.sendEvent(qapp.instance(), event)

        # To avoid giving wrong information with sender() when it is called outside
        # of this function, set sender_id to None
        self.sender_id = None
コード例 #19
0
 def __init__(self, callback):
     # Thread-safe
     QEvent.__init__(self, _Event.EVENT_TYPE)
     self.callback = callback
コード例 #20
0
ファイル: signal.py プロジェクト: chippey/linux-show-player
 def __init__(self, reference, *args, **kwargs):
     QEvent.__init__(self, QSlotEvent.EVENT_TYPE)
     self.reference = reference
     self.args = args
     self.kwargs = kwargs
コード例 #21
0
ファイル: _Event.py プロジェクト: sysdeep/DNote
 def __init__(self, data):
     #thread-safe
     QEvent.__init__(self, Event.EVENT_TYPE)
     self.data = data
コード例 #22
0
ファイル: Qtboard.py プロジェクト: AlexMateva/Splendor
 def __init__(self, data):
     QEvent.__init__(self, NotifyParent.idType)
     self.data = data
コード例 #23
0
 def __init__(self, func, *args):
     QEvent.__init__(self, self.EventType)
     if len(args) > 0:
         self.thunk = partial(func, *args)
     else:
         self.thunk = func
コード例 #24
0
ファイル: thread.py プロジェクト: Sophist-UK/Sophist_picard
 def __init__(self, func, *args, **kwargs):
     QEvent.__init__(self, QEvent.User)
     self.func = func
     self.args = args
     self.kwargs = kwargs
コード例 #25
0
ファイル: mainmanager.py プロジェクト: ThomL/bluesky
    def receiveFromNodes(self):
        # Only look for incoming data if we're not quitting
        if self.stopping:
            return

        # First look for new connections
        r, w, e = select.select((self.listener, ), (), (), 0)
        if self.listener in r:
            conn = self.listener.accept()
            address = self.listener.last_accepted[0]
            if address in self.hosts:
                nodeid = self.hosts[address]
            else:
                nodeid = (len(self.hosts), 0)
            # Store host number and its number of nodes
            self.hosts[address] = (nodeid[0], nodeid[1] + 1)
            # Send the node information about its nodeid
            connidx = len(self.connections)
            conn.send((SetNodeIdType, nodeid))
            self.connections.append([conn, nodeid, 0])
            self.nodes_changed.emit(address, nodeid, connidx)
            self.setActiveNode(connidx)

        # Then process any data in the active connections
        for connidx in range(len(self.connections)):
            conn = self.connections[connidx]
            if conn[0] is None or conn[0].closed:
                continue

            # Check for incoming events with poll
            while conn[0].poll():
                # Receive events that are waiting in the conn
                try:
                    (eventtype, event) = conn[0].recv()
                except:
                    continue

                # Sender id is connection index and node id
                self.sender_id = (connidx, conn[1])

                if eventtype == AddNodeType:
                    # This event only consists of an int: the number of nodes to add
                    for i in range(event):
                        self.addNode()
                    continue
                # Data over connections is pickled/unpickled, this causes problems with
                # inherited classes. Solution is to call the ancestor's init
                QEvent.__init__(event, eventtype)

                # First check if this event is meant for the manager
                if event.type() == SimStateEventType:
                    # Save the state together with the connection object
                    conn[2] = event.state
                    if event.state == event.end:
                        # Quit the main loop. Afterwards, manager will also quit
                        qapp.instance().quit()

                    elif event.state == event.init or event.state == event.hold:
                        if len(self.scenarios) > 0:
                            self.sendScenario(conn)

                elif event.type() == BatchEventType:
                    self.scenarios = [scen for scen in split_scenarios(event.scentime, event.scencmd)]
                    # Check if the batch list contains scenarios
                    if len(self.scenarios) == 0:
                        qapp.sendEvent(qapp.instance(), StackTextEvent(disptext='No scenarios defined in batch file!'))

                    else:
                        qapp.sendEvent(qapp.instance(), StackTextEvent(disptext='Found %d scenarios in batch' % len(self.scenarios)))
                        # Available nodes (nodes that are in init or hold mode):
                        av_nodes = [n for n in range(len(self.connections)) if self.connections[n][2] in [0, 2]]
                        for i in range(min(len(av_nodes), len(self.scenarios))):
                            self.sendScenario(self.connections[i])
                        # If there are still scenarios left, determine and start the required number of local nodes
                        reqd_nnodes = min(len(self.scenarios), max(0, self.max_nnodes - len(self.localnodes)))
                        for n in range(reqd_nnodes):
                            self.addNode()

                else:
                    # The event is meant for the gui
                    qapp.sendEvent(qapp.instance(), event)

        # To avoid giving wrong information with sender() when it is called outside
        # of this function, set sender_id to None
        self.sender_id = None
コード例 #26
0
 def __init__(self, initstate):
     QEvent.__init__(self, WidgetManager.WidgetInitEvent.DelayedInit)
     self._initstate = initstate
コード例 #27
0
 def __init__(self, id, data=None, *args):
     # Invoke parent init
     QEvent.__init__(self, id)
     self.data = data
     self.id = id
コード例 #28
0
ファイル: events.py プロジェクト: oasys-kit/orange-canvas
 def __init__(self, etype):
     QEvent.__init__(self, etype)
コード例 #29
0
ファイル: thread.py プロジェクト: rjshaver/picard
 def __init__(self, func, *args, **kwargs):
     QEvent.__init__(self, QEvent.User)
     self.func = func
     self.args = args
     self.kwargs = kwargs
コード例 #30
0
ファイル: thunkEvent.py プロジェクト: DerThorsten/ilastik
 def __init__(self, func, *args):
     QEvent.__init__(self, self.EventType)
     if len(args) > 0:
         self.thunk = partial(func, *args)
     else:
         self.thunk = func