示例#1
0
def setStyleSheet(widget):
    '''
    Description:
        This is used to set the style theme for the given application

    Args:
        widget (qwidget): The qwidget that you want to apply the stylesheet to

    Returns:
        bool: Returns true if successful otherwise false
    '''
    root = os.path.dirname(os.path.abspath(getsourcefile(lambda: 0)))
    filepath = os.path.join(root, 'Resources', 'Themes', 'Moreno',
                            'styles.css')

    if not os.path.exists(filepath):
        return False

    css = QtCore.QFile(filepath)
    css.open(QtCore.QFile.ReadOnly | QtCore.QFile.Text)
    ss = QtCore.QTextStream(css).readAll()

    themeDir = os.path.dirname(filepath)
    iconsDir = os.path.normpath(os.path.join(themeDir, 'icons'))
    if os.path.isdir(iconsDir):
        iconsDir = iconsDir.replace('\\', '/')
        ss = ss.replace('[PATH]', iconsDir)

    widget.setStyleSheet(ss)
    return True
示例#2
0
def load_ui(ui_path):
    loader = QtUiTools.QUiLoader()
    f = QtCore.QFile(ui_path)
    f.open(QtCore.QFile.ReadOnly)
    widget = loader.load(f)
    f.close()
    return widget
示例#3
0
 def onSavePressed(self):
     tmp = tempfile.mkstemp(suffix=".json")[-1]
     file = QtCore.QFile(tmp)
     file.open(QtCore.QIODevice.WriteOnly)
     stream = QtCore.QDataStream(file)
     model = self.view.model()
     self.saveModel(model.invisibleRootItem(), stream)
     file.close()
     self.statusBar().showMessage("File saved: {}".format(tmp))
示例#4
0
 def __init__(self):
     super(UpLoad, self).__init__()
     # 调用qss 样式
     style_sheet_file = QtCore.QFile(
         os.path.join(os.path.dirname(__file__), 'stylesheets',
                      'scheme.qss'))
     style_sheet_file.open(QtCore.QFile.ReadOnly)
     self.setStyleSheet(str(style_sheet_file.readAll()))
     self.initUI()
示例#5
0
 def setContents(self, fileName):
     fi = QtCore.QFileInfo(fileName)
     self.srcUrl = QtCore.QUrl.fromLocalFile(fi.absoluteFilePath())
     file = QtCore.QFile(fileName)
     if file.open(QtCore.QIODevice.ReadOnly):
         data = file.readAll().data().decode()
         if fileName.endswith(".html"):
             self.setHtml(data)
         else:
             self.setPlainText(data)
示例#6
0
def loadUI(uiPath, parent):
    # read .ui directly
    dirname = os.path.dirname(uiPath)
    loader = QtUiTools.QUiLoader()
    loader.setWorkingDirectory(dirname)

    f = QtCore.QFile(uiPath)
    f.open(QtCore.QFile.ReadOnly)

    myWidget = loader.load(f, parent)

    f.close()
    return myWidget
示例#7
0
def _new_qapp():
    app = QtWidgets.QApplication
    os.environ["QT_AUTO_SCREEN_SCALE_FACTOR"] = "1"
    app.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True)
    app.setEffectEnabled(QtCore.Qt.UI_AnimateCombo, False)
    app = app(sys.argv)
    style_file = QtCore.QFile(':styles/styles/dark/dark.qss')
    style_file.open(QtCore.QFile.ReadOnly | QtCore.QFile.Text)
    stream = QtCore.QTextStream(style_file)
    app.setStyleSheet(stream.readAll())
    pixmap = QtGui.QPixmap(':icons/icons/nxt.svg')
    app.setWindowIcon(QtGui.QIcon(pixmap))
    return app
示例#8
0
def setup_ui_maya(uiFile, parent):
    """ Qt Module to load .ui file """
    # read .ui directly

    moduleDir = os.path.dirname(uiFile)
    loader = QtUiTools.QUiLoader()
    loader.setWorkingDirectory(moduleDir)

    f = QtCore.QFile(uiFile)
    f.open(QtCore.QFile.ReadOnly)

    myWidget = loader.load(f, parent)
    f.close()

    return myWidget
示例#9
0
文件: thumbnail.py 项目: nervYu/qtazu
    def _workerFinished(self):
        """Handler worker finished event."""

        if self._worker:

            pixmap = self._worker.result
            if not pixmap:
                # If not image downloaded read the thumbnail
                # placeholder instead
                qfile = QtCore.QFile(self.placeholderThumbnail)
                qfile.open(qfile.ReadOnly)
                pixmap = qfile.readAll()

            IMAGE_CACHE[self.__loadingReference] = pixmap
            self._updatePixmapData(pixmap)

        self._worker = None
        self.__loadingReference = None
示例#10
0
    def __init__(self):
        """
        light tool
        """
        super(Lightmanager, self).__init__()
        self.setWindowTitle('Lighting Manager')

        self.setMinimumWidth(500)
        self.setMinimumHeight(500)
        # self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
        self.setGeometry(120, 100, 250, 150)
        self.setModal(False)

        style_sheet_file = QtCore.QFile(
            os.path.join(os.path.dirname(__file__), 'stylesheets',
                         'scheme.qss'))
        style_sheet_file.open(QtCore.QFile.ReadOnly)
        self.setStyleSheet(str(style_sheet_file.readAll()))

        self.buildUI()
        self.populate()
        self.lightGroup = []
示例#11
0
 def loadResource(self, _type, name):
     if _type == QtGui.QTextDocument.ImageResource:
         file = QtCore.QFile(self.srcUrl.resolved(name).toLocalFile())
         if file.open(QtCore.QIODevice.ReadOnly):
             return file.readAll()
     return super().loadResource(_type, name)
示例#12
0
 def loadUiWidget(self, uifilename, parent=None):
     loader = QtUiTools.QUiLoader()
     uifile = QtCore.QFile(uifilename)
     uifile.open(QtCore.QFile.ReadOnly)
     self._ui = loader.load(uifile, self)
     uifile.close()