How to use the ginga.qtw.QtHelp.QtCore.Qt function in ginga

To help you get started, we’ve selected a few ginga examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ejeschke / ginga / ginga / qtw / ImageViewQt.py View on Github external
return 'up'
        if keycode in [QtCore.Qt.Key_Down]:
            return 'down'
        if keycode in [QtCore.Qt.Key_Left]:
            return 'left'
        if keycode in [QtCore.Qt.Key_Right]:
            return 'right'
        if keycode in [QtCore.Qt.Key_PageUp]:
            return 'page_up'
        if keycode in [QtCore.Qt.Key_PageDown]:
            return 'page_down'
        if keycode in [QtCore.Qt.Key_Home]:
            return 'home'
        if keycode in [QtCore.Qt.Key_End]:
            return 'end'
        if keycode in [QtCore.Qt.Key_Insert]:
            return 'insert'
        if keycode in [QtCore.Qt.Key_Delete]:
            return 'delete'
        # if keycode in [QtCore.Qt.Key_Super_L]:
        #     return 'super_l'
        # if keycode in [QtCore.Qt.Key_Super_R]:
        #     return 'super_r'
        if keycode in [QtCore.Qt.Key_Escape]:
            return 'escape'
        # Control key on Mac keyboards and "Windows" key under Linux
        if keycode in [16777250]:
            return 'meta_right'
        if keycode in self._fnkeycodes:
            index = self._fnkeycodes.index(keycode)
            return 'f%d' % (index + 1)
github ejeschke / ginga / ginga / qtw / GingaQt.py View on Github external
hbox.addWidget(cbox1, stretch=0)

        opmenu = QtGui.QMenu()
        self.w.operation = opmenu
        btn = QtGui.QPushButton("Operation")
        btn.clicked.connect(self.invoke_op_cb)
        btn.setToolTip("Invoke operation")
        self.w.opbtn = btn
        hbox.addWidget(btn, stretch=0)

        w = QtGui.QWidget()
        self.w.optray = QtGui.QHBoxLayout()
        self.w.optray.setContentsMargins(0, 0, 0, 0)
        self.w.optray.setSpacing(2)
        w.setLayout(self.w.optray)
        hbox.addWidget(w, stretch=1, alignment=QtCore.Qt.AlignLeft)

        self.w.vbox.addWidget(plw, stretch=0)

        # Add colormap bar
        cbar = self.build_colorbar()
        self.w.vbox.addWidget(cbar, stretch=0)

        menuholder = self.w['menu']
        # NOTE: menubar is a ginga.Widgets wrapper
        self.w.menubar = self.add_menus(menuholder)

        self.add_dialogs()
        statusholder = self.w['status']
        self.add_statusbar(statusholder)

        self.w.root.show()
github ejeschke / ginga / ginga / qtw / plugins / Errors.py View on Github external
tw.setText(errmsg)
        vbox.addWidget(tw, stretch=1)

        hbox = QtHelp.HBox()
        btn = QtGui.QPushButton("Remove")
        btn.clicked.connect(lambda: self.remove_error(vbox))
        hbox.addWidget(btn, stretch=0)
        # Add the time the error occurred
        ts = time.strftime("%m/%d %H:%M:%S", time.localtime())
        lbl = QtGui.QLabel(ts)
        hbox.addWidget(lbl, stretch=0)
        vbox.addWidget(hbox, stretch=0)
        
        layout = self.msgList.layout()
        layout.addWidget(vbox, layout.rowCount(), 0,
                         alignment=QtCore.Qt.AlignTop)
        self.widgetList.append(vbox)
        # TODO: force scroll to bottom 
github ejeschke / ginga / ginga / qtw / plugins / Thumbs.py View on Github external
def _mk_context_menu(self, lbl, thumbkey, chname, name, path,
                         image_future):
        lbl.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        menu = QtGui.QMenu()
        item = QtGui.QAction("Display", menu)
        item.triggered.connect(lambda: self.load_file(thumbkey, chname, name,
                                                      path, image_future))
        menu.addAction(item)
        menu.addSeparator()
        item = QtGui.QAction("Remove", menu)
        item.triggered.connect(lambda: self.fv.remove_image_by_name(chname, name, impath=path))
        menu.addAction(item)

        def on_context_menu(point):
            menu.exec_(lbl.mapToGlobal(point))

        lbl.customContextMenuRequested.connect(on_context_menu)
github ejeschke / ginga / ginga / qtw / plugins / Thumbs.py View on Github external
image_future)
        # make a context menu
        self._mk_context_menu(imglbl, thumbkey, chname, name, path,
                              image_future)
        # make a tool tip
        text = self.query_thumb(thumbkey, name, metadata)
        imglbl.setToolTip(text)

        widget = QtGui.QWidget()
        #vbox = QtGui.QGridLayout()
        vbox = QtGui.QVBoxLayout()
        vbox.setContentsMargins(0, 0, 0, 0)
        vbox.setSpacing(0)
        widget.setLayout(vbox)
        namelbl = QtGui.QLabel(thumbname)
        namelbl.setAlignment(QtCore.Qt.AlignLeft)
        namelbl.setAlignment(QtCore.Qt.AlignHCenter)
        ## vbox.addWidget(namelbl, 0, 0)
        ## vbox.addWidget(imglbl,  1, 0)
        vbox.addWidget(namelbl, stretch=0)
        vbox.addWidget(imglbl,  stretch=0)
        widget.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed,
                                               QtGui.QSizePolicy.Fixed))
        bnch = Bunch.Bunch(widget=widget, image=imgwin, layout=vbox,
                           imglbl=imglbl, name=name, imname=name,
                           chname=chname, path=path, thumbpath=thumbpath,
                           pixmap=pixmap, image_future=image_future)

        with self.thmblock:
            self.thumbDict[thumbkey] = bnch
            self.thumbList.append(thumbkey)
github ejeschke / ginga / ginga / qtw / plugins / Header.py View on Github external
def headerData(self, col, orientation, role):
        if (orientation == QtCore.Qt.Horizontal) and \
               (role == QtCore.Qt.DisplayRole):
            return self.columns[col][0]

        # Hack to make the rows in a TableView all have a
        # reasonable height for the data
        elif (role == QtCore.Qt.SizeHintRole) and \
                 (orientation == QtCore.Qt.Vertical):
            return 1
        return None
github ejeschke / ginga / ginga / qtw / plugins / Thumbs.py View on Github external
def mouseMoveEvent(self, event):

        if event.buttons() != QtCore.Qt.LeftButton:
            return

        # only consider this a drag if user has moved a certain amount
        # away from the press position
        if ((event.pos() - self.drag_start_position).manhattanLength() <
            QApplication.startDragDistance()):
            return

        # prepare formatted possibilities on drop
        mimeData = QtCore.QMimeData()
        chname, name, path = self._dragdata
        data = "%s||%s||%s" % (chname, name, path)
        mimeData.setData("text/thumb", data)
        mimeData.setData("text/plain", path)

        drag = QtGui.QDrag(self)
github ejeschke / ginga / ginga / qtw / ImageViewQt.py View on Github external
def scroll_event(self, widget, event):
        x, y = event.x(), event.y()
        # accept event here so it doesn't get propagated to parent
        event.accept()
        self.last_win_x, self.last_win_y = x, y

        data_x, data_y = self.check_cursor_location()

        # NOTE: for future use in distinguishing mouse wheel vs.
        # trackpad events
        src = 'wheel'
        if hasattr(event, 'source'):
            # Qt5 only, it seems
            _src = event.source()
            if _src == QtCore.Qt.MouseEventNotSynthesized:
                src = 'wheel'
            else:
                src = 'trackpad'  # noqa
                point = event.pixelDelta()
                dx, dy = point.x(), point.y()

                # Synthesize this as a pan gesture event
                self.make_ui_callback_viewer(self, 'pan', 'start', 0, 0)
                self.make_ui_callback_viewer(self, 'pan', 'move', dx, dy)
                return self.make_ui_callback_viewer(self, 'pan', 'stop', 0, 0)

        num_degrees, direction = get_scroll_info(event)
        self.logger.debug("scroll deg={} direction={}".format(
            num_degrees, direction))

        return self.make_ui_callback_viewer(self, 'scroll', direction,
github ejeschke / ginga / ginga / qtw / plugins / Header.py View on Github external
def headerData(self, col, orientation, role):
        if (orientation == QtCore.Qt.Horizontal) and \
               (role == QtCore.Qt.DisplayRole):
            return self.columns[col][0]

        # Hack to make the rows in a TableView all have a
        # reasonable height for the data
        elif (role == QtCore.Qt.SizeHintRole) and \
                 (orientation == QtCore.Qt.Vertical):
            return 1
        return None
github ejeschke / ginga / ginga / mplw / FigureCanvasQt.py View on Github external
def setup_Qt(widget, viewer):

    _resizeEvent = widget.resizeEvent

    def resizeEvent(*args):
        rect = widget.geometry()
        x1, y1, x2, y2 = rect.getCoords()
        width = x2 - x1
        height = y2 - y1

        if viewer is not None:
            viewer.configure_window(width, height)

        _resizeEvent(*args)

    widget.setFocusPolicy(QtCore.Qt.FocusPolicy(
        QtCore.Qt.TabFocus |
        QtCore.Qt.ClickFocus |
        QtCore.Qt.StrongFocus |
        QtCore.Qt.WheelFocus))
    widget.setMouseTracking(True)
    widget.setAcceptDrops(True)

    # Matplotlib has a bug where resize events are not reported
    widget.resizeEvent = resizeEvent