当前位置: 首页>>代码示例>>Python>>正文


Python QtGui.QIcon方法代码示例

本文整理汇总了Python中PySide2.QtGui.QIcon方法的典型用法代码示例。如果您正苦于以下问题:Python QtGui.QIcon方法的具体用法?Python QtGui.QIcon怎么用?Python QtGui.QIcon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PySide2.QtGui的用法示例。


在下文中一共展示了QtGui.QIcon方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load_icon

# 需要导入模块: from PySide2 import QtGui [as 别名]
# 或者: from PySide2.QtGui import QIcon [as 别名]
def load_icon(fname_icon):
	path_this_file = os.path.abspath(__file__)
	path_this_dir = os.path.dirname(path_this_file)
	path_icons = os.path.join(path_this_dir, '..', 'media', 'icons')
	path_icon = os.path.join(path_icons, fname_icon)

	pixmap = QtGui.QPixmap(path_icon)

	#pixmap.fill(QtGui.QColor('red'))
	#pixmap.setMask(pixmap.createMaskFromColor(QtGui.QColor('black'), QtGui.Qt.MaskOutColor))

	icon = QtGui.QIcon()
	icon.addPixmap(pixmap, QtGui.QIcon.Normal)
	icon.addPixmap(pixmap, QtGui.QIcon.Disabled)

	return icon 
开发者ID:Vector35,项目名称:debugger,代码行数:18,代码来源:ControlsWidget.py

示例2: __init__

# 需要导入模块: from PySide2 import QtGui [as 别名]
# 或者: from PySide2.QtGui import QIcon [as 别名]
def __init__(self, widget):
		QMainWindow.__init__(self)
		#self.setWindowFlags(QtCore.Qt.CustomizeWindowHint)
		self.setWindowTitle("TileGAN")
		app_icon = QtGui.QIcon()
		app_icon.addFile(iconFolder + '/icon_tilegan_16x16.png', QtCore.QSize(16, 16))
		app_icon.addFile(iconFolder + '/icon_tilegan_24x24.png', QtCore.QSize(24, 24))
		app_icon.addFile(iconFolder + '/icon_tilegan_32x32.png', QtCore.QSize(32, 32))
		app_icon.addFile(iconFolder + '/icon_tilegan_48x48.png', QtCore.QSize(48, 48))
		app_icon.addFile(iconFolder + '/icon_tilegan_64x64.png', QtCore.QSize(64, 64))
		self.setWindowIcon(app_icon)

		## Exit Action
		exit_action = QAction("Exit", self)
		exit_action.setShortcut(QtGui.QKeySequence("Ctrl+Q"))#)
		exit_action.triggered.connect(self.exit_app)

		# Window dimensions
		self.setCentralWidget(widget)

		geometry = app.desktop().availableGeometry(self)
		self.resize(int(geometry.height() * 0.85), int(geometry.height() * 0.75)) 
开发者ID:afruehstueck,项目名称:tileGAN,代码行数:24,代码来源:tileGAN_client.py

示例3: createPullDown

# 需要导入模块: from PySide2 import QtGui [as 别名]
# 或者: from PySide2.QtGui import QIcon [as 别名]
def createPullDown(self, menu, eachPullDown):
        """create the submenu structure to method createMenus"""
        for name, tip, short, icon, handler in eachPullDown:

            if len(name) == 0:
                menu.addSeparator()
                continue

            icon = QtGui.QIcon(ICONS_S + icon)

            logger.debug('HANDLER: {}'.format(handler))

            if 'aboutQt' not in handler:
                handler = 'self.parent.slots.' + handler

            action = QtWidgets.QAction(icon, name, self.parent,
                                       shortcut=short, statusTip=tip,
                                       triggered=eval(handler))
            menu.addAction(action) 
开发者ID:chiefenne,项目名称:PyAero,代码行数:21,代码来源:MenusTools.py

示例4: createTools

# 需要导入模块: from PySide2 import QtGui [as 别名]
# 或者: from PySide2.QtGui import QIcon [as 别名]
def createTools(self):
        """create the toolbar and populate it automatically
         from  method toolData
        """
        # create a tool bar
        self.toolbar = self.parent.addToolBar('Toolbar')

        for tip, icon, handler in self.getToolbarData():
            if len(tip) == 0:
                self.toolbar.addSeparator()
                continue
            icon = QtGui.QIcon(ICONS_L + icon)
            action = QtWidgets.QAction(
                icon, tip, self.parent, triggered=eval(
                    'self.parent.slots.' + handler))
            self.toolbar.addAction(action) 
开发者ID:chiefenne,项目名称:PyAero,代码行数:18,代码来源:MenusTools.py

示例5: _get_application_icon

# 需要导入模块: from PySide2 import QtGui [as 别名]
# 或者: from PySide2.QtGui import QIcon [as 别名]
def _get_application_icon() -> QIcon:
        """
        This finds the running blender process, extracts the blender icon from the blender.exe file on disk and saves it to the user's temp folder.
        It then creates a QIcon with that data and returns it.

        Returns QIcon: Application Icon
        """

        icon_filepath = Path(__file__).parent / ".." / "blender_icon_16.png"
        icon = QIcon()

        if icon_filepath.exists():
            image = QImage(str(icon_filepath))
            if not image.isNull():
                icon = QIcon(QPixmap().fromImage(image))

        return icon 
开发者ID:techartorg,项目名称:bqt,代码行数:19,代码来源:blender_application.py

示例6: __init__

# 需要导入模块: from PySide2 import QtGui [as 别名]
# 或者: from PySide2.QtGui import QIcon [as 别名]
def __init__(self, main_window):
        super(FileToolbar, self).__init__(main_window, 'File')

        self.actions = [
            ToolbarAction(QIcon(os.path.join(IMG_LOCATION, 'toolbar-file-open.ico')),
                          "Open File", "Open a new file for analysis",
                          main_window.open_file_button,
                          ),
            ToolbarAction(QIcon(os.path.join(IMG_LOCATION, 'toolbar-docker-open.png')),
                          "Open Docker Target", "Open a file located within a docker image for analysis",
                          main_window.open_docker_button,
                          ),
            ToolbarAction(QIcon(os.path.join(IMG_LOCATION, 'toolbar-file-save.png')),
                          "Save", "Save angr database",
                          main_window.save_database,
                          ),
        ] 
开发者ID:angr,项目名称:angr-management,代码行数:19,代码来源:file_toolbar.py

示例7: main

# 需要导入模块: from PySide2 import QtGui [as 别名]
# 或者: from PySide2.QtGui import QIcon [as 别名]
def main():
    app = QApplication(sys.argv)

    app.setWindowIcon(QIcon(':/icons/app.svg'))

    fontDB = QFontDatabase()
    fontDB.addApplicationFont(':/fonts/Roboto-Regular.ttf')
    app.setFont(QFont('Roboto'))

    f = QFile(':/style.qss')
    f.open(QFile.ReadOnly | QFile.Text)
    app.setStyleSheet(QTextStream(f).readAll())
    f.close()

    translator = QTranslator()
    translator.load(':/translations/' + QLocale.system().name() + '.qm')
    app.installTranslator(translator)

    mw = MainWindow()
    mw.show()

    sys.exit(app.exec_()) 
开发者ID:gmarull,项目名称:pyside2-boilerplate,代码行数:24,代码来源:__main__.py

示例8: add_marker_from_svg

# 需要导入模块: from PySide2 import QtGui [as 别名]
# 或者: from PySide2.QtGui import QIcon [as 别名]
def add_marker_from_svg(file_path, marker_name, pixel_x=10, pixel_y=None,
                     isLSBFirst=False, isUpToDown=False):
    """adds a new marker bitmap from a vector graphic (svg)"""

    # get an icon from the svg rendered with the given pixel
    from PySide2 import QtCore, QtGui
    pixel_y = pixel_y or pixel_x
    icon = QtGui.QIcon(file_path)
    icon = QtGui.QBitmap(icon.pixmap(pixel_x, pixel_y))

    # create a XMP-icon
    buffer=QtCore.QBuffer()
    buffer.open(buffer.WriteOnly)
    icon.save(buffer,"XPM")
    buffer.close()

    # get a string from the XMP-icon
    ary = str(buffer.buffer(), "utf8")
    ary = ary.split("\n", 1)[1]
    ary = ary.replace('\n', "").replace('"', "").replace(";", "")
    ary = ary.replace("}", "").replace("#", "x").replace(".", " ")
    string = str.join("", ary.split(",")[3:])
    
    # add the new marker style
    setattr(coin.SoMarkerSet, marker_name, coin.SoMarkerSet.getNumDefinedMarkers())
    coin.SoMarkerSet.addMarker(getattr(coin.SoMarkerSet, marker_name), 
                               coin.SbVec2s([pixel_x, pixel_y]), string,
                               isLSBFirst, isUpToDown) 
开发者ID:coin3d,项目名称:pivy,代码行数:30,代码来源:utils.py

示例9: icon

# 需要导入模块: from PySide2 import QtGui [as 别名]
# 或者: from PySide2.QtGui import QIcon [as 别名]
def icon(self):
        return QtGui.QIcon(_coin_logo_pixmap) 
开发者ID:coin3d,项目名称:pivy,代码行数:4,代码来源:PyQuarterWidgetPlugin.py

示例10: _qt_binding

# 需要导入模块: from PySide2 import QtGui [as 别名]
# 或者: from PySide2.QtGui import QIcon [as 别名]
def _qt_binding(self):
        return _QtBinding(QApplication, QIcon, QAbstractSocket) 
开发者ID:mherrmann,项目名称:fbs,代码行数:4,代码来源:PySide2.py

示例11: icon

# 需要导入模块: from PySide2 import QtGui [as 别名]
# 或者: from PySide2.QtGui import QIcon [as 别名]
def icon(filename):
    return QtGui.QIcon(os.path.join(ICONDIR, 'resources', 'icons', filename)) 
开发者ID:luckylyk,项目名称:hotbox_designer,代码行数:4,代码来源:qtutils.py

示例12: _addAccountToWindow

# 需要导入模块: from PySide2 import QtGui [as 别名]
# 或者: from PySide2.QtGui import QIcon [as 别名]
def _addAccountToWindow(self, account, balance, resize_parent=False):
        wrapper_layout = QVBoxLayout()
        account_layout = QHBoxLayout()
        rows_layout = QVBoxLayout()
        address_layout = QHBoxLayout()
        account_label = QLabel(account)
        account_label.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
        copy_button = QPushButton()
        copy_button.setAutoFillBackground(True)
        copy_button.setIcon(QIcon('icons/copy.svg'))
        self.connect(copy_button, SIGNAL('clicked()'), lambda: self.copyAddress(account))
        address_layout.addWidget(account_label)
        address_layout.addWidget(copy_button)
        balance_label = QLabel('Balance: %.5f ethers' % balance)
        balance_label.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
        self.balance_widgets[account] = balance_label
        rows_layout.addLayout(address_layout)
        rows_layout.addWidget(balance_label)
        avatar = QLabel()
        img_filename = render_avatar(account)
        pixmap = QPixmap(img_filename)
        avatar.setPixmap(pixmap)
        account_layout.addWidget(avatar)
        account_layout.addLayout(rows_layout)
        wrapper_layout.addLayout(account_layout)
        wrapper_layout.addSpacing(20)
        self.accounts_layout.addLayout(wrapper_layout)

        if resize_parent:
            sizeHint = self.sizeHint()
            self.parentWidget().parentWidget().resize(QSize(sizeHint.width(), sizeHint.height() + 40)) 
开发者ID:PacktPublishing,项目名称:Hands-On-Blockchain-for-Python-Developers,代码行数:33,代码来源:account_widget.py

示例13: createCommandData

# 需要导入模块: from PySide2 import QtGui [as 别名]
# 或者: from PySide2.QtGui import QIcon [as 别名]
def createCommandData(self):
        """ Crete data for standard commands """

        model = QtGui.QStandardItemModel()

        # Add all command names and icon paths to the the model(model)
        for command in self.cmdDict:
            item = QtGui.QStandardItem(command)
            if os.path.isabs(self.cmdDict[command]['icon']) is True:
                iconPath = os.path.normpath(self.cmdDict[command]['icon'])
                item.setIcon(QtGui.QIcon(iconPath))
            else:
                item.setIcon(
                    QtGui.QIcon(":%s" % self.cmdDict[command]['icon']))
            module = QtGui.QStandardItem(self.cmdDict[command]['module'])
            module.setTextAlignment(
                QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
            font = module.font()
            font.setItalic(True)
            font.setPointSize(11)
            module.setFont(font)
            item.setEditable(False)
            module.setEditable(False)
            model.appendRow([item, module])

        # Store the model(model) into the sortFilterProxy model
        self.filteredModel = QtCore.QSortFilterProxyModel(self)
        self.filteredModel.setFilterCaseSensitivity(QtCore.Qt.CaseInsensitive)
        self.filteredModel.setSourceModel(model) 
开发者ID:minoue,项目名称:rush,代码行数:31,代码来源:Rush.py

示例14: createHistoryData

# 需要导入模块: from PySide2 import QtGui [as 别名]
# 或者: from PySide2.QtGui import QIcon [as 别名]
def createHistoryData(self):
        """ Create data for history list """

        # History model
        self.historyList = self.history.read()
        self.historyModel = QtGui.QStandardItemModel()

        for command in self.historyList:

            # Capitalize the first letter of the command
            displayName = command[:1].capitalize() + command[1:]

            # If a command dosen't exist in the history list,
            # for some reason(eg. command renamed), do nothing.
            if displayName not in self.cmdDict:
                continue

            item = QtGui.QStandardItem(displayName)
            if os.path.isabs(self.cmdDict[displayName]['icon']) is True:
                iconPath = os.path.normpath(self.cmdDict[displayName]['icon'])
                item.setIcon(QtGui.QIcon(iconPath))
            else:
                item.setIcon(
                    QtGui.QIcon(":%s" % self.cmdDict[displayName]['icon']))
            module = QtGui.QStandardItem("History")
            module.setTextAlignment(
                QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
            font = module.font()
            font.setItalic(True)
            font.setPointSize(11)
            module.setFont(font)
            item.setEditable(False)
            module.setEditable(False)
            self.historyModel.appendRow([item, module])

        # Store the model(model) into the sortFilterProxy model
        self.historyFilteredModel = QtCore.QSortFilterProxyModel(self)
        self.historyFilteredModel.setFilterCaseSensitivity(
            QtCore.Qt.CaseInsensitive)
        self.historyFilteredModel.setSourceModel(self.historyModel) 
开发者ID:minoue,项目名称:rush,代码行数:42,代码来源:Rush.py

示例15: redraw_buttons

# 需要导入模块: from PySide2 import QtGui [as 别名]
# 或者: from PySide2.QtGui import QIcon [as 别名]
def redraw_buttons(ui) -> None:
    deck_id = _deck_id(ui)
    current_tab = ui.pages.currentWidget()
    buttons = current_tab.findChildren(QtWidgets.QToolButton)
    for button in buttons:
        button.setText(api.get_button_text(deck_id, _page(ui), button.index))
        button.setIcon(QIcon(api.get_button_icon(deck_id, _page(ui), button.index))) 
开发者ID:timothycrosley,项目名称:streamdeck-ui,代码行数:9,代码来源:gui.py


注:本文中的PySide2.QtGui.QIcon方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。