How to use the qtpy.QtGui.QIcon function in QtPy

To help you get started, we’ve selected a few QtPy 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 spyder-ide / spyder / spyder / app / restart.py View on Github external
else:
            os.environ['QT_SCREEN_SCALE_FACTORS'] = factors
    else:
        os.environ['QT_SCALE_FACTOR'] = ''
        os.environ['QT_SCREEN_SCALE_FACTORS'] = ''

    # Splash screen
    # -------------------------------------------------------------------------
    # Start Qt Splash to inform the user of the current status
    app = qapplication()
    restarter = Restarter()

    if PYQT5:
        APP_ICON = QIcon(get_image_path("spyder.svg"))
    else:
        APP_ICON = QIcon(get_image_path("spyder.png"))
    app.setWindowIcon(APP_ICON)
    restarter.set_splash_message(_('Closing Spyder'))

    # Get variables
    # Note: Variables defined in app/mainwindow.py 'restart()' method
    spyder_args = os.environ.pop('SPYDER_ARGS', None)
    pid = os.environ.pop('SPYDER_PID', None)
    is_bootstrap = os.environ.pop('SPYDER_IS_BOOTSTRAP', None)
    reset = os.environ.pop('SPYDER_RESET', None)

    # Get the spyder base folder based on this file
    this_folder = osp.split(osp.dirname(osp.abspath(__file__)))[0]
    spyder_folder = osp.split(this_folder)[0]

    if not any([spyder_args, pid, is_bootstrap, reset]):
        error = "This script can only be called from within a Spyder instance"
github tlambert03 / llspy-slm / slmgen / slmwindow.py View on Github external
def main():
    import sys

    APP = QtWidgets.QApplication(sys.argv)

    version = "0.1.0"
    appicon = QtGui.QIcon(getAbsoluteResourcePath("img/slmgen_logo.png"))
    APP.setWindowIcon(appicon)
    # register icon with windows
    if sys.platform.startswith("win32"):
        import ctypes

        myappid = "llspy.slmgen." + version
        ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)

    main = SLMdialog()
    main.show()

    # instantiate the execption handler
    exceptionHandler = ExceptionHandler()
    sys.excepthook = exceptionHandler.handler
    exceptionHandler.errorMessage.connect(main.show_error_window)
github smathot / OpenSesame / libqtopensesame / misc / theme.py View on Github external
type:	QIcon
		"""

		if isinstance(icon, QtGui.QIcon):
			return icon
		if os.path.isfile(icon):
			qicon = QtGui.QIcon()
			if icon.endswith(u'_large.png'):
				size = 32
			else:
				size = 16
			qicon.addFile(icon, size=QtCore.QSize(size, size))
			return qicon
		if hasattr(self, u'experiment') and (u'%s_large.png' % icon in \
			self.experiment.resources or '%s.png' in self.experiment.resources):
			qicon = QtGui.QIcon()
			if u'%s_large.png' % icon in self.experiment.resources:
				qicon.addFile(self.experiment.resource(
					u'%s_large.png' % icon), size=QtCore.QSize(32,32))
			if u'%s.png' % icon in self.experiment.resources:
				qicon.addFile(self.experiment.resource(u'%s.png' % icon),
					size=QtCore.QSize(16,16))
			return qicon
		if icon in self.icon_map:
			name = self.icon_map[icon][0]
		else:
			name = icon
		icon = QtGui.QIcon.fromTheme(name, self.fallback_icon)
		if icon.name() != name:
			oslogger.warning(u'missing icon %s' % name)
		return icon
github vnpy / vnpy / vnpy / trader / uiQt.py View on Github external
try:
            import qdarkstyle
            qApp.setStyleSheet(qdarkstyle.load_stylesheet_from_environment())
        except ImportError:
            pass
        
    # 设置Windows底部任务栏图标
    if 'Windows' in platform.uname():
        import ctypes
        ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID('vn.trader')  
    
    # 设置Qt字体
    qApp.setFont(BASIC_FONT)
    
    # 设置Qt图标
    qApp.setWindowIcon(QtGui.QIcon(loadIconPath('vnpy.ico')))
    
    # 返回创建好的QApp对象
    return qApp
github pyCGNS / pyCGNS / CGNS / NAV / wfingerprint.py View on Github external
def initClassConstants(cls):
        for ik in cls.ICONMAPPING:
            cls._icons[ik] = QIcon(QPixmap(cls.ICONMAPPING[ik]))
        cls._title[cls.VIEW_CONTROL] = 'Control'
        cls._title[cls.VIEW_OPTION] = 'Options'
        cls._title[cls.VIEW_TOOLS] = 'Tools'
        cls._busyx = QCursor(QPixmap(":/images/icons/cgSpy.png"))
github Ulm-IQO / qudi / gui / confocal / confocalgui_quphot.py View on Github external
self._mw.depth_ViewWidget.sigMouseAreaSelected.connect(self.zoom_depth_scan)

        # Blink correction
        self._mw.actionBlink_correction_view.triggered.connect(self.blink_correction_clicked)

        ###################################################################
        #               Icons for the scan actions                        #
        ###################################################################

        self._scan_xy_single_icon = QtGui.QIcon()
        self._scan_xy_single_icon.addPixmap(
            QtGui.QPixmap("artwork/icons/qudiTheme/22x22/scan-xy-start.png"),
            QtGui.QIcon.Normal,
            QtGui.QIcon.Off)

        self._scan_depth_single_icon = QtGui.QIcon()
        self._scan_depth_single_icon.addPixmap(
            QtGui.QPixmap("artwork/icons/qudiTheme/22x22/scan-depth-start.png"),
            QtGui.QIcon.Normal,
            QtGui.QIcon.Off)

        self._scan_xy_loop_icon = QtGui.QIcon()
        self._scan_xy_loop_icon.addPixmap(
            QtGui.QPixmap("artwork/icons/qudiTheme/22x22/scan-xy-loop.png"),
            QtGui.QIcon.Normal,
            QtGui.QIcon.Off)

        self._scan_depth_loop_icon = QtGui.QIcon()
        self._scan_depth_loop_icon.addPixmap(
            QtGui.QPixmap("artwork/icons/qudiTheme/22x22/scan-depth-loop.png"),
            QtGui.QIcon.Normal,
            QtGui.QIcon.Off)
github glue-viz / glue / glue / viewers / common / qt / toolbar.py View on Github external
def _make_action(self, tool, menu=None):

        parent = QtWidgets.QToolBar.parent(self)

        if isinstance(tool.icon, six.string_types):
            if os.path.exists(tool.icon):
                icon = QtGui.QIcon(tool.icon)
            else:
                icon = get_icon(tool.icon)
        else:
            icon = tool.icon

        if isinstance(tool, DropdownTool):
            # We use a QToolButton here explicitly so that we can make sure
            # that the whole button opens the pop-up.
            button = QtWidgets.QToolButton()
            if tool.action_text:
                button.setText(tool.action_text)
            if icon:
                button.setIcon(icon)
            button.setPopupMode(button.InstantPopup)
            button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
            action = self.addWidget(button)
github avalentino / gsdview / gsdview / app.py View on Github external
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.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
github Ulm-IQO / qudi / gui / confocal / confocalgui.py View on Github external
self._mw.action_full_range_z.triggered.connect(self.set_full_scan_range_z)

        self._mw.action_zoom.toggled.connect(self.zoom_clicked)
        self._mw.sigDoubleClick.connect(self.activate_zoom_double_click)
        self._mw.xy_ViewWidget.sigMouseClick.connect(self.xy_scan_start_zoom_point)
        self._mw.xy_ViewWidget.sigMouseReleased.connect(self.xy_scan_end_zoom_point)
        self._mw.depth_ViewWidget.sigMouseClick.connect(self.depth_scan_start_zoom_point)
        self._mw.depth_ViewWidget.sigMouseReleased.connect(self.depth_scan_end_zoom_point)



        ###################################################################
        #               Icons for the scan actions                        #
        ###################################################################

        self._scan_xy_single_icon = QtGui.QIcon()
        self._scan_xy_single_icon.addPixmap(
            QtGui.QPixmap("artwork/icons/qudiTheme/22x22/scan-xy-start.png"),
            QtGui.QIcon.Normal,
            QtGui.QIcon.Off)

        self._scan_depth_single_icon = QtGui.QIcon()
        self._scan_depth_single_icon.addPixmap(
            QtGui.QPixmap("artwork/icons/qudiTheme/22x22/scan-depth-start.png"),
            QtGui.QIcon.Normal,
            QtGui.QIcon.Off)

        self._scan_xy_loop_icon = QtGui.QIcon()
        self._scan_xy_loop_icon.addPixmap(
            QtGui.QPixmap("artwork/icons/qudiTheme/22x22/scan-xy-loop.png"),
            QtGui.QIcon.Normal,
            QtGui.QIcon.Off)
github spyder-ide / spyder / spyder / utils / icon_manager.py View on Github external
"""

    icon_path = get_image_path(name, default=None)
    if icon_path is not None:
        icon = QIcon(icon_path)
    elif isinstance(default, QIcon):
        icon = default
    elif default is None:
        try:
            icon = get_std_icon(name[:-4])
        except AttributeError:
            icon = QIcon(get_image_path(name, default))
    else:
        icon = QIcon(get_image_path(name, default))
    if resample:
        icon0 = QIcon()
        for size in (16, 24, 32, 48, 96, 128, 256, 512):
            icon0.addPixmap(icon.pixmap(size, size))
        return icon0
    else:
        return icon