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


Python QWidget.setAutoFillBackground方法代码示例

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


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

示例1: iWindow

# 需要导入模块: from PyQt5.QtWidgets import QWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QWidget import setAutoFillBackground [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: _build_gui

# 需要导入模块: from PyQt5.QtWidgets import QWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QWidget import setAutoFillBackground [as 别名]
    def _build_gui(self):
        # Storages
        buttons = self._buttons

        # Unpack dimension data
        x, y, width, height = CACHE['dimension']

        # If position have not been set before
        if x is NotImplemented:
            screen = QDesktopWidget().screenGeometry()
            x, y = (screen.width() - width) / 2, (screen.height() - height) / 2
        # Set window position and dimension
        self.setGeometry(x, y, width, height)
        self.setFixedWidth(width)

        # Create layout for the entire application and zero-out
        self.layout = main_layout = QVBoxLayout()
        main_layout.setSpacing(0)
        main_layout.setContentsMargins(0, 0, 0, 0)

        # Create and add scrollable area for streams
        self._scroll_area = posts = QScrollArea()
        posts.setWidgetResizable(True)
        posts.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        posts.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        posts.setFrameShape(QFrame.NoFrame)

        # Create a main-stream widget
        main_stream = QWidget()
        main_stream.setFixedWidth(width)

        # TODO: rename self._posts to something meaningful
        self._posts = posts_layout = QVBoxLayout()
        posts_layout.setSpacing(POST_SPACING_FULL)
        posts_layout.setContentsMargins(0, 0, 0, 0)

        # HACK: in both scroll arrows the 'padding_left' value is a hack.
        #       The reason why the arrows are not aligned to the horizontal
        #       center is unknown as it looks like everything is set up properly

        # Add scroll-up icon and text
        self._scroll_up = CoubletButtonWidget(icon=CONSTANTS['icon_scroll_up'],
                                              label='SCROLL UP TO REFRESH',
                                              font=CONSTANTS['text_font_generic'],
                                              palette=CONSTANTS['text_color_light'],
                                              order=ICON_AND_LABEL,
                                              orientation=VERTICAL,
                                              spacing=SMALL_PADDING,
                                              padding_top=POST_SPACING_FULL,
                                              padding_left=8)
        posts_layout.addWidget(self._scroll_up, alignment=Qt.AlignHCenter)
        # Dynamic space
        posts_layout.addStretch(0)
        # Add scroll-down icon and text
        self._scroll_down = CoubletButtonWidget(icon=CONSTANTS['icon_scroll_down'],
                                                label='SCROLL DOWN TO LOAD MORE',
                                                font=CONSTANTS['text_font_generic'],
                                                palette=CONSTANTS['text_color_light'],
                                                order=LABEL_AND_ICON,
                                                orientation=VERTICAL,
                                                spacing=SMALL_PADDING,
                                                padding_bottom=POST_SPACING_FULL,
                                                padding_left=8)
        posts_layout.addWidget(self._scroll_down, alignment=Qt.AlignHCenter)

        # Set posts' layout to stream, add stream to main layout
        main_stream.setLayout(posts_layout)
        posts.setWidget(main_stream)
        main_layout.addWidget(posts)

        # Create menu-bar
        menu_bar = QWidget()
        menu_bar.setPalette(CONSTANTS['panel_color_darker'])
        menu_bar.setAutoFillBackground(True)

        # Create layout for menu-bar and zero-out
        menu_bar_layout = QVBoxLayout()
        menu_bar_layout.setSpacing(0)
        menu_bar_layout.setContentsMargins(0, 0, 0, 0)

        # Create layout for menu buttons and zero-out
        menu_buttons_layout = QHBoxLayout()
        menu_buttons_layout.setSpacing(0)
        menu_buttons_layout.setContentsMargins(0, 0, 0, 0)

        # Add menu-buttons to menu-bar
        menu_bar_layout.addSpacing(2*SMALL_PADDING)
        menu_bar_layout.addLayout(menu_buttons_layout)
        menu_bar_layout.addSpacing(2*SMALL_PADDING)

        # Assign layout and add menu-bar to app
        menu_bar.setLayout(menu_bar_layout)
        main_layout.addWidget(menu_bar)

        # Add buttons and spacess to menu-buttons layout
        menu_buttons_layout.addSpacing(2*SMALL_PADDING)
        # get default double-click interval
        for i, menu_item in enumerate(CoubAPI.STREAM_NAMES):
            # If not the first item, add
            # auto-stretching before it
#.........这里部分代码省略.........
开发者ID:petervaro,项目名称:coublet,代码行数:103,代码来源:window.py

示例3: GameRoundsDetail

# 需要导入模块: from PyQt5.QtWidgets import QWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QWidget import setAutoFillBackground [as 别名]
class GameRoundsDetail(QGroupBox):

    edited = QtCore.pyqtSignal()

    def __init__(self, engine, parent=None):
        super(GameRoundsDetail, self).__init__(parent)
        self.engine = engine
        self.initUI()

    def initUI(self):
        self.setStyleSheet("QGroupBox { font-size: 18px; font-weight: bold; }")
        self.widgetLayout = QVBoxLayout(self)
#        self.container = QToolBox(self)
        self.container = QTabWidget(self)
        self.widgetLayout.addWidget(self.container)

        self.tableContainer = QFrame(self)
        self.tableContainerLayout = QVBoxLayout(self.tableContainer)
        self.tableContainer.setAutoFillBackground(True)
        self.container.addTab(self.tableContainer, '')

        self.table = self.createRoundTable(self.engine, self)
        self.tableContainerLayout.addWidget(self.table, stretch=1)
        self.table.edited.connect(self.updateRound)
        self.table.edited.connect(self.edited.emit)

        self.plot = self.createRoundPlot(self.engine, self)
        self.plot.setAutoFillBackground(True)
#        self.container.addItem(self.plot,'')
        self.container.addTab(self.plot, '')

        self.statsFrame = QWidget(self)
        self.statsFrame.setAutoFillBackground(True)
        self.container.addTab(self.statsFrame, '')

        self.statsLayout = QVBoxLayout(self.statsFrame)
        self.gamestats = self.createQSBox(self.statsFrame)
        self.statsLayout.addWidget(self.gamestats)

    def retranslateUI(self):
        # self.setTitle(i18n("GameRoundsDetail",'Details'))
        self.container.setTabText(
            0, i18n("GameRoundsDetail", "Table"))
        self.container.setTabText(
            1, i18n("GameRoundsDetail", "Plot"))
        self.container.setTabText(2, i18n(
            "GameRoundsDetail", "Statistics"))
#        self.container.setItemText(0,i18n(
        #       "CarcassonneEntriesDetail","Table"))
#        self.container.setItemText(1,i18n(
        #       "CarcassonneEntriesDetail","Plot"))
#        self.container.setItemText(2,i18n(
        #       "CarcassonneEntriesDetail","Statistics"))
        self.gamestats.retranslateUI()
        self.plot.retranslateUI()
        self.updateRound()

    def updatePlot(self):
        self.plot.updatePlot()

    def updateRound(self):
        self.table.resetClear()
        for r in self.engine.getRounds():
            self.table.insertRound(r)
        self.updatePlot()

    def updateStats(self):
        try:
            self.gamestats.update(self.engine.getGame(),
                                  self.engine.getListPlayers())
        except Exception:
            self.gamestats.update()

    def deleteRound(self, nround):
        self.plot.updatePlot()

    # Implement in subclasses if necessary
    def createRoundTable(
        self, engine, parent=None): return GameRoundTable(self)

    def createRoundPlot(self, engine, parent=None): return GameRoundPlot(self)

    def createQSBox(self, parent=None): return QuickStatsTW(
        self.engine.getGame(), self.engine.getListPlayers(), self)

    def updatePlayerOrder(self):
        self.updateRound()
开发者ID:trawl,项目名称:gamelog,代码行数:89,代码来源:game.py


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