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


Python QWidget.palette方法代码示例

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


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

示例1: iWindow

# 需要导入模块: from PyQt5.QtWidgets import QWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QWidget import palette [as 别名]
class iWindow(iWidget):
    def __init__(self, 
                 parent=None, 
                 buttons=('min', 'max', 'close')
                 ):
        super(iWindow, self).__init__(parent)
        self.borderMargin = 5

        self.setBackgroundColor(QColor(107, 173, 246))
        
        self.__mainLayout = QVBoxLayout()
        self.__mainLayout.setSpacing(0)
        self.__mainLayout.setContentsMargins(0, 0, 0, 0)
        self.__contentLayout = QVBoxLayout()
        self.__contentLayout.setSpacing(0)
        
        self.__titleBar = iTitleBar(self, buttons=buttons)
        self.__content = QWidget()
        self.__content.setMouseTracking(True)
        self.__content.setAutoFillBackground(True)
        self.__contentLayout.addWidget(self.__content)
        
        self.__mainLayout.addWidget(self.__titleBar)
        self.__mainLayout.addLayout(self.__contentLayout)
        
        self.setBorderWidth(self.borderMargin, 0, 
                            self.borderMargin, self.borderMargin)
        self.setContentBackgroundColor(QColor(242, 242, 242))
        QWidget.setLayout(self, self.__mainLayout)
    
    ''' Overrides APIs. ''' 
    def setLayout(self, layout):
        self.__content.setLayout(layout)
        
    def setContentsMargins(self, left=0, top=0, right=0, bottom=0):
        self.__content.setContentsMargins(left, top, right, bottom)
    
    ''' Extends APIs. '''    
    def setBorderWidth(self, left=0, top=0, right=0, bottom=0):
        self.__contentLayout.setContentsMargins(left, top, right, bottom)
        
    def titleBar(self):
        return self.__titleBar
        
    def setIcon(self, icon=''):
        self._titleBar.setIcon(icon)
    
    def setTitle(self, title=''):
        self._titleBar.setTitle(title)
    
    def setTitleBarColor(self, color):    
        p = self._titleBar.palette()
        p.setColor(QPalette.WindowText, color)
        self._titleBar.setPalette(p)
        
    def setContentBackgroundColor(self, color):
        palette = QPalette(self.__content.palette())
        palette.setBrush(QPalette.Background, color)
        self.__content.setPalette(palette)
开发者ID:yuanjq,项目名称:idoui,代码行数:61,代码来源:iwindow.py

示例2: main

# 需要导入模块: from PyQt5.QtWidgets import QWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QWidget import palette [as 别名]
def main():
    if sys.version_info < (3, 4):
        print("You need at least Python 3.4 for this application!")
        sys.exit(1)

    t = time.time()
    if GENERATE_UI and not hasattr(sys, 'frozen'):
        try:
            urh_dir = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "..", ".."))
            sys.path.append(urh_dir)
            sys.path.append(os.path.join(urh_dir, "src"))

            import generate_ui

            generate_ui.gen()

            print("Time for generating UI: %.2f seconds" % (time.time() - t))
        except (ImportError, FileNotFoundError):
            print("Will not regenerate UI, because script can't be found. This is okay in release.")

    urh_exe = sys.executable if hasattr(sys, 'frozen') else sys.argv[0]
    urh_exe = os.readlink(urh_exe) if os.path.islink(urh_exe) else urh_exe

    urh_dir = os.path.join(os.path.dirname(os.path.realpath(urh_exe)), "..", "..")
    prefix = os.path.abspath(os.path.normpath(urh_dir))

    src_dir = os.path.join(prefix, "src")
    if os.path.exists(src_dir) and not prefix.startswith("/usr") and not re.match(r"(?i)c:\\program", prefix):
        # Started locally, not installed
        print("Adding {0} to pythonpath. This is only important when running URH from source.".format(src_dir))
        sys.path.insert(0, src_dir)

    from urh.util import util
    util.set_windows_lib_path()

    try:
        import urh.cythonext.signalFunctions
        import urh.cythonext.path_creator
        import urh.cythonext.util
    except ImportError:
        print("Could not find C++ extensions, trying to build them.")
        old_dir = os.curdir
        os.chdir(os.path.join(src_dir, "urh", "cythonext"))

        from urh.cythonext import build
        build.main()

        os.chdir(old_dir)

    from urh.controller.MainController import MainController
    from urh import constants

    if constants.SETTINGS.value("theme_index", 0, int) > 0:
        os.environ['QT_QPA_PLATFORMTHEME'] = 'fusion'

    app = QApplication(["URH"] + sys.argv[1:])
    app.setWindowIcon(QIcon(":/icons/data/icons/appicon.png"))

    if sys.platform != "linux":
        # noinspection PyUnresolvedReferences
        import urh.ui.xtra_icons_rc
        QIcon.setThemeName("oxy")

    constants.SETTINGS.setValue("default_theme", app.style().objectName())

    if constants.SETTINGS.value("theme_index", 0, int) > 0:
        app.setStyle(QStyleFactory.create("Fusion"))

        if constants.SETTINGS.value("theme_index", 0, int) == 2:
            palette = QPalette()
            background_color = QColor(56, 60, 74)
            text_color = QColor(211, 218, 227).lighter()
            palette.setColor(QPalette.Window, background_color)
            palette.setColor(QPalette.WindowText, text_color)
            palette.setColor(QPalette.Base, background_color)
            palette.setColor(QPalette.AlternateBase, background_color)
            palette.setColor(QPalette.ToolTipBase, background_color)
            palette.setColor(QPalette.ToolTipText, text_color)
            palette.setColor(QPalette.Text, text_color)

            palette.setColor(QPalette.Button, background_color)
            palette.setColor(QPalette.ButtonText, text_color)

            palette.setColor(QPalette.BrightText, Qt.red)
            palette.setColor(QPalette.Disabled, QPalette.Text, Qt.darkGray)
            palette.setColor(QPalette.Disabled, QPalette.ButtonText, Qt.darkGray)

            palette.setColor(QPalette.Highlight, QColor(200, 50, 0))
            palette.setColor(QPalette.HighlightedText, text_color)
            app.setPalette(palette)

    main_window = MainController()

    if sys.platform == "darwin":
        menu_bar = main_window.menuBar()
        menu_bar.setNativeMenuBar(False)
        import multiprocessing as mp
        mp.set_start_method("spawn")  # prevent errors with forking in native RTL-SDR backend
    elif sys.platform == "win32":
        # Ensure we get the app icon in windows taskbar
#.........这里部分代码省略.........
开发者ID:Cyber-Forensic,项目名称:urh,代码行数:103,代码来源:main.py

示例3: main

# 需要导入模块: from PyQt5.QtWidgets import QWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QWidget import palette [as 别名]
def main():
    fix_windows_stdout_stderr()

    if sys.version_info < (3, 4):
        print("You need at least Python 3.4 for this application!")
        sys.exit(1)

    urh_exe = sys.executable if hasattr(sys, 'frozen') else sys.argv[0]
    urh_exe = os.readlink(urh_exe) if os.path.islink(urh_exe) else urh_exe

    urh_dir = os.path.join(os.path.dirname(os.path.realpath(urh_exe)), "..", "..")
    prefix = os.path.abspath(os.path.normpath(urh_dir))

    src_dir = os.path.join(prefix, "src")
    if os.path.exists(src_dir) and not prefix.startswith("/usr") and not re.match(r"(?i)c:\\program", prefix):
        # Started locally, not installed -> add directory to path
        sys.path.insert(0, src_dir)

    if len(sys.argv) > 1 and sys.argv[1] == "--version":
        import urh.version
        print(urh.version.VERSION)
        sys.exit(0)

    if GENERATE_UI and not hasattr(sys, 'frozen'):
        try:
            sys.path.insert(0, os.path.join(prefix))
            from data import generate_ui
            generate_ui.gen()
        except (ImportError, FileNotFoundError):
            # The generate UI script cannot be found so we are most likely in release mode, no problem here.
            pass

    from urh.util import util
    util.set_shared_library_path()

    try:
        import urh.cythonext.signal_functions
        import urh.cythonext.path_creator
        import urh.cythonext.util
    except ImportError:
        if hasattr(sys, "frozen"):
            print("C++ Extensions not found. Exiting...")
            sys.exit(1)
        print("Could not find C++ extensions, trying to build them.")
        old_dir = os.path.realpath(os.curdir)
        os.chdir(os.path.join(src_dir, "urh", "cythonext"))

        from urh.cythonext import build
        build.main()

        os.chdir(old_dir)

    from urh.controller.MainController import MainController
    from urh import constants

    if constants.SETTINGS.value("theme_index", 0, int) > 0:
        os.environ['QT_QPA_PLATFORMTHEME'] = 'fusion'

    app = QApplication(["URH"] + sys.argv[1:])
    app.setWindowIcon(QIcon(":/icons/icons/appicon.png"))

    util.set_icon_theme()

    font_size = constants.SETTINGS.value("font_size", 0, int)
    if font_size > 0:
        font = app.font()
        font.setPointSize(font_size)
        app.setFont(font)

    constants.SETTINGS.setValue("default_theme", app.style().objectName())

    if constants.SETTINGS.value("theme_index", 0, int) > 0:
        app.setStyle(QStyleFactory.create("Fusion"))

        if constants.SETTINGS.value("theme_index", 0, int) == 2:
            palette = QPalette()
            background_color = QColor(56, 60, 74)
            text_color = QColor(211, 218, 227).lighter()
            palette.setColor(QPalette.Window, background_color)
            palette.setColor(QPalette.WindowText, text_color)
            palette.setColor(QPalette.Base, background_color)
            palette.setColor(QPalette.AlternateBase, background_color)
            palette.setColor(QPalette.ToolTipBase, background_color)
            palette.setColor(QPalette.ToolTipText, text_color)
            palette.setColor(QPalette.Text, text_color)

            palette.setColor(QPalette.Button, background_color)
            palette.setColor(QPalette.ButtonText, text_color)

            palette.setColor(QPalette.BrightText, Qt.red)
            palette.setColor(QPalette.Disabled, QPalette.Text, Qt.darkGray)
            palette.setColor(QPalette.Disabled, QPalette.ButtonText, Qt.darkGray)

            palette.setColor(QPalette.Highlight, QColor(200, 50, 0))
            palette.setColor(QPalette.HighlightedText, text_color)
            app.setPalette(palette)

    # use system colors for painting
    widget = QWidget()
    bg_color = widget.palette().color(QPalette.Background)
#.........这里部分代码省略.........
开发者ID:jopohl,项目名称:urh,代码行数:103,代码来源:main.py


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