def get_icon(icon_name): """Returns an icon from ui library """ here = os.path.abspath(os.path.dirname(__file__)) images_path = os.path.join(here, 'images') icon_full_path = os.path.join(images_path, icon_name) return QtGui.QIcon(icon_full_path)
def _setup_ui(self): self.setWindowModality(QtCore.Qt.ApplicationModal) self.setModal(True) self.resize(300, 300) size_policy = QtWidgets.QSizePolicy( QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred ) size_policy.setHorizontalStretch(1) size_policy.setVerticalStretch(1) size_policy.setHeightForWidth(self.sizePolicy().hasHeightForWidth()) self.setSizePolicy(size_policy) self.setSizeGripEnabled(True) self.horizontal_layout = QtWidgets.QHBoxLayout(self) self.toolbox_widget = QtWidgets.QWidget(self) self.horizontal_layout.addWidget(self.toolbox_widget) self.toolbox_layout = ToolboxLayout(self.toolbox_widget) self.toolbox_layout.setSizeConstraint(QtWidgets.QLayout.SetMaximumSize) self.toolbox_layout.setContentsMargins(0, 0, 0, 0) # setup icon global __here__ icon_path = os.path.abspath( os.path.join(__here__, "../../../ui/images/fusion9.png") ) icon = QtGui.QIcon(icon_path) self.setWindowIcon(icon)
def setup_ui(self): """create the main """ tlb = ToolboxLayout() self.setLayout(tlb) # setup icon global __here__ icon_path = os.path.abspath( os.path.join(__here__, "../../../ui/images/DaVinciResolve.png")) try: icon = QtWidgets.QIcon(icon_path) except AttributeError: icon = QtGui.QIcon(icon_path) self.setWindowIcon(icon) self.setWindowTitle("DaVinci Resolve Toolbox")
def setup_ui(self): """creates the UI widgets """ self.setWindowTitle("%s v%s" % (self.__app_name__, self.__version__)) # set application icon from anima import ui import os print('ui.__path__: %s' % ui.__path__[0]) app_icon_path = os.path.join(ui.__path__[0], 'images', 'app_icon.png') self.setWindowIcon(QtGui.QIcon(app_icon_path)) self.create_main_menu() self.create_toolbars() self.create_dock_widgets() self.read_settings()
def get_icon(icon_name): """Returns an icon from ui library """ import time start_time = time.time() # get the icon from cache if possible from anima.ui import ICON_CACHE q_icon = ICON_CACHE.get(icon_name) if not q_icon: logger.debug("getting icon from the cache!") # use the local icon cache import os from anima import defaults local_icon_cache_path = os.path.normpath( os.path.expanduser( os.path.join(defaults.local_cache_folder, "icons"))) local_icon_full_path = os.path.join(local_icon_cache_path, "%s.png" % icon_name) logger.debug("local_icon_full_path: %s" % local_icon_full_path) if not os.path.exists(local_icon_full_path): logger.debug("local icon cache not found: %s" % icon_name) logger.debug("retrieving icon from library!") here = os.path.abspath(os.path.dirname(__file__)) images_path = os.path.join(here, 'images') icon_full_path = os.path.join(images_path, "%s.png" % icon_name) logger.debug("icon_full_path: %s" % icon_full_path) # copy to local cache folder try: os.makedirs(local_icon_cache_path) except OSError: pass import shutil try: shutil.copy(icon_full_path, local_icon_full_path) except OSError: # original icon doesn't exist pass q_icon = QtGui.QIcon(local_icon_full_path) ICON_CACHE[icon_name] = q_icon logger.debug("get_icon took: %0.6f s" % (time.time() - start_time)) return q_icon