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


Python QScrollArea.setBackgroundRole方法代码示例

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


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

示例1: __init__

# 需要导入模块: from PyQt5.QtWidgets import QScrollArea [as 别名]
# 或者: from PyQt5.QtWidgets.QScrollArea import setBackgroundRole [as 别名]
	def __init__(self, tup_gallery, parent = None, menu = None):
		super().__init__(parent)
		self.setMaximumWidth(16777215)
		assert isinstance(tup_gallery, tuple), "Incorrect type received, expected tuple"
		assert isinstance(tup_gallery[0], str) and isinstance(tup_gallery[1], list)
		main_layout = QVBoxLayout()
		# todo make it scroll
		scroll_area = QScrollArea()
		dummy = QWidget()
		self.gallery_layout = misc.FlowLayout(dummy)
		scroll_area.setWidgetResizable(True)
		scroll_area.setMaximumHeight(400)
		scroll_area.setMidLineWidth(620)
		scroll_area.setBackgroundRole(scroll_area.palette().Shadow)
		scroll_area.setFrameStyle(scroll_area.NoFrame)
		scroll_area.setWidget(dummy)
		text = tup_gallery[0]
		galleries = tup_gallery[1]
		main_layout.addWidget(scroll_area, 3)
		for g in galleries:
			gall_w = misc.GalleryShowcaseWidget(parent=self, menu=menu())
			gall_w.set_gallery(g, (170//1.40, 170))
			gall_w.double_clicked.connect(self.gallery_doubleclicked.emit)
			self.gallery_layout.addWidget(gall_w)

		text_lbl =  QLabel(text)
		text_lbl.setAlignment(Qt.AlignCenter)
		main_layout.addWidget(text_lbl)
		main_layout.addLayout(self.buttons_layout)
		self.main_widget.setLayout(main_layout)
		self.setMaximumHeight(500)
		self.setMaximumWidth(620)
		self.resize(620, 500)
		self.show()
开发者ID:ImoutoChan,项目名称:happypanda,代码行数:36,代码来源:io_misc.py

示例2: __init__

# 需要导入模块: from PyQt5.QtWidgets import QScrollArea [as 别名]
# 或者: from PyQt5.QtWidgets.QScrollArea import setBackgroundRole [as 别名]
	def __init__(self, parent):
		super().__init__(None,
				   Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowMinMaxButtonsHint)
		self.setAttribute(Qt.WA_DeleteOnClose)
		main_layout = QVBoxLayout(self)
		self.parent_widget = parent
		self.url_inserter = QLineEdit()
		self.url_inserter.setPlaceholderText("Hover to see supported URLs")
		self.url_inserter.setToolTip(gui_constants.SUPPORTED_DOWNLOAD_URLS)
		self.url_inserter.setToolTipDuration(999999999)
		self.url_inserter.returnPressed.connect(self.add_download_entry)
		main_layout.addWidget(self.url_inserter)
		self.info_lbl = QLabel(self)
		self.info_lbl.setAlignment(Qt.AlignCenter)
		main_layout.addWidget(self.info_lbl)
		self.info_lbl.hide()
		buttons_layout = QHBoxLayout()
		clear_all_btn = QPushButton('Clear List')
		clear_all_btn.adjustSize()
		clear_all_btn.setFixedWidth(clear_all_btn.width())
		buttons_layout.addWidget(clear_all_btn, 0, Qt.AlignRight)
		main_layout.addLayout(buttons_layout)
		self.download_list = GalleryDownloaderList(parent.manga_list_view.sort_model, self)
		clear_all_btn.clicked.connect(self.download_list.clear_list)
		download_list_scroll = QScrollArea(self)
		download_list_scroll.setBackgroundRole(self.palette().Base)
		download_list_scroll.setWidgetResizable(True)
		download_list_scroll.setWidget(self.download_list)
		main_layout.addWidget(download_list_scroll, 1)
		close_button = QPushButton('Close', self)
		close_button.clicked.connect(self.hide)
		main_layout.addWidget(close_button)
		self.resize(480,600)
		self.setWindowIcon(QIcon(gui_constants.APP_ICO_PATH))
开发者ID:peaceandpizza,项目名称:happypanda,代码行数:36,代码来源:file_misc.py

示例3: widgetDebug

# 需要导入模块: from PyQt5.QtWidgets import QScrollArea [as 别名]
# 或者: from PyQt5.QtWidgets.QScrollArea import setBackgroundRole [as 别名]
    def widgetDebug(self):
        """Create debug infos widget.
        """
        vbox = QVBoxLayout()
        self.debugText = QTextEdit(self)
        css = "QTextEdit { background-color: #FFF; color: #222 }"
        self.debugText.setStyleSheet(css)
        hbox = QHBoxLayout()
        self.showDetails = QPushButton(self.tr('Details >>>'))
        self.showDetails.setCheckable(True)
        self.showDetails.clicked[bool].connect(self.toggleDebugInfo)
        self.showDetails.setChecked(1)

        scroll = QScrollArea()
        scrollLayout = QVBoxLayout()
        scrollContents = QWidget()

        scroll.setWidgetResizable(True)
        scroll.setBackgroundRole(QtGui.QPalette.Dark);

        figureWidget = QWidget(scrollContents)
        self.figure = plt.figure()
        self.canvas = FigureCanvas(self.figure)
        self.canvas.setParent(figureWidget)
        self.toolbar = NavigationToolbar(self.canvas, self)

        plotLayout = QVBoxLayout()
        plotLayout.addWidget(self.canvas)
        plotLayout.addWidget(self.toolbar)
        figureWidget.setLayout(plotLayout)

        scrollLayout.addWidget(self.debugText)
        scrollLayout.addWidget(figureWidget)

        scrollContents.setLayout(scrollLayout)
        scroll.setWidget(scrollContents)

        self.detailsScroll = scroll

        self.canvas.setMinimumSize(self.canvas.size())
        self.toggleDebugInfo(True)

        hbox.addWidget(self.showDetails)
        hbox.addStretch(1)
        vbox.addLayout(hbox)
        vbox.addWidget(scroll)
        return vbox
开发者ID:xsyann,项目名称:clustering,代码行数:49,代码来源:clustering.py

示例4: new_tab

# 需要导入模块: from PyQt5.QtWidgets import QScrollArea [as 别名]
# 或者: from PyQt5.QtWidgets.QScrollArea import setBackgroundRole [as 别名]
		def new_tab(name, parent, scroll=False):
			"""
			Creates a new tab.
			Returns new tab page widget and it's layout
			"""
			new_t = QWidget(parent)
			new_l = QFormLayout(new_t)
			if scroll:
				scr = QScrollArea(parent)
				scr.setBackgroundRole(QPalette.Base)
				scr.setWidget(new_t)
				scr.setWidgetResizable(True)
				parent.addTab(scr, name)
				return new_t, new_l
			else:
				parent.addTab(new_t, name)
			return new_t, new_l
开发者ID:darmstard,项目名称:happypanda,代码行数:19,代码来源:settingsdialog.py

示例5: __init__

# 需要导入模块: from PyQt5.QtWidgets import QScrollArea [as 别名]
# 或者: from PyQt5.QtWidgets.QScrollArea import setBackgroundRole [as 别名]
    def __init__(self, parent):
        super().__init__(None,
                   )#Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowMinMaxButtonsHint)
        self.setAttribute(Qt.WA_DeleteOnClose, False)
        main_layout = QVBoxLayout(self)
        self.parent_widget = parent
        self.url_inserter = QLineEdit()
        self.url_inserter.setPlaceholderText("Hover to see supported URLs")
        self.url_inserter.setToolTip(app_constants.SUPPORTED_DOWNLOAD_URLS)
        self.url_inserter.setToolTipDuration(999999999)
        self.url_inserter.returnPressed.connect(self.add_download_entry)
        main_layout.addWidget(self.url_inserter)
        self.info_lbl = QLabel(self)
        self.info_lbl.setAlignment(Qt.AlignCenter)
        main_layout.addWidget(self.info_lbl)
        self.info_lbl.hide()
        buttons_layout = QHBoxLayout()
        url_window_btn = QPushButton('Batch URLs')
        url_window_btn.adjustSize()
        url_window_btn.setFixedWidth(url_window_btn.width())
        self._urls_queue = []
        def batch_url_win():
            self._batch_url = GalleryDownloaderUrlExtracter()
            self._batch_url.url_emit.connect(lambda u: self._urls_queue.append(u))
            self._batch_url.url_emit.connect(lambda u: self.info_lbl.setText("<font color='green'>Adding URLs to queue...</font>") if u else None)
        url_window_btn.clicked.connect(batch_url_win)
        clear_all_btn = QPushButton('Clear List')
        clear_all_btn.adjustSize()
        clear_all_btn.setFixedWidth(clear_all_btn.width())
        buttons_layout.addWidget(url_window_btn, 0, Qt.AlignLeft)
        buttons_layout.addWidget(clear_all_btn, 0, Qt.AlignRight)
        main_layout.addLayout(buttons_layout)
        self.download_list = GalleryDownloaderList(parent, self)
        clear_all_btn.clicked.connect(self.download_list.clear_list)
        download_list_scroll = QScrollArea(self)
        download_list_scroll.setBackgroundRole(self.palette().Base)
        download_list_scroll.setWidgetResizable(True)
        download_list_scroll.setWidget(self.download_list)
        main_layout.addWidget(download_list_scroll, 1)
        self.resize(480,600)
        self.setWindowIcon(QIcon(app_constants.APP_ICO_PATH))

        self._url_checker = QTimer(self)
        self._url_checker.timeout.connect(lambda: self.add_download_entry(extractor=True))
        self._url_checker.start(500)
开发者ID:Pewpews,项目名称:happypanda,代码行数:47,代码来源:io_misc.py

示例6: _createFileInfo

# 需要导入模块: from PyQt5.QtWidgets import QScrollArea [as 别名]
# 或者: from PyQt5.QtWidgets.QScrollArea import setBackgroundRole [as 别名]
    def _createFileInfo(self, filePath, data):
        self.clear()

        w = QWidget(self)
        w.setLayout(QFormLayout())
        w.layout().setContentsMargins(2, 2, 2, 2)
        w.layout().setSizeConstraint(QLayout.SetMinimumSize)

        sa = QScrollArea(self)
        sa.setWidget(w)
        sa.setBackgroundRole(w.backgroundRole())

        fileNameLabel = QLabel(os.path.split(filePath)[1], self)
        fileNameLabel.setToolTip(fileNameLabel.text())

        fpsLabel = QLabel(str(data.fps), self)
        fpsLabel.setToolTip(fpsLabel.text())

        formatLabel = QLabel(data.outputFormat.NAME, self)
        formatLabel.setToolTip(formatLabel.text())

        inEncodingLabel = QLabel(data.inputEncoding, self)
        inEncodingLabel.setToolTip(inEncodingLabel.text())

        outEncodingLabel = QLabel(data.outputEncoding, self)
        outEncodingLabel.setToolTip(outEncodingLabel.text())

        if data.videoPath is not None:
            videoLabel = QLabel(data.videoPath, self)
            videoLabel.setToolTip(videoLabel.text())
        else:
            videoLabel = QLabel("-", self)
            videoLabel.setToolTip(_("No video"))

        w.layout().addRow(_("File name:"), fileNameLabel)
        w.layout().addRow(_("Video:"), videoLabel)
        w.layout().addRow(_("FPS:"), fpsLabel)
        w.layout().addRow(_("Format:"), formatLabel)
        w.layout().addRow(_("Input encoding:"), inEncodingLabel)
        w.layout().addRow(_("Output encoding:"), outEncodingLabel)

        self.layout().addWidget(sa)
开发者ID:mgoral,项目名称:subconvert,代码行数:44,代码来源:Details.py

示例7: MainWindow

# 需要导入模块: from PyQt5.QtWidgets import QScrollArea [as 别名]
# 或者: from PyQt5.QtWidgets.QScrollArea import setBackgroundRole [as 别名]

#.........这里部分代码省略.........
        self.pagePairTrLaunchButton.setText("Re-Launch")

    def atoTrdPage(self):

        for pi in range(0,len(self.pages)):
            self.toolButtons[pi].setStyleSheet(self.toolButtonHideQSS)
            self.pages[pi].hide()

        print "in monitor page"
        ci = 2
        page = self.pages[ci]
        self.toolButtons[ci].setStyleSheet(self.toolButtonFocusQSS)

        if self.pagesStatus[ci] == 0:

            if not page.layout() == None:
                while page.layout().count() > 0:
                    page.layout().takeAt(0).widget().setParent(None)

            if page.layout() == None:
                self.pageAutoTrdPageMainVerticalBox = QVBoxLayout()
                self.pageAutoTrdPageMainVerticalBox.setContentsMargins(0, 5, 0, 0)
                page.setLayout(self.pageAutoTrdPageMainVerticalBox)

            self.pageAutoTrdTitleLabel = QLabel("Monitor", page)
            self.pageAutoTrdTitleLabel.setFixedSize(860, 25)
            self.pageAutoTrdTitleLabel.setStyleSheet(self.pageTitleQSS)
            self.pageAutoTrdPageMainVerticalBox.addWidget(self.pageAutoTrdTitleLabel)

            pnlReport = self.ATM.report
            if not len(self.ATM.strategies.strategiesPool.keys()) == 0:
                self.pageAtoTrdPageScroll = QScrollArea(page)
                self.pageAtoTrdPageScroll.setWidgetResizable(True)
                self.pageAtoTrdPageScroll.setBackgroundRole(QPalette.NoRole)
                self.pageAtoTrdPageScroll.setStyleSheet("background: transparent")
                self.pageAtoTrdPageScroll.setFixedSize(860, 635)
                self.pageAtoTrdScrollContentsWidget = QWidget(page)
                scrollContentVBox = QVBoxLayout()
                scrollContentVBox.setAlignment(Qt.AlignTop)
                scrollContentVBox.setContentsMargins(0, 0, 0, 0)

                self.pageAtoTrdSignalPlotLabel = QLabel("Signals Plots", page)
                self.pageAtoTrdSignalPlotLabel.setFixedSize(860, 25)
                self.pageAtoTrdSignalPlotLabel.setStyleSheet(self.pageSubTitleQSS)
                scrollContentVBox.addWidget(self.pageAtoTrdSignalPlotLabel)

                path = "./strategies/image/"
                for file in os.listdir(path):
                    if file.endswith(".png") and file.split('.')[0] in self.ATM.strategies.strategiesPool.keys():
                        pageAtoTrdSignalPlotStrategyLabel = QLabel(file.split('.')[0], page)
                        pageAtoTrdSignalPlotStrategyLabel.setFixedSize(860, 25)
                        pageAtoTrdSignalPlotStrategyLabel.setStyleSheet(self.pageSubSubTitleQSS)
                        scrollContentVBox.addWidget(pageAtoTrdSignalPlotStrategyLabel)

                        widget = QWidget()
                        widget.setFixedHeight(300)
                        hbox = QHBoxLayout()
                        hbox.setContentsMargins(0, 0, 0, 0)
                        hbox.setAlignment(Qt.AlignCenter)
                        lbl = QLabel()
                        pixmap = QPixmap(path + file)
                        scaled_pixmap = pixmap.scaled(860, 330, Qt.KeepAspectRatio)
                        lbl.setPixmap(scaled_pixmap)
                        hbox.addWidget(lbl)
                        widget.setLayout(hbox)
                        scrollContentVBox.addWidget(widget)
开发者ID:curme,项目名称:AutoTrading,代码行数:70,代码来源:widgets.py

示例8: ImageDisplay

# 需要导入模块: from PyQt5.QtWidgets import QScrollArea [as 别名]
# 或者: from PyQt5.QtWidgets.QScrollArea import setBackgroundRole [as 别名]

#.........这里部分代码省略.........
        text_height = bottom_row - top_row + 1
        port_height = self.scroll_area.viewport().height()
        self._set_zoom_real(port_height/text_height)
        self.scroll_area.verticalScrollBar().setValue(
                         int( top_row * self.zoom_factor ) )
        # and that completes zoom-to-height

    # Build the widgetary contents. The widget consists mostly of a vertical
    # layout with two items: A scrollArea containing a QLabel used to display
    # an image, and a horizontal layout containing the zoom controls.
    # TODO: figure out design and location of two cursor-link tool buttons.
    def _uic(self):

        # Function to return the actual width of the label text
        # of a widget. Get the fontMetrics and ask it for the width.
        def _label_width(widget):
            fm = widget.fontMetrics()
            return fm.width(widget.text())

        # Create a gray field to use when no image is available
        self.gray_image = QPixmap(700,900)
        self.gray_image.fill(QColor("gray"))

        # Build the QLabel that displays the image pixmap. It gets all
        # available space and scales its contents to fit that space.
        self.image_display = QLabel()
        self.image_display.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored)
        self.image_display.setScaledContents(True)

        # Create a scroll area within which to display the image. It will
        # create a horizontal and/or vertical scroll bar when
        # the image_display size exceeds the size of the scroll area.
        self.scroll_area = QScrollArea()
        self.scroll_area.setBackgroundRole(QPalette.Dark)
        self.scroll_area.setSizeAdjustPolicy(QAbstractScrollArea.AdjustToContents)
        self.scroll_area.setWidget(self.image_display)
        # Make sure the scroll area does not swallow user keystrokes
        self.setFocusPolicy(Qt.ClickFocus) # focus into whole widget
        self.scroll_area.setFocusProxy(self) # you, pass it on.

        # Create the image-linking toolbuttons.
        # Cursor-to-image uses left-hands.
        c2i_on = QPixmap(':/hand-left-closed.png')
        c2i_off = QPixmap(':/hand-left-open.png')
        c2i_con = QIcon()
        c2i_con.addPixmap(c2i_on,QIcon.Normal,QIcon.On)
        c2i_con.addPixmap(c2i_off,QIcon.Normal,QIcon.Off)
        self.cursor_to_image = QToolButton()
        self.cursor_to_image.setCheckable(True)
        self.cursor_to_image.setContentsMargins(0,0,0,0)
        self.cursor_to_image.setIconSize(QSize(30,24))
        self.cursor_to_image.setMaximumSize(QSize(32,26))
        self.cursor_to_image.setIcon(c2i_con)
        # Image-to-cursor uses right-hands.
        i2c_on = QPixmap(':/hand-right-closed.png')
        i2c_off = QPixmap(':/hand-right-open.png')
        i2c_con = QIcon()
        i2c_con.addPixmap(i2c_on,QIcon.Normal,QIcon.On)
        i2c_con.addPixmap(i2c_off,QIcon.Normal,QIcon.Off)
        self.image_to_cursor = QToolButton()
        self.image_to_cursor.setCheckable(True)
        self.image_to_cursor.setContentsMargins(0,0,0,0)
        self.image_to_cursor.setIconSize(QSize(30,24))
        self.image_to_cursor.setMaximumSize(QSize(32,26))
        self.image_to_cursor.setIcon(i2c_con)
开发者ID:B-Rich,项目名称:PPQT2,代码行数:69,代码来源:imageview.py

示例9: PixmapDiagram

# 需要导入模块: from PyQt5.QtWidgets import QScrollArea [as 别名]
# 或者: from PyQt5.QtWidgets.QScrollArea import setBackgroundRole [as 别名]
class PixmapDiagram(E5MainWindow):
    """
    Class implementing a dialog showing a pixmap.
    """
    ZoomLevels = [
        1, 3, 5, 7, 9,
        10, 20, 30, 50, 67, 80, 90,
        100,
        110, 120, 133, 150, 170, 200, 240, 300, 400,
        500, 600, 700, 800, 900, 1000,
    ]
    ZoomLevelDefault = 100
    
    def __init__(self, pixmap, parent=None, name=None):
        """
        Constructor
        
        @param pixmap filename of a graphics file to show (string)
        @param parent parent widget of the view (QWidget)
        @param name name of the view widget (string)
        """
        super(PixmapDiagram, self).__init__(parent)
        if name:
            self.setObjectName(name)
        else:
            self.setObjectName("PixmapDiagram")
        self.setWindowTitle(self.tr("Pixmap-Viewer"))
        
        self.pixmapLabel = QLabel()
        self.pixmapLabel.setObjectName("pixmapLabel")
        self.pixmapLabel.setBackgroundRole(QPalette.Base)
        self.pixmapLabel.setSizePolicy(
            QSizePolicy.Ignored, QSizePolicy.Ignored)
        self.pixmapLabel.setScaledContents(True)
        
        self.pixmapView = QScrollArea()
        self.pixmapView.setObjectName("pixmapView")
        self.pixmapView.setBackgroundRole(QPalette.Dark)
        self.pixmapView.setWidget(self.pixmapLabel)
        
        self.setCentralWidget(self.pixmapView)
        
        self.__zoomWidget = E5ZoomWidget(
            UI.PixmapCache.getPixmap("zoomOut.png"),
            UI.PixmapCache.getPixmap("zoomIn.png"),
            UI.PixmapCache.getPixmap("zoomReset.png"), self)
        self.statusBar().addPermanentWidget(self.__zoomWidget)
        self.__zoomWidget.setMapping(
            PixmapDiagram.ZoomLevels, PixmapDiagram.ZoomLevelDefault)
        self.__zoomWidget.valueChanged.connect(self.__doZoom)
        
        # polish up the dialog
        self.resize(QSize(800, 600).expandedTo(self.minimumSizeHint()))
        
        self.pixmapfile = pixmap
        self.status = self.__showPixmap(self.pixmapfile)
        
        self.__initActions()
        self.__initContextMenu()
        self.__initToolBars()
        
        self.grabGesture(Qt.PinchGesture)
    
    def __initActions(self):
        """
        Private method to initialize the view actions.
        """
        self.closeAct = \
            QAction(UI.PixmapCache.getIcon("close.png"),
                    self.tr("Close"), self)
        self.closeAct.triggered.connect(self.close)
        
        self.printAct = \
            QAction(UI.PixmapCache.getIcon("print.png"),
                    self.tr("Print"), self)
        self.printAct.triggered.connect(self.__printDiagram)
        
        self.printPreviewAct = \
            QAction(UI.PixmapCache.getIcon("printPreview.png"),
                    self.tr("Print Preview"), self)
        self.printPreviewAct.triggered.connect(self.__printPreviewDiagram)
        
    def __initContextMenu(self):
        """
        Private method to initialize the context menu.
        """
        self.__menu = QMenu(self)
        self.__menu.addAction(self.closeAct)
        self.__menu.addSeparator()
        self.__menu.addAction(self.printPreviewAct)
        self.__menu.addAction(self.printAct)
        
        self.setContextMenuPolicy(Qt.CustomContextMenu)
        self.customContextMenuRequested.connect(self.__showContextMenu)
        
    def __showContextMenu(self, coord):
        """
        Private slot to show the context menu of the listview.
        
        @param coord the position of the mouse pointer (QPoint)
#.........这里部分代码省略.........
开发者ID:testmana2,项目名称:test,代码行数:103,代码来源:PixmapDiagram.py

示例10: PDFAreaSelectorDlg

# 需要导入模块: from PyQt5.QtWidgets import QScrollArea [as 别名]
# 或者: from PyQt5.QtWidgets.QScrollArea import setBackgroundRole [as 别名]
class PDFAreaSelectorDlg(QDialog):

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

        self._parent = parent

        self.setWindowTitle("Area selection")
        self.scaleFactor = 1
        self.setModal(True)

        self.controlBarWgt         = QWidget(self)
        self.nextPageBtn         = QPushButton("Next page (Ctrl+right arrow)")
        self.previousPageBtn     = QPushButton("Previous page (Ctrl+left arrow)")
        self.noPageTxt             = QLabel("1")
        self.noPageTxt.setStyleSheet("border: 1px solid grey")
        self.noPageTxt.setFixedWidth(40)

        self.controlBarWgt.setLayout(QHBoxLayout())

        self.nextPageBtn.clicked.connect(self.nextPage)
        self.previousPageBtn.clicked.connect(self.previousPage)

        self.controlBarWgt.layout().addWidget(self.previousPageBtn)
        self.controlBarWgt.layout().addWidget(self.noPageTxt)
        self.controlBarWgt.layout().addWidget(self.nextPageBtn)

        self.imageLabel = ImageWidget()
        self.imageLabel.setBackgroundRole(QPalette.Base)
        self.imageLabel.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored)
        self.imageLabel.setScaledContents(True)

        self.scrollArea = QScrollArea()
        self.scrollArea.setBackgroundRole(QPalette.Dark)
        self.scrollArea.setWidget(self.imageLabel)

        self.createActions()
        self.createMenus()

        self.setLayout(QVBoxLayout())
        self.layout().addWidget(self.menuBar)
        self.layout().addWidget(self.controlBarWgt)
        self.layout().addWidget(self.scrollArea)

        self.imageLabel.areaSelected.connect(self.resendSelectedEvent)

        self.loadImage()

    @pyqtSlot(float, float, float, float, QPixmap)
    def resendSelectedEvent(self, x, y, width, height, image):
        self._parent.x = x
        self._parent.y = y
        self._parent.width = width
        self._parent.height = height
        self._parent.image = image

        self._parent.areaSelected.emit()
        self.close()


    def loadImage(self):
        image = QImage.fromData(self._parent.pages[self._parent.currentPageInd],"PNG")

        self.imageLabel.setPixmap(QPixmap.fromImage(image))
        self.fitToWindowAct.setEnabled(True)
        self.updateActions()

        if not self.fitToWindowAct.isChecked():
            self.imageLabel.adjustSize()

        self.setWindowFilePath(self._parent.fileName)
        return True


    def zoomIn(self):
        self.scaleImage(1.25)


    def zoomOut(self):
        self.scaleImage(0.8)


    def normalSize(self):
        self.imageLabel.adjustSize()
        self.scaleFactor = 1.0

    def fitToWindow(self):
        fitToWindow = self.fitToWindowAct.isChecked()
        self.scrollArea.setWidgetResizable(fitToWindow)
        if not fitToWindow :
            self.normalSize()
        self.updateActions()



    def createActions(self):

        self.exitAct = QAction("E&xit", self)
        self.exitAct.setShortcut("Ctrl+Q")
        self.exitAct.triggered.connect(self.close)
#.........这里部分代码省略.........
开发者ID:christian-oreilly,项目名称:neurocurator,代码行数:103,代码来源:areaSelector.py

示例11: GridScrollArea

# 需要导入模块: from PyQt5.QtWidgets import QScrollArea [as 别名]
# 或者: from PyQt5.QtWidgets.QScrollArea import setBackgroundRole [as 别名]
class GridScrollArea(QVBoxLayout):
    def __init__(self, parent):
        QVBoxLayout.__init__(self, parent)

        self.scroll_area = QScrollArea()

        self.grid_frame = QFrame(self.scroll_area)

        self.grid_layout = QGridLayout(self.grid_frame)

        self.scroll_area.setWidget(self.grid_frame)
        self.scroll_area.setWidgetResizable(True)
        self.scroll_area.setBackgroundRole(QPalette.Light)

        self.addWidget(self.scroll_area)

        self.current_column = 0

        self.current_row = 0

        self.initial_grid = True

        self.max_columns = 5

        self.current_width = 0

        self.child_widgets = list()

    def add_widget_by_label(self, label):
        if label != None:
            self.grid_layout.addWidget(label, self.current_row, self.current_column)

            print('Added to row: ' + str(self.current_row))
            print('Added to column: ' + str(self.current_column))

            self.grid_frame.updateGeometry()

            self.child_widgets.append(label)

            # Update the row and column indices appropriately
            self.current_column += 1

            if self.current_column == self.max_columns:
                self.current_column = 0
                self.current_row += 1

            self.print_width()

    def remove_widget_by_label(self, label):
        if label != None:
            self.grid_layout.removeWidget(label)

            label.deleteLater()

            self.grid_frame.updateGeometry()

            self.child_widgets.remove(label)

            # Update the row and column indices appropriately
            self.current_column -= 1

            if self.current_column < 0 and self.current_row > 0:
                self.current_column = self.max_columns
                self.current_row -= 1
            elif self.current_column < 0:
                self.current_column = 0

            for child in self.child_widgets:
                self.grid_layout.removeWidget(child)

            current_column = 0
            current_row = 0
            for child in self.child_widgets:
                self.grid_layout.addWidget(child, current_row, current_column)
                current_column += 1
                if current_column == self.max_columns:
                    current_column = 0
                    current_row += 1

    def print_width(self, label=None):
        print('Width of grid frame: ' + str(self.grid_frame.width()))
        #print 'Width of grid layout: ' + str(self.grid_layout.width())
        print('Width of scrolled area: ' + str(self.scroll_area.width()))
        print('Width of vbox layout: ' + str(self.scroll_area.width()))
        if label != None:
            print('Width of new label: ' + str(label.width()))
开发者ID:jhavstad,项目名称:model_runner,代码行数:88,代码来源:PyQtExtras.py

示例12: ImageViewer

# 需要导入模块: from PyQt5.QtWidgets import QScrollArea [as 别名]
# 或者: from PyQt5.QtWidgets.QScrollArea import setBackgroundRole [as 别名]
class ImageViewer(QMainWindow):
    def __init__(self):
        super(ImageViewer, self).__init__()

        self.printer = QPrinter()
        self.scaleFactor = 0.0

        self.imageLabel = QLabel()
        self.imageLabel.setBackgroundRole(QPalette.Base)
        self.imageLabel.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored)
        self.imageLabel.setScaledContents(True)

        self.scrollArea = QScrollArea()
        self.scrollArea.setBackgroundRole(QPalette.Dark)
        self.scrollArea.setWidget(self.imageLabel)
        self.setCentralWidget(self.scrollArea)

        self.createActions()
        self.createMenus()
        self.initUI()

        self.setWindowTitle("Encrypter Pictures")
        self.resize(500, 400)

    def initUI(self):

        encrypt = QAction(QIcon(CURRENT_DIR + '/encrypt.png'), 'Encrypt', self)
        encrypt.setShortcut('Ctrl+D')
        encrypt.triggered.connect(self.buttonClicked)

        open_file= QAction(QIcon(CURRENT_DIR + '/open.png'), 'Exit', self)
        open_file.triggered.connect(self.open)

        exitAction = QAction(QIcon(CURRENT_DIR + '/exit24.png'), 'Exit', self)
        exitAction.triggered.connect(qApp.quit)

        self.toolbar = self.addToolBar('Exit')
        self.toolbar.addAction(open_file)
        self.toolbar.addAction(encrypt)
        self.toolbar.addAction(exitAction)

        self.statusBar()

    def buttonClicked(self):
        try:
            self.statusBar().showMessage("Encrypting: " + self.fileName)
            self.output_path = cript(self.fileName)
            self.show_image()
            self.statusBar().showMessage("Salve on: " + self.output_path)
        except AttributeError:
            self.statusBar().showMessage("Select an image")

    def show_image(self):
        """docstring for show_image"""
        if self.output_path:
            image = QImage(self.output_path)
            if image.isNull():
                QMessageBox.information(self, "Image Viewer",
                        "Cannot load %s." % self.output_path)
                return

            self.imageLabel.setPixmap(QPixmap.fromImage(image))
            self.scaleFactor = 1.0

            self.printAct.setEnabled(True)
            self.fitToWindowAct.setEnabled(True)
            self.updateActions()

            if not self.fitToWindowAct.isChecked():
                self.imageLabel.adjustSize()
    def open(self):
        self.fileName, _ = QFileDialog.getOpenFileName(self, "Open File",
                QDir.currentPath())
        if self.fileName:
            image = QImage(self.fileName)
            if image.isNull():
                QMessageBox.information(self, "Image Viewer",
                        "Cannot load %s." % self.fileName)
                return

            self.imageLabel.setPixmap(QPixmap.fromImage(image))
            self.scaleFactor = 1.0

            self.printAct.setEnabled(True)
            self.fitToWindowAct.setEnabled(True)
            self.updateActions()

            if not self.fitToWindowAct.isChecked():
                self.imageLabel.adjustSize()

    def print_(self):
        dialog = QPrintDialog(self.printer, self)
        if dialog.exec_():
            painter = QPainter(self.printer)
            rect = painter.viewport()
            size = self.imageLabel.pixmap().size()
            size.scale(rect.size(), Qt.KeepAspectRatio)
            painter.setViewport(
                rect.x(),
                rect.y(),
#.........这里部分代码省略.........
开发者ID:TiagoAssuncao,项目名称:encrypter_pictures,代码行数:103,代码来源:gui.py

示例13: init_right_panel

# 需要导入模块: from PyQt5.QtWidgets import QScrollArea [as 别名]
# 或者: from PyQt5.QtWidgets.QScrollArea import setBackgroundRole [as 别名]
	def init_right_panel(self):

		#def title_def(title):
		#	title_lbl = QLabel(title)
		#	f = QFont()
		#	f.setPixelSize(16)
		#	title_lbl.setFont(f)
		#	return title_lbl

		def groupbox(name, layout, parent, add_in_layout=None):
			"""
			Makes a groupbox and a layout for you
			Returns groupbox and layout
			"""
			g = QGroupBox(name, parent)
			l = layout(g)
			if add_in_layout:
				if isinstance(add_in_layout, QFormLayout):
					add_in_layout.addRow(g)
				else:
					add_in_layout.addWidget(g)
			return g, l

		def option_lbl_checkbox(text, optiontext, parent=None):
			l = QLabel(text)
			c = QCheckBox(text, parent)
			return l, c

		def new_tab(name, parent, scroll=False):
			"""
			Creates a new tab.
			Returns new tab page widget and it's layout
			"""
			new_t = QWidget(parent)
			new_l = QFormLayout(new_t)
			if scroll:
				scr = QScrollArea(parent)
				scr.setBackgroundRole(QPalette.Base)
				scr.setWidget(new_t)
				scr.setWidgetResizable(True)
				parent.addTab(scr, name)
				return new_t, new_l
			else:
				parent.addTab(new_t, name)
			return new_t, new_l


		# App
		application = QTabWidget(self)
		self.application_index = self.right_panel.addWidget(application)
		application_general, app_general_m_l = new_tab('General', application, True)

		# App / General / gallery
		app_gallery_page, app_gallery_l = new_tab('Gallery', application, True)
		self.subfolder_as_chapters = QCheckBox("Subdirectiories should be treated as standalone galleries instead of chapters (applies in archives too)")
		self.subfolder_as_chapters.setToolTip("This option will enable creating standalone galleries for each subdirectiories found recursively when importing."+
										"\nDefault action is treating each subfolder found as chapters of a gallery.")
		extract_gallery_info = QLabel("Note: This option has no effect when turned off if path to viewer is not specified.")
		self.extract_gallery_before_opening = QCheckBox("Extract archive before opening (only turn off if your viewer supports it)")
		self.open_galleries_sequentially = QCheckBox("Open chapters sequentially (Note: has no effect if path to viewer is not specified)")
		subf_info = QLabel("Behaviour of 'Scan for new galleries on startup' option will be affected.")
		subf_info.setWordWrap(True)
		app_gallery_l.addRow('Note:', subf_info)
		app_gallery_l.addRow(self.subfolder_as_chapters)
		app_gallery_l.addRow(extract_gallery_info)
		app_gallery_l.addRow(self.extract_gallery_before_opening)
		app_gallery_l.addRow(self.open_galleries_sequentially)
		self.scroll_to_new_gallery = QCheckBox("Scroll to newly added gallery")
		self.scroll_to_new_gallery.setDisabled(True)
		app_gallery_l.addRow(self.scroll_to_new_gallery)
		self.move_imported_gs, move_imported_gs_l = groupbox('Move imported galleries',
													   QFormLayout, app_gallery_page)
		self.move_imported_gs.setCheckable(True)
		self.move_imported_gs.setToolTip("Move imported galleries to specified folder.")
		self.move_imported_def_path = PathLineEdit()
		move_imported_gs_l.addRow('Directory:', self.move_imported_def_path)
		app_gallery_l.addRow(self.move_imported_gs)
		self.rename_g_source_group, rename_g_source_l = groupbox('Rename gallery source',
													  QFormLayout, app_gallery_page)
		self.rename_g_source_group.setCheckable(True)
		self.rename_g_source_group.setDisabled(True)
		app_gallery_l.addRow(self.rename_g_source_group)
		rename_g_source_l.addRow(QLabel("Check what to include when renaming gallery source. (Same order)"))
		rename_g_source_flow_l = FlowLayout()
		rename_g_source_l.addRow(rename_g_source_flow_l)
		self.rename_artist = QCheckBox("Artist")
		self.rename_title = QCheckBox("Title")
		self.rename_lang = QCheckBox("Language")
		self.rename_title.setChecked(True)
		self.rename_title.setDisabled(True)
		rename_g_source_flow_l.addWidget(self.rename_artist)
		rename_g_source_flow_l.addWidget(self.rename_title)
		rename_g_source_flow_l.addWidget(self.rename_lang)
		random_gallery_opener, random_g_opener_l = groupbox('Random Gallery Opener', QFormLayout, app_gallery_page)
		app_gallery_l.addRow(random_gallery_opener)
		self.open_random_g_chapters = QCheckBox("Open random gallery chapters")
		random_g_opener_l.addRow(self.open_random_g_chapters)

		# App / General / Search
		app_search, app_search_layout = groupbox('Search', QFormLayout, application_general)
#.........这里部分代码省略.........
开发者ID:darmstard,项目名称:happypanda,代码行数:103,代码来源:settingsdialog.py

示例14: ImageViewer

# 需要导入模块: from PyQt5.QtWidgets import QScrollArea [as 别名]
# 或者: from PyQt5.QtWidgets.QScrollArea import setBackgroundRole [as 别名]
class ImageViewer(QMainWindow):
    def __init__(self):
        super(ImageViewer, self).__init__()

        self.printer = QPrinter()
        self.scaleFactor = 0.0

        self.imageLabel = QLabel()
        self.imageLabel.setBackgroundRole(QPalette.Base)
        self.imageLabel.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored)
        self.imageLabel.setScaledContents(True)

        self.scrollArea = QScrollArea()
        self.scrollArea.setBackgroundRole(QPalette.Dark)
        self.scrollArea.setWidget(self.imageLabel)
        self.setCentralWidget(self.scrollArea)

        self.createActions()
        self.createMenus()

        self.setWindowTitle("Image Viewer")
        self.resize(500, 400)

    def open(self):
        fileName, _ = QFileDialog.getOpenFileName(self, "Open File",
                QDir.currentPath())
        if fileName:
            image = QImage(fileName)
            if image.isNull():
                QMessageBox.information(self, "Image Viewer",
                        "Cannot load %s." % fileName)
                return

            self.imageLabel.setPixmap(QPixmap.fromImage(image))
            self.scaleFactor = 1.0

            self.printAct.setEnabled(True)
            self.fitToWindowAct.setEnabled(True)
            self.updateActions()

            if not self.fitToWindowAct.isChecked():
                self.imageLabel.adjustSize()

    def print_(self):
        dialog = QPrintDialog(self.printer, self)
        if dialog.exec_():
            painter = QPainter(self.printer)
            rect = painter.viewport()
            size = self.imageLabel.pixmap().size()
            size.scale(rect.size(), Qt.KeepAspectRatio)
            painter.setViewport(rect.x(), rect.y(), size.width(), size.height())
            painter.setWindow(self.imageLabel.pixmap().rect())
            painter.drawPixmap(0, 0, self.imageLabel.pixmap())

    def zoomIn(self):
        self.scaleImage(1.25)

    def zoomOut(self):
        self.scaleImage(0.8)

    def normalSize(self):
        self.imageLabel.adjustSize()
        self.scaleFactor = 1.0

    def fitToWindow(self):
        fitToWindow = self.fitToWindowAct.isChecked()
        self.scrollArea.setWidgetResizable(fitToWindow)
        if not fitToWindow:
            self.normalSize()

        self.updateActions()

    def about(self):
        QMessageBox.about(self, "About Image Viewer",
                "<p>The <b>Image Viewer</b> example shows how to combine "
                "QLabel and QScrollArea to display an image. QLabel is "
                "typically used for displaying text, but it can also display "
                "an image. QScrollArea provides a scrolling view around "
                "another widget. If the child widget exceeds the size of the "
                "frame, QScrollArea automatically provides scroll bars.</p>"
                "<p>The example demonstrates how QLabel's ability to scale "
                "its contents (QLabel.scaledContents), and QScrollArea's "
                "ability to automatically resize its contents "
                "(QScrollArea.widgetResizable), can be used to implement "
                "zooming and scaling features.</p>"
                "<p>In addition the example shows how to use QPainter to "
                "print an image.</p>")

    def createActions(self):
        self.openAct = QAction("&Open...", self, shortcut="Ctrl+O",
                triggered=self.open)

        self.printAct = QAction("&Print...", self, shortcut="Ctrl+P",
                enabled=False, triggered=self.print_)

        self.exitAct = QAction("E&xit", self, shortcut="Ctrl+Q",
                triggered=self.close)

        self.zoomInAct = QAction("Zoom &In (25%)", self, shortcut="Ctrl++",
                enabled=False, triggered=self.zoomIn)
#.........这里部分代码省略.........
开发者ID:lmann03,项目名称:roadside-viewer,代码行数:103,代码来源:imageviewer.py

示例15: init_right_panel

# 需要导入模块: from PyQt5.QtWidgets import QScrollArea [as 别名]
# 或者: from PyQt5.QtWidgets.QScrollArea import setBackgroundRole [as 别名]
	def init_right_panel(self):

		#def title_def(title):
		#	title_lbl = QLabel(title)
		#	f = QFont()
		#	f.setPixelSize(16)
		#	title_lbl.setFont(f)
		#	return title_lbl

		# App
		application = QTabWidget()
		self.application_index = self.right_panel.addWidget(application)
		application_general = QWidget()
		application.addTab(application_general, 'General')
		application.setTabEnabled(0, False)

		# App / Monitor
		app_monitor_page = QScrollArea()
		app_monitor_page.setBackgroundRole(QPalette.Base)
		app_monitor_dummy = QWidget()
		app_monitor_page.setWidgetResizable(True)
		app_monitor_page.setWidget(app_monitor_dummy)
		application.addTab(app_monitor_page, 'Monitoring')
		application.setCurrentIndex(1)
		app_monitor_m_l = QVBoxLayout(app_monitor_dummy)
		# App / Monitor / misc
		app_monitor_misc_group = QGroupBox('General *', self)
		app_monitor_m_l.addWidget(app_monitor_misc_group)
		app_monitor_misc_m_l = QFormLayout(app_monitor_misc_group)
		monitor_info = QLabel('Directory monitoring will monitor the specified directories for any'+
						' gallery events. For example if you delete a gallery source in one of your'+
						' monitored directories the application will inform you about it, and ask if'+
						' you want to delete the gallery from the application as well.')
		monitor_info.setWordWrap(True)
		app_monitor_misc_m_l.addRow(monitor_info)
		self.enable_monitor = QCheckBox('Enable directory monitoring')
		app_monitor_misc_m_l.addRow(self.enable_monitor)
		self.look_new_gallery_startup = QGroupBox('Scan for new galleries on startup', self)
		app_monitor_misc_m_l.addRow(self.look_new_gallery_startup)
		self.look_new_gallery_startup.setCheckable(True)
		look_new_gallery_startup_m_l = QVBoxLayout(self.look_new_gallery_startup)
		self.auto_add_new_galleries = QCheckBox('Automatically add found galleries')
		look_new_gallery_startup_m_l.addWidget(self.auto_add_new_galleries)

		# App / Monitor / folders
		app_monitor_group = QGroupBox('Directories *', self)
		app_monitor_m_l.addWidget(app_monitor_group, 1)
		app_monitor_folders_m_l = QVBoxLayout(app_monitor_group)
		app_monitor_folders_add = QPushButton('+')
		app_monitor_folders_add.clicked.connect(self.add_folder_monitor)
		app_monitor_folders_add.setMaximumWidth(20)
		app_monitor_folders_add.setMaximumHeight(20)
		app_monitor_folders_m_l.addWidget(app_monitor_folders_add, 0, Qt.AlignRight)
		self.folders_layout = QFormLayout()
		app_monitor_folders_m_l.addLayout(self.folders_layout)

		# Web
		web = QTabWidget()
		self.web_index = self.right_panel.addWidget(web)
		web_general_page = QScrollArea()
		web_general_page.setBackgroundRole(QPalette.Base)
		web_general_page.setWidgetResizable(True)
		web.addTab(web_general_page, 'General')
		web_general_dummy = QWidget()
		web_general_page.setWidget(web_general_dummy)
		web_general_m_l = QVBoxLayout(web_general_dummy)
		metadata_fetcher_group = QGroupBox('Metadata', self)
		web_general_m_l.addWidget(metadata_fetcher_group)
		metadata_fetcher_m_l = QFormLayout(metadata_fetcher_group)
		self.default_ehen_url = QRadioButton('g.e-hentai.org', metadata_fetcher_group)
		self.exhentai_ehen_url = QRadioButton('exhentai.org', metadata_fetcher_group)
		ehen_url_l = QHBoxLayout()
		ehen_url_l.addWidget(self.default_ehen_url)
		ehen_url_l.addWidget(self.exhentai_ehen_url, 1)
		metadata_fetcher_m_l.addRow('Default URL:', ehen_url_l)
		self.continue_a_metadata_fetcher = QCheckBox('Continue from where auto metadata fetcher left off')
		metadata_fetcher_m_l.addRow(self.continue_a_metadata_fetcher)
		self.use_jpn_title = QCheckBox('Use japanese title')
		metadata_fetcher_m_l.addRow(self.use_jpn_title)
		time_offset_info = QLabel('To avoid getting banned, we need to impose a delay between our requests.'+
							' I have made it so you cannot set the delay lower than the recommended (I don\'t'+
							' want you to get banned, anon).\nSpecify the delay between requests in seconds.')
		time_offset_info.setWordWrap(True)
		self.web_time_offset = QSpinBox()
		self.web_time_offset.setMaximumWidth(40)
		self.web_time_offset.setMinimum(4)
		self.web_time_offset.setMaximum(99)
		metadata_fetcher_m_l.addRow(time_offset_info)
		metadata_fetcher_m_l.addRow('Requests delay in', self.web_time_offset)
		replace_metadata_info = QLabel('When fetching for metadata the new metadata will be appended'+
								 ' to the gallery by default. This means that new data will only be set if'+
								 ' the field was empty. There is however a special case for namespace & tags.'+
								 ' We go through all the new namespace & tags to only add those that'+
								 ' do not already exists.\n\nEnabling this option makes it so that a gallery\'s old data'+
								 ' are deleted and replaced with the new data.')
		replace_metadata_info.setWordWrap(True)
		self.replace_metadata = QCheckBox('Replace old metadata with new metadata')
		metadata_fetcher_m_l.addRow(replace_metadata_info)
		metadata_fetcher_m_l.addRow(self.replace_metadata)
		first_hit_info = QLabel('By default, you get to choose which gallery to extract metadata from when'+
#.........这里部分代码省略.........
开发者ID:utterbull,项目名称:happypanda,代码行数:103,代码来源:settingsdialog.py


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