コード例 #1
0
ファイル: Hou2Drive.py プロジェクト: SideswipeeZ/Hou2Drive
    def __init__(self, parent=None):
        super(MyWindow, self).__init__(parent, QtCore.Qt.WindowStaysOnTopHint)
        self.mw = QtCompat.loadUi(file_interface)
        self.setCentralWidget(self.mw)
        self.setWindowTitle("Hou2Cloud")
        stylesheet = hou.qt.styleSheet()
        self.setStyleSheet(stylesheet)
        #Clear Conditions
        self.mw.listWidget.clear()
        self.mw.header_lbl.setPixmap(QPixmap(header))
        self.mw.bttn_link.setText("Link Google Account")

        #Get Init Conditions
        self.Start()
        #Check if Houdini is running Apprentice.
        self.mw.combo_file.clear()
        if hou.isApprentice() == False:
            self.mw.combo_file.addItem(".hip")
        self.mw.combo_file.addItem(".hipnc")
        self.mw.combo_file.addItem(".hiplc")

        #Button Assignment
        #Link to Google Drive
        self.mw.bttn_link.clicked.connect(self.linkDrive)
        self.mw.bttn_link.setIcon(QIcon(gicon))
        #Get File List from Drive
        self.mw.bttn_getFiles.clicked.connect(self.getFiles)
        self.mw.bttn_getFiles.setIcon(QIcon(gicon))
        #Clear List
        self.mw.bttn_clear.clicked.connect(self.clearList)
        self.mw.bttn_clear.setIcon(QIcon(hicon))
        #Upload Button
        self.mw.bttn_upload.clicked.connect(self.upload)
        self.mw.bttn_upload.setIcon(QIcon(gicon))
コード例 #2
0
ファイル: helpform.py プロジェクト: lange5959/qkt_code
    def __init__(self, page, parent=None):
        super(HelpForm, self).__init__(parent)
        self.setAttribute(Qt.WA_DeleteOnClose)
        self.setAttribute(Qt.WA_GroupLeader)

        backAction = QAction(QIcon(":/back.png"), "&Back", self)
        backAction.setShortcut(QKeySequence.Back)
        homeAction = QAction(QIcon(":/home.png"), "&Home", self)
        homeAction.setShortcut("Home")
        self.pageLabel = QLabel()

        toolBar = QToolBar()
        toolBar.addAction(backAction)
        toolBar.addAction(homeAction)
        toolBar.addWidget(self.pageLabel)
        self.textBrowser = QTextBrowser()

        layout = QVBoxLayout()
        layout.addWidget(toolBar)
        layout.addWidget(self.textBrowser, 1)
        self.setLayout(layout)

        backAction.triggered.connect(self.tbackward)
        homeAction.triggered.connect(self.thome)
        self.textBrowser.sourceChanged.connect(self.updatePageTitle)

        self.textBrowser.setSearchPaths([":/help"])
        self.textBrowser.setSource(QUrl(page))
        self.resize(400, 600)
        self.setWindowTitle("{0} Help".format(QApplication.applicationName()))
コード例 #3
0
ファイル: pyxpad.py プロジェクト: ZedThree/pyxpad
    def __init__(self, mainwindow):
        self.main = mainwindow
        self.main.sourceDescription.stateChanged.connect(self.updateDisplay)

        self.groupIcon = QIcon()
        self.groupIcon.addPixmap(mainwindow.style().standardPixmap(QStyle.SP_DirClosedIcon),
                                 QIcon.Normal, QIcon.Off)
        self.groupIcon.addPixmap(mainwindow.style().standardPixmap(QStyle.SP_DirOpenIcon),
                                 QIcon.Normal, QIcon.On)
        self.keyIcon = QIcon()
        self.keyIcon.addPixmap(mainwindow.style().standardPixmap(QStyle.SP_FileIcon))

        self.main.treeView.itemSelectionChanged.connect(self.updateDisplay)
        self.main.tracePattern.returnPressed.connect(self.updateDisplay)
        self.main.treeView.setContextMenuPolicy(Qt.CustomContextMenu)  # Enable popup menus

        # Context menu
        self.main.treeView.customContextMenuRequested.connect(self.handlePopupMenu)

        # Context menu actions
        self.actionAdd = QAction("Add", self.main, statusTip="Add a new source")

        self.actionDelete = QAction("Delete", self.main, statusTip="Remove source from tree")
        self.actionDelete.triggered.connect(self.deleteSource)

        self.actionConfig = QAction("Configure", self.main, statusTip="Configure source")
        self.actionConfig.triggered.connect(self.configureSource)
コード例 #4
0
 def __init__(self, parent=None):
     super(MyWindow, self).__init__(parent, QtCore.Qt.WindowStaysOnTopHint)
     self.mw = QtCompat.loadUi(file_interface)
     self.setCentralWidget(self.mw)
     self.setWindowTitle("Maya2Cloud")
     #Clear Conditions
     self.mw.listWidget.clear()
     self.mw.header_lbl.setPixmap(QPixmap(header))
     self.mw.bttn_link.setText("Link Google Account")
     #Get Init Conditions
     self.Start()
     #Add Items to List.
     self.mw.combo_file.clear()
     self.mw.combo_file.addItem(".mb")
     self.mw.combo_file.addItem(".ma")
     #Button Assignment
     #Link to Google Drive
     self.mw.bttn_link.clicked.connect(self.linkDrive)
     self.mw.bttn_link.setIcon(QIcon(gicon))
     #Get File List from Drive
     self.mw.bttn_getFiles.clicked.connect(self.getFiles)
     self.mw.bttn_getFiles.setIcon(QIcon(gicon))
     #Clear List
     self.mw.bttn_clear.clicked.connect(self.clearList)
     self.mw.bttn_clear.setIcon(QIcon(hicon))
     #Upload Button
     self.mw.bttn_upload.clicked.connect(self.upload)
     self.mw.bttn_upload.setIcon(QIcon(gicon))
コード例 #5
0
    def initPenSizeButtons(self):
        self.penSize = QWidget(self)
        self.penSizeLayout = QHBoxLayout()
        self.penSize.setLayout(self.penSizeLayout)
        # adjust pen size
        self.penSize1 = QPushButton(self.penSize)
        self.penSize1.setIcon(QIcon(":/resource/icon/pensize1.png"))
        self.penSize1.setObjectName('1')
        self.penSize1.setFixedSize(self.iconWidth, self.iconHeight)
        self.penSize1.setCheckable(True)

        self.penSize2 = QPushButton(self.penSize)
        self.penSize2.setIcon(QIcon(":/resource/icon/pensize2.png"))
        self.penSize2.setObjectName('2')
        self.penSize2.setFixedSize(self.iconWidth, self.iconHeight)
        self.penSize2.setCheckable(True)

        self.penSize3 = QPushButton(self.penSize)
        self.penSize3.setIcon(QIcon(":/resource/icon/pensize3.png"))
        self.penSize3.setObjectName('3')
        self.penSize3.setFixedSize(self.iconWidth, self.iconHeight)
        self.penSize3.setCheckable(True)

        self.sizeButtonGroup = QButtonGroup(self.penSize)
        self.sizeButtonGroup.addButton(self.penSize1)
        self.sizeButtonGroup.addButton(self.penSize2)
        self.sizeButtonGroup.addButton(self.penSize3)
        self.sizeButtonGroup.buttonClicked.connect(self.sizeButtonToggled)

        self.penSizeLayout.addWidget(self.penSize1)
        self.penSizeLayout.addWidget(self.penSize2)
        self.penSizeLayout.addWidget(self.penSize3)

        self.penSizeLayout.setSpacing(5)
        self.penSizeLayout.setContentsMargins(0, 0, 0, 0)
コード例 #6
0
ファイル: main.py プロジェクト: mrals2018/QtExamples
def main():
    import sys

    QGuiApplication.setApplicationName("Gallery")
    QGuiApplication.setOrganizationName("QtProject")
    QGuiApplication.setAttribute(Qt.AA_EnableHighDpiScaling)

    app = QGuiApplication(sys.argv)

    QIcon.setThemeName("gallery")

    settings = QSettings()

    style = QQuickStyle.name()
    if style:
        settings.setValue("style", style)
    else:
        QQuickStyle.setStyle(settings.value("style"))

    engine = QQmlApplicationEngine()
    engine.rootContext().setContextProperty("availableStyles",
                                            QQuickStyle.availableStyles())
    engine.load(QUrl("qrc:/gallery.qml"))
    if not engine.rootObjects():
        sys.exit(-1)

    sys.exit(app.exec_())
コード例 #7
0
ファイル: file_status.py プロジェクト: Passion-7/usdmanager
 def icon(self):
     """ Get an icon to display representing the file's status.
     
     :Returns:
         Icon (may be blank)
     :Rtype:
         `QIcon`
     """
     if self.status == self.FILE_NOT_WRITABLE:
         return QIcon(":images/images/lock")
     return QIcon()
コード例 #8
0
ファイル: project.py プロジェクト: tpDcc/tpDcc-libs-qt
    def set_image(self, encoded_image):

        from tpDcc.libs.qt.core import image

        if not encoded_image:
            return

        encoded_image = encoded_image.encode('utf-8')
        project_icon = QIcon(QPixmap.fromImage(image.base64_to_image(encoded_image)))
        if project_icon.isNull():
            project_icon = resources.icon('tpDcc')
        self.project_btn.setIcon(project_icon)
コード例 #9
0
def icon(*args, **kwargs):
    """
    Returns icon
    :param args: list
    :param kwargs: kwargs
    :return: QIcon
    """

    if not _RESOURCES:
        return QIcon()

    return get(resource_type=ResourceTypes.ICON, *args, **kwargs) or QIcon()
コード例 #10
0
ファイル: find_dialog.py プロジェクト: Passion-7/usdmanager
 def setupUi(self, widget):
     """
     Creates and lays out the widgets defined in the ui file.
     
     :Parameters:
         widget : `QtWidgets.QWidget`
             Base widget
     """
     super(FindDialog, self).setupUi(widget)
     self.statusBar = QStatusBar(self)
     self.verticalLayout.addWidget(self.statusBar)
     self.findBtn.setIcon(QIcon.fromTheme("edit-find"))
     self.replaceBtn.setIcon(QIcon.fromTheme("edit-find-replace"))
コード例 #11
0
    def setupUi(self, widget):
        """
        Creates and lays out the widgets defined in the ui file.
        
        :Parameters:
            widget : `QtGui.QWidget`
                Base widget
        """
        #super(PreferencesDialog, self).setupUi(widget) # TODO: Switch back to this if we get loadUiType working.
        self.baseInstance = loadUiWidget("preferences_dialog.ui", self)
        self.setWindowIcon(QIcon.fromTheme("preferences-system"))
        self.buttonFont.setIcon(QIcon.fromTheme("preferences-desktop-font"))
        self.buttonNewProg.setIcon(QIcon.fromTheme("list-add"))

        # ----- General tab -----
        # Set initial preferences.
        parent = self.parent()
        self.checkBox_parseLinks.setChecked(parent.preferences['parseLinks'])
        self.checkBox_newTab.setChecked(parent.preferences['newTab'])
        self.checkBox_syntaxHighlighting.setChecked(
            parent.preferences['syntaxHighlighting'])
        self.checkBox_teletypeConversion.setChecked(
            parent.preferences['teletype'])
        self.checkBox_lineNumbers.setChecked(parent.preferences['lineNumbers'])
        self.checkBox_showAllMessages.setChecked(
            parent.preferences['showAllMessages'])
        self.checkBox_showHiddenFiles.setChecked(
            parent.preferences['showHiddenFiles'])
        self.checkBox_autoCompleteAddressBar.setChecked(
            parent.preferences['autoCompleteAddressBar'])
        self.useSpacesCheckBox.setChecked(parent.preferences['useSpaces'])
        self.useSpacesSpinBox.setValue(parent.preferences['tabSpaces'])
        self.lineEditTextEditor.setText(parent.preferences['textEditor'])
        self.lineEditDiffTool.setText(parent.preferences['diffTool'])
        self.updateFontLabel()

        # ----- Programs tab -----
        self.progLayout = QVBoxLayout()
        self.extLayout = QVBoxLayout()

        # Extensions can only be: <optional .><alphanumeric><optional comma><optional space>
        #self.progValidator = QRegExpValidator(QRegExp("[\w,. ]+"), self)
        self.extValidator = QRegExpValidator(QRegExp(r"(?:\.?\w*,?\s*)+"),
                                             self)
        self.lineEdit.setValidator(self.extValidator)

        # Create the fields for programs and extensions.
        self.populateProgsAndExts(parent.programs)
コード例 #12
0
    def add_files(self, filenames):
        """add filenames (list(str)) to the table"""
        for f in filenames:
            row = self.table.rowCount()
            self.table.insertRow(row)

            file_item = QTableWidgetItem()
            file_item.setData(Qt.DisplayRole, f)
            self.table.setItem(row, 0, file_item)

            widget_that_lets_me_horizontally_align_an_icon = QWidget()
            widget_layout = QHBoxLayout(
                widget_that_lets_me_horizontally_align_an_icon)
            section_remove = QLabel()
            dim = int(1.5 *
                      section_remove.fontMetrics().boundingRect("Z").height())
            section_remove.setPixmap(
                QIcon(section_remove.style().standardIcon(
                    QStyle.SP_DialogDiscardButton)).pixmap(dim, dim))
            widget_layout.addWidget(section_remove, 0, Qt.AlignHCenter)
            widget_layout.setContentsMargins(0, 0, 0, 0)
            self.table.setCellWidget(
                row, 1, widget_that_lets_me_horizontally_align_an_icon)

        self.add_last_row()
コード例 #13
0
    def add_conf_group(self, conf_group_widget):
        row = conf_group_widget.childCount()

        conformer_item = QTreeWidgetItem(conf_group_widget)
        conf_group_widget.insertChild(row, conformer_item)

        nrg_combobox = FilereaderComboBox(self.session, otherItems=['energy'])
        nrg_combobox.currentIndexChanged.connect(
            lambda *args: self.changes.emit())
        freq_combobox = FilereaderComboBox(self.session,
                                           otherItems=['frequency'])
        freq_combobox.currentIndexChanged.connect(
            lambda *args: self.changes.emit())

        trash_button = QPushButton()
        trash_button.setFlat(True)
        trash_button.clicked.connect(
            lambda *args, combobox=nrg_combobox: combobox.deleteLater())
        trash_button.clicked.connect(
            lambda *args, combobox=freq_combobox: combobox.deleteLater())
        trash_button.clicked.connect(lambda *args, child=conformer_item:
                                     conf_group_widget.removeChild(child))
        trash_button.clicked.connect(lambda *args: self.changes.emit())
        trash_button.setIcon(
            QIcon(self.style().standardIcon(QStyle.SP_DialogCancelButton)))

        self.tree.setItemWidget(conformer_item, 0, nrg_combobox)
        self.tree.setItemWidget(conformer_item, 1, freq_combobox)
        self.tree.setItemWidget(conformer_item, 2, trash_button)

        self.changes.emit()
コード例 #14
0
    def initUI(self):

        searchEdit = QLineEdit()
        grid = QGridLayout()
        grid.setSpacing(10)

        grid.addWidget(searchEdit, 1, 0)

        self.list = QListView()
        # Create an empty model for the list's data
        model = QStandardItemModel(self.list)

        for gameName, gameId in self.Games.items():
            game = QStandardItem(gameName)
            game.setEditable(False)
            model.appendRow(game)

        self.list.doubleClicked.connect(self.OnDoubleClick) # Launch Game
        # Apply the model to the list view
        self.list.setModel(model)
        self.list.setCurrentIndex(self.list.model().index(0, 0)) # Show the window and run the app

        grid.addWidget(self.list, 2, 0)

        self.setLayout(grid)

        self.setGeometry(300, 300, 350, 300)
        self.setWindowTitle('pySteamLauncher')
        self.setWindowIcon(QIcon('logo.png'))
        self.show()
コード例 #15
0
ファイル: item.py プロジェクト: tpDcc/tpDcc-tools-datalibrary
    def setIcon(self, column, icon, color=None):
        """
        Overrides base QTreeWidgetItem setIcon function
        :param column: int or str
        :param icon: QIcon
        :param color: QColor or None
        """

        is_app_running = bool(QApplication.instance())
        if not is_app_running:
            return

        if python.is_string(icon):
            if not os.path.exists(icon):
                color = color or QColor(255, 255, 255, 20)
                icon = resources.icon('image', color=color)
            else:
                icon = QIcon(icon)
        if python.is_string(column):
            self._icon[column] = icon
        else:
            self._pixmap[column] = None
            super(ItemView, self).setIcon(column, icon)

        self.update_icon()
コード例 #16
0
ファイル: image.py プロジェクト: tpDcc/tpDcc-libs-qt
    def current_icon(self):
        """
        Returns the current frames as QIcon
        :return: QIcon
        """

        return QIcon(self.current_filename())
コード例 #17
0
    def icon(self, *names, **kwargs):
        """Return a QIcon object corresponding to the provided icon name."""
        options_list = kwargs.pop('options', [{}] * len(names))
        general_options = kwargs

        if len(options_list) != len(names):
            error = '"options" must be a list of size {0}'.format(len(names))
            raise Exception(error)

        if QApplication.instance() is not None:
            parsed_options = []
            for i in range(len(options_list)):
                specific_options = options_list[i]
                parsed_options.append(self._parse_options(specific_options,
                                                          general_options,
                                                          names[i]))

            # Process high level API
            api_options = parsed_options

            return self._icon_by_painter(self.painter, api_options)
        else:
            warnings.warn("You need to have a running "
                          "QApplication to use QtAwesome!")
            return QIcon()
コード例 #18
0
ファイル: item.py プロジェクト: tpDcc/tpDcc-tools-datalibrary
    def default_thumbnail_icon(self):
        """
        Returns the default thumbnail icon
        :return: QIcon
        """

        return QIcon(self.default_thumbnail_path())
コード例 #19
0
ファイル: search.py プロジェクト: tpDcc/tpDcc-libs-qt
    def __init__(self, search_line=None, parent=None):
        super(SearchFindWidget, self).__init__(parent=parent)

        self.setObjectName('SearchFindWidget')

        self.text = ''
        self._placeholder_text = ''

        main_layout = layouts.HorizontalLayout(spacing=2, margins=(2, 2, 2, 2))
        self.setLayout(main_layout)

        self._search_line = search_line or QLineEdit(self)
        self._search_menu = QMenu()
        self._search_menu.addAction('Test')

        icon_size = self.style().pixelMetric(QStyle.PM_SmallIconSize)

        delete_icon = resources.icon('delete')
        search_icon = QIcon(resources.icon('search'))

        self._clear_btn = buttons.IconButton(delete_icon,
                                             icon_padding=2,
                                             parent=self)
        self._clear_btn.setIconSize(QSize(icon_size, icon_size))
        self._clear_btn.setFixedSize(QSize(icon_size, icon_size))
        self._clear_btn.hide()

        self._search_btn = buttons.IconButton(search_icon,
                                              icon_padding=2,
                                              parent=self)
        self._search_btn.setIconSize(QSize(icon_size, icon_size))
        self._search_btn.setFixedSize(QSize(icon_size, icon_size))
        # self._search_btn.setStyleSheet('border: none;')
        # self._search_btn.setPopupMode(QToolButton.InstantPopup)
        self._search_btn.setEnabled(True)

        self._search_line.setStyleSheet("""
            QLineEdit { padding-left: %spx; padding-right: %spx; border-radius:10px; border:2px; border-color:red; }
            """ % (self._search_button_padded_width(),
                   self._clear_button_padded_width()))
        self._search_line.setMinimumSize(
            max(
                self._search_line.minimumSizeHint().width(),
                self._clear_button_padded_width() +
                self._search_button_padded_width()),
            max(
                self._search_line.minimumSizeHint().height(),
                max(self._clear_button_padded_width(),
                    self._search_button_padded_width())))

        main_layout.addWidget(self._search_line)

        self._search_line.setFocus()

        self._search_line.textChanged.connect(self.textChanged)
        self._search_line.textChanged.connect(self.set_text)
        # self._search_line.editingFinished.connect(self.editingFinished)
        # self._search_line.returnPressed.connect(self.returnPressed)
        self._clear_btn.clicked.connect(self.clear)
        self._search_btn.clicked.connect(self._popup_menu)
コード例 #20
0
 def _custom_icon(self, name, **kwargs):
     """Return the custom icon corresponding to the given name."""
     options = dict(_default_options, **kwargs)
     if name in self.painters:
         painter = self.painters[name]
         return self._icon_by_painter(painter, options)
     else:
         return QIcon()
コード例 #21
0
ファイル: main.py プロジェクト: mrals2018/QtExamples
def main():
    import sys

    QGuiApplication.setApplicationName("Automotive")
    QGuiApplication.setOrganizationName("QtProject")
    QGuiApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
    QGuiApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)

    app = QGuiApplication(sys.argv)

    QIcon.setThemeName("automotive")

    engine = QQmlApplicationEngine()
    engine.load(QUrl("qrc:/qml/automotive.qml"))
    if not engine.rootObjects():
        sys.exit(-1)

    sys.exit(app.exec_())
コード例 #22
0
    def set_image(self, encoded_image):

        from tpDcc.libs.qt.core import image

        if not encoded_image:
            return

        encoded_image = encoded_image.encode('utf-8')
        self.project_btn.setIcon(
            QIcon(QPixmap.fromImage(image.base64_to_image(encoded_image))))
コード例 #23
0
ファイル: pyxpad.py プロジェクト: ZedThree/pyxpad
    def __init__(self, mainwindow):
        self.main = mainwindow
        self.main.sourceDescription.stateChanged.connect(self.updateDisplay)

        self.groupIcon = QIcon()
        self.groupIcon.addPixmap(
            mainwindow.style().standardPixmap(QStyle.SP_DirClosedIcon),
            QIcon.Normal,
            QIcon.Off,
        )
        self.groupIcon.addPixmap(
            mainwindow.style().standardPixmap(QStyle.SP_DirOpenIcon),
            QIcon.Normal,
            QIcon.On,
        )
        self.keyIcon = QIcon()
        self.keyIcon.addPixmap(mainwindow.style().standardPixmap(
            QStyle.SP_FileIcon))

        self.main.treeView.itemSelectionChanged.connect(self.updateDisplay)
        self.main.tracePattern.textChanged.connect(self.updateDisplay)
        self.main.availableSignals.stateChanged.connect(self.updateDisplay)
        self.main.treeView.setContextMenuPolicy(
            Qt.CustomContextMenu)  # Enable popup menus

        # Context menu
        self.main.treeView.customContextMenuRequested.connect(
            self.handlePopupMenu)

        # Context menu actions
        self.actionAdd = QAction("Add",
                                 self.main,
                                 statusTip="Add a new source")

        self.actionDelete = QAction("Delete",
                                    self.main,
                                    statusTip="Remove source from tree")
        self.actionDelete.triggered.connect(self.deleteSource)

        self.actionConfig = QAction("Configure",
                                    self.main,
                                    statusTip="Configure source")
        self.actionConfig.triggered.connect(self.configureSource)
コード例 #24
0
    def set_icon_path(self, path):
        """
        Sets the icon path to be used for the thumbnail
        :param path: str
        """

        self._icon_path = path
        icon = QIcon(QPixmap(path))
        self.set_icon(icon)
        self.update_thumbnail_size()
        self.item().update()
コード例 #25
0
ファイル: image.py プロジェクト: tpDcc/tpDcc-libs-qt
def base64_to_icon(base64_string, icon_format='PNG'):
    """
    Converts base64 to QIcon
    :param base64_string: str
    :param icon_format: str
    :return: QIcon
    """

    bitmap = base64_to_bitmap(base64_string, icon_format)
    if bitmap is not None:
        icon = QIcon(bitmap)
        return icon
コード例 #26
0
ファイル: item.py プロジェクト: tpDcc/tpDcc-tools-datalibrary
    def _on_thumbnail_from_image(self, image):
        """
        Internal callback function that is called when an image object has finished loading
        """

        self.clear_cache()
        pixmap = QPixmap()
        pixmap.convertFromImage(image)
        icon = QIcon(pixmap)
        self._thumbnail_icon = icon
        if self.viewer():
            self.viewer().update()
コード例 #27
0
    def initOtherButtons(self, flags):
        # other action buttons
        if len(self.button_list) != 0:
            self.separator1 = QFrame(self)
            self.separator1.setFrameShape(QFrame.VLine)
            self.separator1.setFrameShadow(QFrame.Sunken)
            self.hlayout.addWidget(self.separator1)

            self.undoButton = QPushButton(self)
            self.undoButton.setIcon(QIcon(":/resource/icon/undo.png"))
            self.undoButton.setFixedSize(self.iconWidth, self.iconWidth)
            self.undoButton.clicked.connect(self.otherButtonsClicked)
            self.hlayout.addWidget(self.undoButton)

        if flags & constant.SAVE_TO_FILE:
            self.saveButton = QPushButton(self)
            self.saveButton.setIcon(QIcon(":/resource/icon/save.png"))
            self.saveButton.setFixedSize(self.iconWidth, self.iconHeight)
            self.saveButton.clicked.connect(self.otherButtonsClicked)
            self.hlayout.addWidget(self.saveButton)

        self.separator2 = QFrame(self)
        self.separator2.setFrameShape(QFrame.VLine)
        self.separator2.setFrameShadow(QFrame.Sunken)
        self.hlayout.addWidget(self.separator2)

        self.cancelButton = QPushButton(self)
        self.cancelButton.setIcon(QIcon(":/resource/icon/close.png"))
        self.cancelButton.setFixedSize(self.iconWidth, self.iconHeight)
        self.cancelButton.clicked.connect(self.otherButtonsClicked)

        if flags & constant.CLIPBOARD:
            self.okButton = QPushButton(self)
            self.okButton.setIcon(QIcon(":/resource/icon/check.png"))
            self.okButton.setFixedSize(self.iconWidth, self.iconHeight)
            self.okButton.clicked.connect(self.otherButtonsClicked)
            self.hlayout.addWidget(self.okButton)

        self.hlayout.addWidget(self.cancelButton)
コード例 #28
0
    def initDrawButtons(self, flags):
        self.drawButtonGroup = QButtonGroup(self)

        # draw action buttons
        if flags & constant.RECT:
            self.rectButton = QPushButton(self)
            self.rectButton.setIcon(QIcon(":/resource/icon/rect.png"))
            self.rectButton.setFixedSize(self.iconWidth, self.iconHeight)
            self.rectButton.setCheckable(True)
            self.drawButtonGroup.addButton(self.rectButton)
            self.hlayout.addWidget(self.rectButton)
            self.button_list.append(self.rectButton)

        if flags & constant.ELLIPSE:
            self.ellipseButton = QPushButton(self)
            self.ellipseButton.setIcon(QIcon(":/resource/icon/ellipse.png"))
            self.ellipseButton.setFixedSize(self.iconWidth, self.iconHeight)
            self.ellipseButton.setCheckable(True)
            self.drawButtonGroup.addButton(self.ellipseButton)
            self.hlayout.addWidget(self.ellipseButton)
            self.button_list.append(self.ellipseButton)

        if flags & constant.ARROW:
            self.arrowButton = QPushButton(self)
            self.arrowButton.setIcon(QIcon(":/resource/icon/arrow.png"))
            self.arrowButton.setFixedSize(self.iconWidth, self.iconHeight)
            self.arrowButton.setCheckable(True)
            self.drawButtonGroup.addButton(self.arrowButton)
            self.hlayout.addWidget(self.arrowButton)
            self.button_list.append(self.arrowButton)

        if flags & constant.LINE:
            self.lineButton = QPushButton(self)
            self.lineButton.setIcon(QIcon(":/resource/icon/line.png"))
            self.lineButton.setFixedSize(self.iconWidth, self.iconHeight)
            self.lineButton.setCheckable(True)
            self.drawButtonGroup.addButton(self.lineButton)
            self.hlayout.addWidget(self.lineButton)
            self.button_list.append(self.lineButton)

        if flags & constant.FREEPEN:
            self.freePenButton = QPushButton(self)
            self.freePenButton.setIcon(QIcon(":/resource/icon/pen.png"))
            self.freePenButton.setFixedSize(self.iconWidth, self.iconHeight)
            self.freePenButton.setCheckable(True)
            self.drawButtonGroup.addButton(self.freePenButton)
            self.hlayout.addWidget(self.freePenButton)
            self.button_list.append(self.freePenButton)

        if flags & constant.TEXT:
            self.textButton = QPushButton(self)
            self.textButton.setIcon(QIcon(":/resource/icon/text.png"))
            self.textButton.setFixedSize(self.iconWidth, self.iconHeight)
            self.textButton.setCheckable(True)
            self.drawButtonGroup.addButton(self.textButton)
            self.hlayout.addWidget(self.textButton)
            self.button_list.append(self.textButton)

        self.drawButtonGroup.buttonClicked.connect(self.buttonToggled)
コード例 #29
0
ファイル: item.py プロジェクト: tpDcc/tpDcc-tools-datalibrary
    def _thumbnail_from_image(self, image):
        """
        Called after the given image object has finished loading
        :param image: QImage
        """

        self.clear_cache()
        pixmap = QPixmap()
        pixmap.convertFromImage(image)
        icon = QIcon(pixmap)
        self._thumbnail_icon = icon
        if self.viewer():
            self.viewer().update()
コード例 #30
0
def add_ligand(tool):
    rows = tool.ligand_table.rowCount()
    if rows != 0:
        rows -= 1
        ligand_name = QTableWidgetItem()
        name = "<click to choose>"
        is_c2 = Qt.Unchecked
        enabled = True
        if rows > 0:
            name = tool.ligand_table.item(rows - 1, 0).text()
            is_c2 = tool.ligand_table.cellWidget(rows - 1, 1).layout().itemAt(0).widget().checkState()
            enabled = tool.ligand_table.cellWidget(rows - 1, 1).layout().itemAt(0).widget().isEnabled()

        ligand_name.setData(Qt.DisplayRole, name)
        tool.ligand_table.setItem(rows, 0, ligand_name)
        
        widget_that_lets_me_horizontally_align_a_checkbox = QWidget()
        widget_layout = QHBoxLayout(widget_that_lets_me_horizontally_align_a_checkbox)
        c2 = QCheckBox()
        c2.setEnabled(enabled)
        c2.setCheckState(is_c2)
        widget_layout.addWidget(c2, 0, Qt.AlignHCenter)
        widget_layout.setContentsMargins(0, 0, 0, 0)
        tool.ligand_table.setCellWidget(
            rows, 1, widget_that_lets_me_horizontally_align_a_checkbox
        )
        
        widget_that_lets_me_horizontally_align_an_icon = QWidget()
        widget_layout = QHBoxLayout(widget_that_lets_me_horizontally_align_an_icon)
        section_remove = QLabel()
        dim = int(1.5 * section_remove.fontMetrics().boundingRect("Q").height())
        section_remove.setPixmap(
            QIcon(section_remove.style().standardIcon(
                QStyle.SP_DialogDiscardButton)
            ).pixmap(dim, dim)
        )
        widget_layout.addWidget(section_remove, 0, Qt.AlignHCenter)
        widget_layout.setContentsMargins(0, 0, 0, 0)
        tool.ligand_table.setCellWidget(
            rows, 2, widget_that_lets_me_horizontally_align_an_icon
        )
        rows += 1

    tool.ligand_table.insertRow(rows)

    widget_that_lets_me_horizontally_align_an_icon = QWidget()
    widget_layout = QHBoxLayout(widget_that_lets_me_horizontally_align_an_icon)
    ligand_add = QLabel("add ligand")
    widget_layout.addWidget(ligand_add, 0, Qt.AlignHCenter)
    widget_layout.setContentsMargins(0, 0, 0, 0)
    tool.ligand_table.setCellWidget(rows, 1, widget_that_lets_me_horizontally_align_an_icon)
コード例 #31
0
ファイル: find_dialog.py プロジェクト: Passion-7/usdmanager
 def updateForEditMode(self, edit):
     """
     Show/Hide text replacement options based on if we are editing or not.
     If editing, allow replacement of the found text.
     
     :Parameters:
         edit : `bool`
             If in edit mode or not
     """
     self.replaceLabel.setVisible(edit)
     self.replaceLineEdit.setVisible(edit)
     self.replaceBtn.setVisible(edit)
     self.replaceFindBtn.setVisible(edit)
     self.replaceAllBtn.setVisible(edit)
     self.replaceAllOpenBtn.setVisible(edit)
     self.buttonBox.setVisible(edit)
     self.buttonBox2.setVisible(not edit)
     if edit:
         self.setWindowTitle("Find/Replace")
         self.setWindowIcon(QIcon.fromTheme("edit-find-replace"))
     else:
         self.setWindowTitle("Find")
         self.setWindowIcon(QIcon.fromTheme("edit-find"))
コード例 #32
0
ファイル: pyxpad.py プロジェクト: ZedThree/pyxpad
class Sources:
    sources = []  # List of sources

    def __init__(self, mainwindow):
        self.main = mainwindow
        self.main.sourceDescription.stateChanged.connect(self.updateDisplay)

        self.groupIcon = QIcon()
        self.groupIcon.addPixmap(mainwindow.style().standardPixmap(QStyle.SP_DirClosedIcon),
                                 QIcon.Normal, QIcon.Off)
        self.groupIcon.addPixmap(mainwindow.style().standardPixmap(QStyle.SP_DirOpenIcon),
                                 QIcon.Normal, QIcon.On)
        self.keyIcon = QIcon()
        self.keyIcon.addPixmap(mainwindow.style().standardPixmap(QStyle.SP_FileIcon))

        self.main.treeView.itemSelectionChanged.connect(self.updateDisplay)
        self.main.tracePattern.returnPressed.connect(self.updateDisplay)
        self.main.treeView.setContextMenuPolicy(Qt.CustomContextMenu)  # Enable popup menus

        # Context menu
        self.main.treeView.customContextMenuRequested.connect(self.handlePopupMenu)

        # Context menu actions
        self.actionAdd = QAction("Add", self.main, statusTip="Add a new source")

        self.actionDelete = QAction("Delete", self.main, statusTip="Remove source from tree")
        self.actionDelete.triggered.connect(self.deleteSource)

        self.actionConfig = QAction("Configure", self.main, statusTip="Configure source")
        self.actionConfig.triggered.connect(self.configureSource)

    def saveState(self, f):
        pickle.dump(self.sources, f)

    def loadState(self, f):
        try:
            sources = pickle.load(f)
        except EOFError:
            sources = []
        for s in sources:
            self.addSource(s)
        self.updateDisplay()

    def handlePopupMenu(self):
        """
        Called when user right-clicks on the sources tree
        """
        menu = QMenu()
        menu.addAction(self.actionAdd)

        selected = self.main.treeView.selectedItems()
        if len(selected) != 0:
            if 'config' in selected[0].source.__dict__:
                menu.addAction(self.actionConfig)
            menu.addAction(self.actionDelete)

        menu.exec_(QCursor.pos())

    def addNetCDF(self):
        """
        Add a NetCDF file as a data source
        """
        try:
            from pyxpad.datafile import NetCDFDataSource
        except ImportError:
            self.main.write("Sorry, no NetCDF support")
            return
        try:
            # Get the file name
            tr = self.main.tr
            fname, _ = QFileDialog.getOpenFileName(self.main, tr('Open file'), '.',
                                                   filter=tr("NetCDF files (*.nc *.cdl)"))
            if (fname is None) or (fname == ""):
                return  # Cancelled

            s = NetCDFDataSource(fname)

            self.addSource(s)
            self.updateDisplay()
        except:
            self.main.write("Error creating NetCDFDataSource")
            self.main.write(str(sys.exc_info()))

    def addXPADtree(self):
        try:
            from pyxpad.xpadsource import XPadSource
        except ImportError:
            self.main.write("Sorry, no XPAD tree support")
            self.main.write(str(sys.exc_info()))
            return

        try:
            # Select the directory
            tr = self.main.tr
            dname = QFileDialog.getExistingDirectory(self.main, tr('Open XPAD directory'),
                                                     QDir.currentPath())
            if (dname == "") or (dname is None):
                return
            # Create data source
            s = XPadSource(dname)

            # Add data source and update
            self.addSource(s)
            self.updateDisplay()
        except:
            self.main.write("Error creating XPadSource")
            self.main.write(str(sys.exc_info()))
            raise

    def addBOUT(self):
        """
        Add a BOUT++ directory source
        """
        try:
            from pyxpad.boutsource import BoutDataSource

            # Select the directory
            tr = self.main.tr
            dname = QFileDialog.getExistingDirectory(self.main, tr('Open BOUT++ directory'),
                                                     QDir.currentPath())
            if (dname == "") or (dname is None):
                return
            # Create data source
            s = BoutDataSource(dname)

            # Add data source and update
            self.addSource(s)
            self.updateDisplay()
        except:
            self.main.write("Sorry, no BOUT++ support")
            raise
            return

    def addSource(self, source):
        self.sources.append(source)
        it = QTreeWidgetItem(self.main.treeView, [source.label])
        it.setIcon(0, self.groupIcon)
        it.source = source
        self.main.treeView.addTopLevelItem(it)

        def buildtree(parent, it):
            # Check for children
            try:
                for child in parent.children:
                    itchild = QTreeWidgetItem(it, [child.label])
                    itchild.source = child
                    buildtree(child, itchild)  # Add child's children
                    it.addChild(itchild)
            except AttributeError:
                # Probably no children
                return

        buildtree(source, it)

    def deleteSource(self):
        tree = self.main.treeView
        selected = tree.selectedItems()
        if len(selected) == 0:
            return
        source = selected[0].source
        tree.takeTopLevelItem(tree.indexOfTopLevelItem(selected[0]))  # Remove from tree
        # Remove from list of sources
        i = self.sources.index(source)
        del self.sources[i]
        # Update the display
        self.updateDisplay()

    def configureSource(self):
        """
        Configure a data source, changing the source's
        'config' dictionary.
        """
        selected = self.main.treeView.selectedItems()
        if len(selected) == 0:
            return
        source = selected[0].source
        c = ConfigDialog(source.config, self.main)
        c.exec_()

    def updateDisplay(self):
        table = self.main.sourceTable
        # Find which source is selected, and update table view
        selected = self.main.treeView.selectedItems()
        if len(selected) == 0:
            table.clearContents()
            table.setRowCount(0)
            return
        s = selected[0].source

        # Check if any items selected
        selecteditems = table.selectedItems()
        selectedvars = []
        nextra = 0
        for item in selecteditems:
            if 'source' in item.__dict__:
                name = item.text()
                selectedvars.append((name, item.source))
                if item.source != s:
                    nextra += 1

        table.clearContents()  # Clear the table and selections

        pattern = self.main.tracePattern.text()
        if pattern == "":
            varNames = s.varNames
        else:
            # Filter the variable names
            varNames = [name for name in s.varNames
                        if fnmatch.fnmatch(name.lower(), pattern.lower())]

        varNames.sort(key=str.lower)

        if self.main.sourceDescription.isChecked():
            # Provide description for each variable (if available)

            table.setColumnCount(2)
            table.setRowCount(len(varNames) + nextra)
            table.setSelectionBehavior(QAbstractItemView.SelectRows)

            def addVar(name, source, selected=False):
                var = source.variables[name]
                item = QTableWidgetItem(name)
                item.source = source
                table.setItem(addVar.ind, 0, item)
                item.setSelected(selected)
                comment = var.desc
                if comment == "":
                    comment = var.label
                    if var.units != "":
                        comment += " ("+var.units+") "

                if var.dim:
                    try:
                        comment += " [" + ", ".join([str(v) for v in var.dim]) + "]"
                    except TypeError:
                        if str(var.dim):
                            comment += " [" + str(var.dim) + "]"
                item = QTableWidgetItem(comment)
                table.setItem(addVar.ind, 1, item)
                item.setSelected(selected)
                addVar.ind += 1
        else:
            # Just a list of variable names. Can use multiple columns
            maxrows = 20
            n = len(varNames) + nextra
            ncols = int(n / maxrows) + 1
            table.setColumnCount(ncols)
            table.setRowCount(min([n, maxrows]))
            table.setSelectionBehavior(QAbstractItemView.SelectItems)

            def addVar(name, source, selected=False):
                row = addVar.ind % maxrows
                col = int(addVar.ind / maxrows)
                item = QTableWidgetItem(name)
                item.source = source
                table.setItem(row, col, item)
                item.setSelected(selected)
                addVar.ind += 1

        addVar.ind = 0
        for name, source in selectedvars:
            addVar(name, source, True)
        sel = [name for name, source in selectedvars if source == s]
        for name in varNames:
            if name not in sel:
                addVar(name, s)

    def read(self):
        """
        Read the selected data and return as a list of data items

        Input
        -----
            None

        Returns
        ------
            [ XPadDataItem ]  or equivalent

        Modifies
        --------
            None
        """

        # Get list of shots
        shotlist = self.main.shotInput.text().split(',')

        table = self.main.sourceTable
        tableitems = table.selectedItems()
        data = []
        for item in tableitems:
            if 'source' in item.__dict__:
                name = item.text()

                for shot in shotlist:
                    s = "Reading " + name + " from " + item.source.label
                    if shot != "":
                        s += " shot = " + shot
                    self.main.write(s)
                    # Run in a sandbox to catch exceptions and display output
                    self.main.runSandboxed(lambda: data.append(item.source.read(name, shot)))

            else:
                print("Ignoring "+item.text())
        return data