Пример #1
0
    def __init__(self, parent=None, flags=QtCore.Qt.WindowFlags(0), **kwargs):
        #title = self.tr('Worldmap Panel')
        super(WorldmapPanel, self).__init__('World Map Panel', parent, flags,
                                            **kwargs)
        #self.setObjectName('worldmapPanel') # @TODO: check

        scene = QtWidgets.QGraphicsScene(self)
        scene.setSceneRect(-180, -90, 360, 180)
        self.graphicsview = QtWidgets.QGraphicsView(scene)
        self.graphicsview.scale(2., -2.)

        self.worldmapitem = None
        self.setWorldmapItem()

        self.actions = self._setupActions()
        self.actionZoomIn, self.actionZoomOut = self.actions.actions()

        toolbar = qtsupport.actionGroupToToolbar(self.actions,
                                                  self.tr('Zoom toolbar'))
        toolbar.setOrientation(QtCore.Qt.Vertical)

        mainlayout = QtWidgets.QHBoxLayout()
        mainlayout.addWidget(self.graphicsview)
        mainlayout.addWidget(toolbar)

        mainwidget = QtWidgets.QWidget()
        mainwidget.setLayout(mainlayout)
        self.setWidget(mainwidget)

        self.bigbox = None
        self.box = None
        self.fitItem = self.worldmapitem

        self.graphicsview.installEventFilter(self)
Пример #2
0
    def _setupActions(self):
        actions = QtWidgets.QActionGroup(self)

        # KML export
        icon = qtsupport.geticon('area.svg', 'gsdview')
        QtWidgets.QAction(icon,
                          self.tr('KML export'),
                          actions,
                          objectName='kmlExportAction',
                          statusTip=self.tr('KML export'),
                          triggered=self.exportKML)

        # Open in google earth
        icon = qtsupport.geticon('earth.svg', __name__)
        QtWidgets.QAction(icon,
                          self.tr('Open in Google Earth'),
                          actions,
                          objectName='openInGoogleEarthAction',
                          statusTip=self.tr('Open in Google Earth'),
                          triggered=self.openInGoogleEarth)

        # Open in google maps
        icon = qtsupport.geticon('overview.svg', 'gsdview.gdalbackend')
        QtWidgets.QAction(icon,
                          self.tr('Open in Google Maps'),
                          actions,
                          objectName='openInGoogleMapsAction',
                          statusTip=self.tr('Open in Google Maps'),
                          triggered=self.openInGoogleMaps)

        return actions
Пример #3
0
    def __init__(self, parent=None, flags=QtCore.Qt.WindowFlags(0), **kwargs):
        super(ItemModelMainWindow, self).__init__(parent, flags, **kwargs)

        #: main application datamodel (QStandardItemModel)
        self.datamodel = QtGui.QStandardItemModel(self)

        # @TODO: custom treeview with "currentChanged" slot re-implemented
        #: tree view for the main application data model
        self.treeview = QtWidgets.QTreeView()
        # @TODO
        #self.treeview.setSelectionMode(QtWidgets.QTreeView.SingleSelection)
        self.treeview.setModel(self.datamodel)
        self.treeview.setEditTriggers(
            QtWidgets.QAbstractItemView.NoEditTriggers)
        self.treeview.header().hide()

        self.treeview.clicked.connect(self.setActiveWinFromIndex)
        self.mdiarea.subWindowActivated.connect(self.setActiveIndexFromWin)
        self.datamodel.rowsAboutToBeRemoved.connect(self.onItemsClosed)

        # setup the treeview dock
        treeviewdock = QtWidgets.QDockWidget(self.tr('Data Browser'), self)
        treeviewdock.setWidget(self.treeview)
        treeviewdock.setObjectName('TreeViewPanel')
        self.addDockWidget(QtCore.Qt.LeftDockWidgetArea, treeviewdock)
Пример #4
0
    def _setupFileActions(self):
        style = self.style()

        actions = QtWidgets.QActionGroup(self)

        icon = style.standardIcon(QtWidgets.QStyle.SP_DialogOpenButton)
        QtWidgets.QAction(icon,
                          self.tr('Open Vector'),
                          actions,
                          objectName='openVectorAction',
                          statusTip=self.tr('Open Vector'),
                          triggered=self.onOpenVector)

        icon = style.standardIcon(QtWidgets.QStyle.SP_DialogResetButton)
        QtWidgets.QAction(icon,
                          self.tr('Close All'),
                          actions,
                          objectName='claseAllAction',
                          statusTip=self.tr('Close All'),
                          triggered=self.reset)

        QtWidgets.QAction(actions).setSeparator(True)

        icon = style.standardIcon(QtWidgets.QStyle.SP_DialogCancelButton)
        QtWidgets.QAction(icon,
                          self.tr('Exit'),
                          actions,
                          objectName='exitAction',
                          statusTip=self.tr('Exit'),
                          triggered=self.close)

        return actions
Пример #5
0
    def _setupMajorObjectItemActions(self, actionsgroup=None):
        if actionsgroup is None:
            actionsgroup = QtWidgets.QActionGroup(self)

        # open metadata view
        icon = qtsupport.geticon('metadata.svg', __name__)
        QtWidgets.QAction(icon,
                          self.tr('Open &Metadata View'),
                          actionsgroup,
                          objectName='actionOpenItemMetadataView',
                          shortcut=self.tr('Ctrl+M'),
                          toolTip=self.tr('Show metadata in a new window'),
                          statusTip=self.tr('Show metadata in a new window'),
                          triggered=self.openItemMatadataView,
                          enabled=False)  # @TODO: remove

        # show properties
        # @TODO: standard info icon from gdsview package
        icon = qtsupport.geticon('info.svg', 'gsdview')
        QtWidgets.QAction(
            icon,
            self.tr('&Show Properties'),
            actionsgroup,
            objectName='actionShowItemProperties',
            shortcut=self.tr('Ctrl+S'),
            toolTip=self.tr('Show the property dialog for the cutent item'),
            statusTip=self.tr('Show the property dialog for the cutent item'),
            triggered=self.showItemProperties)

        return actionsgroup
Пример #6
0
    def _setupHelpActions(self):
        actionsgroup = QtWidgets.QActionGroup(self)

        # About
        icon = qtsupport.geticon('about.svg', __name__)
        QtWidgets.QAction(
            icon, self.tr('&About'), actionsgroup,
            objectName='aboutAction',
            toolTip=self.tr('Show program information'),
            statusTip=self.tr('Show program information'),
            triggered=lambda: self.aboutdialog.exec_())

        # AboutQt
        icon = QtGui.QIcon(':/qt-project.org/qmessagebox/images/qtlogo-64.png')
        # @COMPATIBILITY: Qt4 --> Qt5
        if not icon.availableSizes():
            icon = QtGui.QIcon(':/trolltech/qmessagebox/images/qtlogo-64.png')
        if not icon.availableSizes():
            icon = QtGui.QIcon.fromTheme('qtlogo-64')
        QtWidgets.QAction(
            icon, self.tr('About &Qt'), actionsgroup,
            objectName='aboutQtAction',
            toolTip=self.tr('Show information about Qt'),
            statusTip=self.tr('Show information about Qt'),
            triggered=lambda: QtWidgets.QMessageBox.aboutQt(self))

        return actionsgroup
Пример #7
0
def test_generalpreferencespage():
    app = QtWidgets.QApplication(sys.argv)
    d = QtWidgets.QDialog()
    layout = QtWidgets.QVBoxLayout()
    layout.addWidget(GeneralPreferencesPage())
    d.setLayout(layout)
    d.show()
    app.exec_()
Пример #8
0
def test_fileentrywidget():
    app = QtWidgets.QApplication(sys.argv)
    d = QtWidgets.QDialog()
    layout = QtWidgets.QVBoxLayout()
    layout.addWidget(FileEntryWidget())
    d.setLayout(layout)
    d.show()
    app.exec_()
Пример #9
0
    def __init__(self,
                 exctype=None,
                 excvalue=None,
                 tracebackobj=None,
                 parent=None,
                 flags=QtCore.Qt.WindowFlags(0),
                 fill=True,
                 **kwargs):
        super(ExceptionDialog, self).__init__(parent, flags, **kwargs)
        self.setupUi(self)

        title = 'Critical error: unhandled exception occurred'
        self.setWindowTitle(self.tr(title))

        closebutton = self.buttonBox.button(QtWidgets.QDialogButtonBox.Close)
        closebutton.setDefault(True)

        style = QtWidgets.QApplication.style()

        icon = style.standardIcon(style.SP_CommandLink)
        sendbutton = QtWidgets.QPushButton(
            icon,
            self.tr('Send'),
            toolTip=self.tr('Send the bug-report via email.'),
            autoDefault=False,
            clicked=self.sendBugReport)
        self.sendbutton = sendbutton
        self.buttonBox.addButton(sendbutton,
                                 QtWidgets.QDialogButtonBox.ActionRole)

        icon = style.standardIcon(style.SP_DialogSaveButton)
        savebutton = QtWidgets.QPushButton(
            icon,
            self.tr('&Save'),
            toolTip=self.tr('Save the bug-report on file.'),
            autoDefault=False,
            clicked=self.saveBugReport)
        self.savebutton = savebutton
        self.buttonBox.addButton(savebutton,
                                 QtWidgets.QDialogButtonBox.ActionRole)

        pixmap = style.standardPixmap(style.SP_MessageBoxCritical)
        self.iconLabel.setPixmap(pixmap)

        self.exctype = exctype
        self.excvalue = excvalue
        self.tracebackobj = tracebackobj

        self.textLabel.linkActivated.connect(self._linkActivated)

        if fill:
            if not self._excInfoSet():
                self.setExcInfo(*sys.exc_info())
            else:
                self._fill()
Пример #10
0
    def addSoftwareVersion(self, sw, version, link=''):
        tablewidget = self.versionsTableWidget
        index = tablewidget.rowCount()
        tablewidget.setRowCount(index + 1)

        tablewidget.setItem(index, 0, QtWidgets.QTableWidgetItem(sw))
        tablewidget.setItem(index, 1, QtWidgets.QTableWidgetItem(version))
        #tablewidget.setItem(row, 2, QtWidgets.QTableWidgetItem(link))
        linkLabel = QtWidgets.QLabel('<a href="{0}">{0}</a>'.format(link))
        linkLabel.linkActivated.connect(
            lambda text: QtGui.QDesktopServices.openUrl(QtCore.QUrl(text)))
        tablewidget.setCellWidget(index, 2, linkLabel)
Пример #11
0
    def _setupHelpActions(self):
        actions = QtWidgets.QActionGroup(self)

        icon = QtGui.QIcon(
            ':/trolltech/styles/commonstyle/images/fileinfo-32.png')
        QtWidgets.QAction(icon, 'About', actions, triggered=self.about)

        icon = QtGui.QIcon(':/trolltech/qmessagebox/images/qtlogo-64.png')
        QtWidgets.QAction(icon,
                          'About Qt',
                          actions,
                          triggered=QtWidgets.QApplication.aboutQt)

        return actions
Пример #12
0
    def _setupActions(self):
        actions = QtWidgets.QActionGroup(self)

        # Zoom in
        icon = qtsupport.geticon('zoom-in.svg', 'gsdview')
        QtWidgets.QAction(icon,
                          self.tr('Zoom In'),
                          actions,
                          objectName='zoomInAction',
                          statusTip=self.tr('Zoom In'),
                          shortcut=QtGui.QKeySequence(self.tr('Ctrl++')),
                          triggered=self.zoomIn)

        # Zoom out
        icon = qtsupport.geticon('zoom-out.svg', 'gsdview')
        QtWidgets.QAction(icon,
                          self.tr('Zoom Out'),
                          actions,
                          objectName='zoomOutAction',
                          statusTip=self.tr('Zoom Out'),
                          shortcut=QtGui.QKeySequence(self.tr('Ctrl+-')),
                          triggered=self.zoomOut)

        # Zoom fit
        icon = qtsupport.geticon('zoom-fit.svg', 'gsdview')
        QtWidgets.QAction(icon,
                          self.tr('Zoom Fit'),
                          actions,
                          objectName='zoomFitAction',
                          statusTip=self.tr('Zoom to fit the window size'),
                          triggered=self.zoomFit)

        # Zoom 100
        icon = qtsupport.geticon('zoom-100.svg', 'gsdview')
        QtWidgets.QAction(icon,
                          self.tr('Zoom 100%'),
                          actions,
                          objectName='zoom100Action',
                          statusTip=self.tr('Original size'),
                          triggered=self.zoom100)

        # Manual Zoom
        #icon = QtGui.QIcon() #qt4support.geticon('zoom-100.svg', 'gsdview')
        #QtWidgets.QWidgetAction(
        #    icon, self.tr('Zoom 100%'), actions,
        #    statusTip=self.tr('Original size'),
        #    triggered=self.zoom100)

        return actions
Пример #13
0
    def setPlatformInfo(self):
        tablewidget = self.platformTableWidget

        platform_info = utils.format_platform_info()
        platform_info.extend(qtsupport.format_qt_info())

        tablewidget.setRowCount(len(platform_info))
        for index, line in enumerate(platform_info):
            name, value = line.split(':', 1)
            tablewidget.setItem(index, 0, QtWidgets.QTableWidgetItem(name))
            tablewidget.setItem(index, 1, QtWidgets.QTableWidgetItem(value))

        header = tablewidget.horizontalHeader()
        header.resizeSections(QtWidgets.QHeaderView.ResizeToContents)
        header.setStretchLastSection(True)
Пример #14
0
    def __init__(self, app, **kwargs):
        super(StretchTool, self).__init__(app, **kwargs)
        self.app = app

        self.dialog = StretchDialog(parent=app)
        self.dialog.hide()

        # @COMPATIBILITY: pyside 1.2.2
        qApp = QtWidgets.QApplication.instance()

        # This should not be necessary since tha main window (app) is set
        # as parent of the StretchDialog
        qApp.lastWindowClosed.connect(self.dialog.close)

        self.action = self._setupAction()
        self.action.setEnabled(False)

        self.dialog.finished.connect(lambda: self.action.setChecked(False))
        self.app.mdiarea.subWindowActivated.connect(self.onSubWindowChanged)
        #~ self.app.treeview.clicked.connect(self.onItemClicked)
        #~ self.app.subWindowClosed(self.onModelChanged)
        self.dialog.valueChanged.connect(self.onStretchChanged)

        self.toolbar = QtWidgets.QToolBar(self.tr('Stretching Toolbar'))
        self.toolbar.setObjectName('stretchingToolbar')
        self.toolbar.addAction(self.action)
Пример #15
0
    def _setupActions(self):
        actions = super(LayerManager, self)._setupActions()

        icon = QtGui.QIcon(
            ':/trolltech/styles/commonstyle/images/viewdetailed-128.png')
        QtWidgets.QAction(icon,
                          self.tr('Select all'),
                          actions,
                          objectName='selectAllAction',
                          statusTip=self.tr('Select all'),
                          shortcut=self.tr('Ctrl-A'),
                          triggered=self.view.selectAll)

        # connect actions
        action = actions.findChild(QtWidgets.QAction, 'moveToTopAction')
        action.triggered.connect(self.moveSelectionToTop)
        action = actions.findChild(QtWidgets.QAction, 'moveUpAction')
        action.triggered.connect(self.moveSelectionUp)
        action = actions.findChild(QtWidgets.QAction, 'moveDownAction')
        action.triggered.connect(self.moveSelectionDown)
        action = actions.findChild(QtWidgets.QAction, 'moveToBottomAction')
        action.triggered.connect(self.moveSelectionToBottom)
        action = actions.findChild(QtWidgets.QAction, 'removeLayerAction')
        action.triggered.connect(self.removeSelectedLayers)
        action = actions.findChild(QtWidgets.QAction, 'showLayerAction')
        action.triggered.connect(self.checkSelectedItems)
        action = actions.findChild(QtWidgets.QAction, 'hideLayerAction')
        action.triggered.connect(self.uncheckSelectedItems)

        return actions
Пример #16
0
    def __init__(self,
                 logger=None,
                 statusbar=None,
                 progressbar=None,
                 blinker=None,
                 parent=None,
                 **kwargs):
        QtCore.QObject.__init__(self, parent, **kwargs)
        BaseOutputHandler.__init__(self, logger)

        self.statusbar = statusbar
        if self.statusbar:
            if blinker is None:
                blinker = QtBlinker()
                statusbar.addPermanentWidget(blinker)
                blinker.hide()
            self.pulse.connect(blinker.show)
            self.pulse.connect(blinker.pulse)
            self.pulse[str].connect(lambda text: statusbar.showMessage(
                text, self._statusbar_timeout))

            if progressbar is None:
                progressbar = QtWidgets.QProgressBar(self.statusbar)
                progressbar.setTextVisible(True)
                statusbar.addPermanentWidget(progressbar)  # , 1) # stretch=1
                progressbar.hide()
            self.progressbar = progressbar
            #self.percentageChanged[()].connect(progressbar.show)
            self.percentageChanged.connect(progressbar.show)
            self.percentageChanged.connect(progressbar.setValue)

        self.progressbar = progressbar
        self.blinker = blinker
Пример #17
0
def test_mousemanager():
    import sys
    app = QtWidgets.QApplication(sys.argv)
    app.setApplicationName('MouseManager')
    mainwin = MainWin()
    mainwin.show()
    sys.exit(app.exec_())
Пример #18
0
def printPreview(obj, printer=None, parent=None):
    if printer is None:
        printer = QtPrintSupport.QPrinter(QtPrintSupport.QPrinter.PrinterResolution)

    # @TODO: check
    if parent is None:
        try:
            parent = obj.window()
        except AttributeError:
            parent = None

    dialog = QtWidgets.QPrintPreviewDialog(printer, parent)
    dialog.paintRequested.connect(coreprint)
    ret = dialog.exec_()

    # @WARNING: duplicate code
    ret = QtPrintSupport.QPrintDialog(printer, parent).exec_()
    if ret == QtWidgets.QDialog.Accepted:
        if isinstance(obj, (QtGui.QTextDocument, QtWidgets.QTextEdit)):
            obj.print_(printer)
        elif hasattr(object, 'model'):
            model = obj.model()
            doc = modelToTextDocument(model)
            obj.print_(printer)
        elif isinstance(obj, QtCore.QAbstractItemModel):
            doc = modelToTextDocument(obj)
            doc.print_(printer)
        else:
            coreprint(obj, printer)
Пример #19
0
    def _setupViewActions(self):
        actions = QtWidgets.QActionGroup(self)

        icon = QtGui.QIcon(
            ':/trolltech/dialogs/qprintpreviewdialog/images/zoom-in-32.png')
        QtWidgets.QAction(icon,
                          self.tr('Zoom In'),
                          actions,
                          objectName='zoomInAction',
                          statusTip=self.tr('Zoom In'),
                          shortcut=self.tr('Ctrl++'),
                          triggered=lambda: self.graphicsview.scale(1.2, 1.2))

        icon = QtGui.QIcon(
            ':/trolltech/dialogs/qprintpreviewdialog/images/zoom-out-32.png')
        QtWidgets.QAction(
            icon,
            self.tr('Zoom Out'),
            actions,
            objectName='zoomOutAction',
            statusTip=self.tr('Zoom Out'),
            shortcut=self.tr('Ctrl+-'),
            triggered=lambda: self.graphicsview.scale(1 / 1.2, 1 / 1.2))

        icon = QtGui.QIcon(
            ':/trolltech/dialogs/qprintpreviewdialog/images/page-setup-24.png')
        QtWidgets.QAction(icon,
                          self.tr('Zoom 1:1'),
                          actions,
                          objectName='zoomResetAction',
                          statusTip=self.tr('Zoom 1:1'),
                          triggered=lambda: self.graphicsview.setTransform(
                              QtGui.QTransform(1, 0, 0, -1, 0, 0)))

        icon = QtGui.QIcon(
            ':/trolltech/dialogs/qprintpreviewdialog/images/fit-page-32.png')
        QtWidgets.QAction(
            icon,
            self.tr('Zoom Fit'),
            actions,
            objectName='zoomFitAction',
            statusTip=self.tr('Zoom Fit'),
            #checkable=True,
            triggered=lambda: self.graphicsview.fitInView(
                self.graphicsview.sceneRect(), QtCore.Qt.KeepAspectRatio))

        return actions
Пример #20
0
 def addPage(self, page, icon, label=None):
     if not (hasattr(page, 'load') and hasattr(page, 'save')):
         raise TypeError('preference pages must have both "load" and '
                         '"save" methods')
     index = self.stackedWidget.addWidget(page)
     item = QtWidgets.QListWidgetItem(icon, label)
     self.listWidget.addItem(item)
     assert self.listWidget.row(item) == index
Пример #21
0
    def _setupFileActions(self):
        style = self.style()

        actions = QtWidgets.QActionGroup(self)

        icon = style.standardIcon(QtWidgets.QStyle.SP_DialogOpenButton)
        QtWidgets.QAction(icon, 'Open', actions, triggered=self.openfile)

        icon = style.standardIcon(QtWidgets.QStyle.SP_DialogCloseButton)
        QtWidgets.QAction(icon, 'Close', actions, triggered=self.scene.clear)

        QtWidgets.QAction(actions).setSeparator(True)

        icon = style.standardIcon(QtWidgets.QStyle.SP_DialogCancelButton)
        QtWidgets.QAction(icon, 'Exit', actions, triggered=self.close)

        return actions
Пример #22
0
    def _setupDatasetItemActions(self, actionsgroup=None):
        if actionsgroup is None:
            actionsgroup = QtWidgets.QActionGroup(self)

        # open RGB
        # @TODO: find an icon for RGB
        icon = qtsupport.geticon('rasterband.svg', __name__)
        QtWidgets.QAction(
            icon,
            self.tr('Open as RGB'),
            actionsgroup,
            objectName='actionOpenRGBImageView',
            #shortcut=self.tr('Ctrl+B'),
            toolTip=self.tr('Display the dataset as an RGB image'),
            statusTip=self.tr('Open as RGB'),
            triggered=self.openRGBImageView)

        # build overviews
        icon = qtsupport.geticon('overview.svg', __name__)
        QtWidgets.QAction(
            icon,
            self.tr('&Build overviews'),
            actionsgroup,
            objectName='actionBuidOverviews',
            shortcut=self.tr('Ctrl+B'),
            toolTip=self.tr('Build overviews for all raster bands'),
            statusTip=self.tr('Build overviews for all raster bands'),
            triggered=self.buildOverviews)

        # @TODO: add band, add virtual band, open GCPs view

        # close
        icon = qtsupport.geticon('close.svg', 'gsdview')
        QtWidgets.QAction(icon,
                          self.tr('Close'),
                          actionsgroup,
                          objectName='actionCloseItem',
                          shortcut=self.tr('Ctrl+W'),
                          toolTip=self.tr('Close the current item'),
                          statusTip=self.tr('Close the current item'),
                          triggered=self.closeCurrentItem)

        self._setupMajorObjectItemActions(actionsgroup)

        return actionsgroup
Пример #23
0
    def _setupSubDatasetItemActions(self, actionsgroup=None):
        if actionsgroup is None:
            actionsgroup = QtWidgets.QActionGroup(self)

        # open
        icon = qtsupport.geticon('open.svg', __name__)
        QtWidgets.QAction(icon,
                          self.tr('Open Sub Dataset'),
                          actionsgroup,
                          objectName='actionOpenSubDatasetItem',
                          shortcut=self.tr('Ctrl+O'),
                          toolTip=self.tr('Open Sub Dataset'),
                          statusTip=self.tr('Open Sub Dataset'),
                          triggered=self.openSubDataset)

        self._setupDatasetItemActions(actionsgroup)

        return actionsgroup
Пример #24
0
    def __init__(self,
                 plugin,
                 active,
                 parent=None,
                 flags=QtCore.Qt.WindowFlags(0),
                 **kwargs):
        super(PluginInfoDialog, self).__init__(parent, flags, **kwargs)
        self.setModal(True)

        bbox = QtWidgets.QDialogButtonBox()
        bbox.addButton(bbox.Close)
        b = bbox.button(bbox.Close)
        b.clicked.connect(self.accept)

        layout = QtWidgets.QVBoxLayout()
        layout.addWidget(PluginInfoForm(plugin, active))
        layout.addWidget(bbox)
        self.setLayout(layout)
Пример #25
0
    def setMetadata(self, metadatalist):
        self.clear()
        if not metadatalist:
            return

        self.infoTable.setRowCount(len(metadatalist))

        for row, data in enumerate(metadatalist):
            name, value = data.split('=', 1)
            #item = QtWidgets.QTableWidgetItem(name)
            #item.setFlags(item.flags() ^ QtCore.Qt.ItemIsEditable)
            self.infoTable.setItem(row, 0, QtWidgets.QTableWidgetItem(name))
            self.infoTable.setItem(row, 1, QtWidgets.QTableWidgetItem(value))

        # Fix table header behaviour
        header = self.infoTable.horizontalHeader()
        header.resizeSections(QtWidgets.QHeaderView.ResizeToContents)
        header.setStretchLastSection(True)
Пример #26
0
    def __init__(self, parent=None, stdmodes=True, **kwargs):
        QtCore.QObject.__init__(self, parent, **kwargs)

        self._moderegistry = []
        self.actions = QtWidgets.QActionGroup(self)
        self.actions.setExclusive(True)

        if stdmodes:
            self.registerStandardModes()
Пример #27
0
def setViewContextActions(widget):
    assert (widget.contextMenuPolicy() == QtCore.Qt.ActionsContextMenu), \
        'menu policy is not "QtCore.Qt.ActionsContextMenu"'
    #if widget.contextMenuPolicy() != QtCore.Qt.ActionsContextMenu:
    #    widget.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)

    icon = geticon('copy.svg', __name__)
    action = QtWidgets.QAction(
        icon, widget.tr('&Copy'), widget,
        objectName='copyAction',
        shortcut=widget.tr('Ctrl+C'),
        toolTip=widget.tr('Copy selected items'),
        triggered=lambda: copySelectedItems(widget))
    widget.addAction(action)

    #':/trolltech/dialogs/qprintpreviewdialog/images/view-page-multi-32.png'
    icon = QtGui.QIcon(
        ':/trolltech/styles/commonstyle/images/viewlist-128.png')
    action = QtWidgets.QAction(
        icon, widget.tr('Select &All'), widget,
        objectName='selectAllAction',
        #shortcut=widget.tr('Ctrl+A'),
        toolTip=widget.tr('Select all items'),
        triggered=lambda: selectAllItems(widget))
    widget.addAction(action)

    icon = widget.style().standardIcon(QtWidgets.QStyle.SP_DialogSaveButton)
    action = QtWidgets.QAction(
        icon, widget.tr('&Save As'), widget,
        objectName='saveAsAction',
        shortcut=widget.tr('Ctrl+S'),
        statusTip=widget.tr('Save as'),
        triggered=lambda: exportTable(widget.model()))
    widget.addAction(action)

    icon = QtGui.QIcon(
        ':/trolltech/dialogs/qprintpreviewdialog/images/print-32.png')
    action = QtWidgets.QAction(
        icon, widget.tr('&Print'), widget,
        objectName='printAction',
        shortcut=widget.tr('Ctrl+P'),
        statusTip=widget.tr('Print'),
        triggered=lambda: printObject(widget))
    widget.addAction(action)
Пример #28
0
def get_filedialog(parent=None):
    try:
        #mainwin = QtWidgets.qApp.findChild(
        #    QtWidgets.QMainWindow,  'gsdview-mainwin')
        mainwin = get_mainwin()
        dialog = mainwin.filedialog
    except AttributeError:
        _log.debug('unable to find the GDSView main window widget')
        dialog = QtWidgets.QFileDialog(parent)
    return dialog
Пример #29
0
    def setup_progress_dialog(self, title=''):
        dialog = QtWidgets.QProgressDialog(self.app)
        dialog.setModal(True)
        if title:
            dialog.setLabelText(title)
        dialog.hide()

        self.progressdialog = dialog

        return dialog
Пример #30
0
    def __init__(self, parent=None, flags=QtCore.Qt.WindowFlags(0)):
        super(MainWin, self).__init__(parent, flags)

        self.mousemanager = MouseManager(self)

        from gsdview.mousemanager import RubberBandMode
        rubberbandmode = RubberBandMode()
        self.mousemanager.addMode(rubberbandmode)

        def callback(rect):
            print('rect', rect)

        rubberbandmode.rubberBandSeclection.connect(callback)

        self.scene = QtWidgets.QGraphicsScene(self)
        self.graphicsview = QtWidgets.QGraphicsView(self.scene, self)
        self.setCentralWidget(self.graphicsview)

        self.mousemanager.register(self.graphicsview)

        # File Actions
        self.fileactions = self._setupFileActions()

        menu = QtWidgets.QMenu('File', self)
        menu.addActions(self.fileactions.actions())
        self.menuBar().addMenu(menu)

        toolbar = QtWidgets.QToolBar('File', self)
        toolbar.addActions(self.fileactions.actions())
        self.addToolBar(toolbar)

        # Mouse Actions
        menu = QtWidgets.QMenu('Mouse', self)
        menu.addActions(self.mousemanager.actions.actions())
        self.menuBar().addMenu(menu)

        toolbar = QtWidgets.QToolBar('Mouse')
        toolbar.addActions(self.mousemanager.actions.actions())
        self.addToolBar(toolbar)

        # Help action
        self.helpactions = self._setupHelpActions()

        menu = QtWidgets.QMenu('Help', self)
        menu.addActions(self.helpactions.actions())
        self.menuBar().addMenu(menu)

        toolbar = QtWidgets.QToolBar('Help', self)
        toolbar.addActions(self.helpactions.actions())
        self.addToolBar(toolbar)

        self.resize(700, 500)