def mousePressEvent(self, event): anchor_item = self.scene.item_at(event.scenePos(), items.NodeAnchorItem, buttons=Qt.LeftButton) if anchor_item and event.button() == Qt.LeftButton: # Start a new link starting at item self.from_item = anchor_item.parentNodeItem() if isinstance(anchor_item, items.SourceAnchorItem): self.direction = NewLinkAction.FROM_SOURCE self.source_item = self.from_item else: self.direction = NewLinkAction.FROM_SINK self.sink_item = self.from_item event.accept() helpevent = QuickHelpTipEvent( self.tr("Create a new link"), self.tr('<h3>Create new link</h3>' '<p>Drag a link to an existing node or release on ' 'an empty spot to create a new node.</p>' # '<a href="help://orange-canvas/create-new-links">' # 'More ...</a>' ) ) QCoreApplication.postEvent(self.document, helpevent) return True else: # Whoever put us in charge did not know what he was doing. self.cancel(self.ErrorReason) return False
def showssd(self, param): if param == 'ALL' or param == 'OFF': qapp.postEvent(qapp.instance(), DisplayFlagEvent('SSD', param)) else: idx = self.sim.traf.id2idx(param) if idx >= 0: qapp.postEvent(qapp.instance(), DisplayFlagEvent('SSD', idx))
def showssd(self, param): if param == "ALL" or param == "OFF": qapp.postEvent(qapp.instance(), DisplayFlagEvent("SSD", param)) else: idx = self.sim.traf.id2idx(param) if idx >= 0: qapp.postEvent(qapp.instance(), DisplayFlagEvent("SSD", idx))
def end(self): self.cleanup() # Remove the help tip set in mousePressEvent self.macro = None helpevent = QuickHelpTipEvent("", "") QCoreApplication.postEvent(self.document, helpevent) UserInteraction.end(self)
def scrollPage(self, degrees=180, afterScroll=None): # do 180 degree scroll down event = QWheelEvent(QCursor.pos(), -1 * (degrees / 15) * 120, Qt.MouseButtons(), Qt.KeyboardModifiers(), Qt.Vertical) QCoreApplication.postEvent(self, event) if afterScroll: afterScroll(self)
def mousePressEvent(self, event): anchor_item = self.scene.item_at(event.scenePos(), items.NodeAnchorItem, buttons=Qt.LeftButton) if anchor_item and event.button() == Qt.LeftButton: # Start a new link starting at item self.from_item = anchor_item.parentNodeItem() if isinstance(anchor_item, items.SourceAnchorItem): self.direction = NewLinkAction.FROM_SOURCE self.source_item = self.from_item else: self.direction = NewLinkAction.FROM_SINK self.sink_item = self.from_item event.accept() helpevent = QuickHelpTipEvent( self.tr("Create a new link"), self. tr('<h3>Create new link</h3>' '<p>Drag a link to an existing node or release on ' 'an empty spot to create a new node.</p>' # '<a href="help://orange-canvas/create-new-links">' # 'More ...</a>' )) QCoreApplication.postEvent(self.document, helpevent) return True else: # Whoever put us in charge did not know what he was doing. self.cancel(self.ErrorReason) return False
def pan(self, pan, absolute=False): if absolute: self.ctrlat = pan[0] self.ctrlon = pan[1] else: self.ctrlat += pan[0] self.ctrlon += pan[1] qapp.postEvent(qapp.instance(), PanZoomEvent(pan=pan, absolute=absolute))
def down(x, y): event = QMouseEvent( QEvent.MouseButtonPress, QPoint(x, y), QPoint(x, y), Qt.LeftButton, Qt.LeftButton, Qt.NoModifier ) QCoreApplication.postEvent(desktop, event)
def up(x, y): event = QMouseEvent( QEvent.MouseButtonRelease, QPoint(x, y), QPoint(x, y), Qt.LeftButton, Qt.LeftButton, Qt.NoModifier ) QCoreApplication.postEvent(desktop, event)
def _stateChanged(self, future, state): """ The `future` state has changed (called by :class:`Future`). """ ev = StateChangedEvent(state) if self.thread() is QThread.currentThread(): QCoreApplication.sendEvent(self, ev) else: QCoreApplication.postEvent(self, ev)
def update(self): painter = QPainter(self)#CApplication.getTelaPrincipal()) painter.translate(self.getPos()) self.paint(painter) painter.end() if not CApplication.updateRequested(): CApplication.setUpdateRequested(True) QCoreApplication.postEvent(CApplication.getInstance(), EventoUpdateConsole(EventoUpdateConsole.UpdateRequest)) return
def end(self): self.down_pos = None self.arrow_item = None self.annotation = None self.document.view().setCursor(Qt.ArrowCursor) # Clear the help tip helpevent = QuickHelpTipEvent("", "") QCoreApplication.postEvent(self.document, helpevent) UserInteraction.end(self)
def send_aircraft_data(self): data = ACDataEvent() data.id = list(self.sim.traf.id) data.lat = np.array(self.sim.traf.lat, dtype=np.float32, copy=True) data.lon = np.array(self.sim.traf.lon, dtype=np.float32, copy=True) data.alt = np.array(self.sim.traf.alt, dtype=np.float32, copy=True) data.tas = np.array(self.sim.traf.tas, dtype=np.float32, copy=True) data.iconf = np.array(self.sim.traf.iconf, copy=True) data.confcpalat = np.array(self.sim.traf.dbconf.latowncpa, copy=True) data.confcpalon = np.array(self.sim.traf.dbconf.lonowncpa, copy=True) data.trk = np.array(self.sim.traf.trk, dtype=np.float32, copy=True) qapp.postEvent(qapp.instance(), data)
def showroute(self, acid): data = RouteDataEvent() data.acidx = self.sim.traf.id2idx(acid) if data.acidx >= 0: route = self.sim.traf.route[data.acidx] n_segments = len(route.wplat) + 1 data.lat = np.empty(n_segments, dtype=np.float32) data.lat[0] = self.sim.traf.lat[data.acidx] data.lat[1:] = route.wplat data.lon = np.empty(n_segments, dtype=np.float32) data.lon[0] = self.sim.traf.lon[data.acidx] data.lon[1:] = route.wplon qapp.postEvent(qapp.instance(), data)
def delay_method_call(self, *args, **kwargs): if self.thread() != QThread.currentThread(): semaphore = QSemaphore() else: semaphore = None event = QueuedCallEvent(method, (self, ) + args, kwargs, semaphore) QCoreApplication.postEvent(self, event) if semaphore is None: QCoreApplication.sendPostedEvents() else: # Wait until the other thread's event loop processes the event semaphore.acquire() return event.result()
def delay_method_call(self, *args, **kwargs): if self.thread() != QThread.currentThread(): semaphore = QSemaphore() else: semaphore = None event = QueuedCallEvent(method, (self,) + args, kwargs, semaphore) QCoreApplication.postEvent(self, event) if semaphore is None: QCoreApplication.sendPostedEvents() else: # Wait until the other thread's event loop processes the event semaphore.acquire() return event.result()
def start(self): self.document.view().setCursor(Qt.CrossCursor) helpevent = QuickHelpTipEvent( self.tr("Click and drag to create a new arrow"), self. tr('<h3>New arrow annotation</h3>' '<p>Click and drag to create a new arrow annotation</p>' # '<a href="help://orange-canvas/arrow-annotations>' # 'More ...</a>' )) QCoreApplication.postEvent(self.document, helpevent) UserInteraction.start(self)
def start(self): self.document.view().setCursor(Qt.CrossCursor) helpevent = QuickHelpTipEvent( self.tr("Click and drag to create a new arrow"), self.tr('<h3>New arrow annotation</h3>' '<p>Click and drag to create a new arrow annotation</p>' # '<a href="help://orange-canvas/arrow-annotations>' # 'More ...</a>' ) ) QCoreApplication.postEvent(self.document, helpevent) UserInteraction.start(self)
def send_siminfo(self): t = time.time() dt = t - self.prevtime qapp.postEvent( qapp.instance(), SimInfoEvent( (self.sim.samplecount - self.prevcount) / dt, self.sim.simdt, self.sim.simt, self.sim.traf.ntraf, self.sim.mode, ), ) self.prevtime = t self.prevcount = self.sim.samplecount
def start(self): self.document.view().setCursor(Qt.CrossCursor) helpevent = QuickHelpTipEvent( self.tr("Click to create a new text annotation"), self.tr('<h3>New text annotation</h3>' '<p>Click (and drag to resize) on the canvas to create ' 'a new text annotation item.</p>' # '<a href="help://orange-canvas/text-annotations">' # 'More ...</a>' ) ) QCoreApplication.postEvent(self.document, helpevent) UserInteraction.start(self)
def end(self): if self.control is not None: self.scene.removeItem(self.control) self.control = None self.down_pos = None self.annotation_item = None self.annotation = None self.document.view().setCursor(Qt.ArrowCursor) # Clear the help tip helpevent = QuickHelpTipEvent("", "") QCoreApplication.postEvent(self.document, helpevent) UserInteraction.end(self)
def start(self): self.document.view().setCursor(Qt.CrossCursor) helpevent = QuickHelpTipEvent( self.tr("Click to create a new text annotation"), self. tr('<h3>New text annotation</h3>' '<p>Click (and drag to resize) on the canvas to create ' 'a new text annotation item.</p>' # '<a href="help://orange-canvas/text-annotations">' # 'More ...</a>' )) QCoreApplication.postEvent(self.document, helpevent) UserInteraction.start(self)
def objappend(self, objtype, objname, data_in): if data_in is None: # This is an object delete event data = None elif objtype == 1 or objtype == 4: # LINE(1) or POLY(4) data = np.array(data_in, dtype=np.float32) elif objtype == 2: # BOX data = np.array( [data_in[0], data_in[1], data_in[0], data_in[3], data_in[2], data_in[3], data_in[2], data_in[1]], dtype=np.float32, ) elif objtype == 3: # CIRCLE pass qapp.postEvent(qapp.instance(), DisplayShapeEvent(objname, data))
def keyPressEvent(self, event): if self.autocomplete.active: if self.autocomplete.keyPressEvent(event): return elif self.calltip.active: if self.calltip.keyPressEvent(event): return m = event.modifiers() k = event.key() t = event.text() # Disable some shortcuts if self.disable_shortcuts and \ m & Qt.ControlModifier and k in [Qt.Key_A, Qt.Key_R, Qt.Key_C, Qt.Key_K, Qt.Key_X, Qt.Key_V, Qt.Key_Y, Qt.Key_Z]: new_ev = QKeyEvent(event.type(), k, m, t) event.ignore() QCoreApplication.postEvent(self.parent(), new_ev) return elif k == Qt.Key_Tab: if self.tab_pressed(): return elif k == Qt.Key_Backtab: if self.backtab_pressed(): return elif k == Qt.Key_Backspace: if self.backspace_pressed(): return elif k == Qt.Key_Period or \ (k == Qt.Key_Space and event.modifiers() == Qt.ControlModifier): QPlainTextEdit.keyPressEvent(self, event) self.autocomplete_pressed() return elif k in [Qt.Key_ParenLeft, Qt.Key_BraceLeft, Qt.Key_BracketLeft]: QPlainTextEdit.keyPressEvent(self, event) self.paren_opened(k) return QPlainTextEdit.keyPressEvent(self, event) if k == Qt.Key_Return or k == Qt.Key_Enter: self.after_return_pressed()
def shutdown_request(): QCoreApplication.postEvent(mainwindow, QEvent(Updater.QUIT_EVENT_TYPE))
def nextImage(self): QCoreApplication.postEvent(self.parent, NextImageGrowthEvent())
def abort(self): QCoreApplication.postEvent(self.parent, AbortImageGrowthEvent())
def __on_anchorClicked(self, anchor): ev = QuickHelpDetailRequestEvent(anchor.toString(), anchor) QCoreApplication.postEvent(self, ev)
def _update(self): """ Schedule processing at a later time. """ QCoreApplication.postEvent(self, QEvent(QEvent.UpdateRequest))
def to_main(func, *args, **kwargs): QCoreApplication.postEvent(QCoreApplication.instance(), ProxyToMainEvent(func, *args, **kwargs))
def abort(self, reason, **others): e = AbortPlottingEvent(reason) if others: e.others = others QCoreApplication.postEvent(self.parent, e)
def update_nb_images(self, nb): QCoreApplication.postEvent(self.parent, UpdateNbImageEvent(nb))
def image_ready(self): QCoreApplication.postEvent(self.parent, ImageReadyPlottingEvent())
def finished(self): if self.loading: QCoreApplication.postEvent(self.parent, FinishLoadingEvent()) self.loading = False else: QCoreApplication.postEvent(self.parent, FinishPlottingEvent())
def delay_method_call(self, *args, **kwargs): event = QueuedCallEvent(method.__get__(self), args, kwargs) QCoreApplication.postEvent(self, event)
def delay_method_call(self, *args, **kwargs): event = QueuedCallEvent(method, (self, ) + args, kwargs) QCoreApplication.postEvent(self, event) QCoreApplication.sendPostedEvents() return event.result()
def start(self): QCoreApplication.postEvent(self, ExecuteCallEvent())
def schedule_later(): QCoreApplication.postEvent(self, event, Qt.LowEventPriority - 10)
def nextImage(self): QCoreApplication.postEvent(self.parent, NextImageEvent())
def finished(self): QCoreApplication.postEvent(self.parent, FinishImageGrowthEvent())
def schedule_later(): QCoreApplication.postEvent( self, event, Qt.LowEventPriority - 10)