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


Python QScrollArea.setHorizontalScrollBarPolicy方法代码示例

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


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

示例1: createDialogCenterWidget

# 需要导入模块: from PyQt5.QtWidgets import QScrollArea [as 别名]
# 或者: from PyQt5.QtWidgets.QScrollArea import setHorizontalScrollBarPolicy [as 别名]
 def createDialogCenterWidget(self, formation):
   '''
   Scrolling list of editor widgets for editing StyleProperty.
   List comprises labels, and labeled editing widgets.
   But labels are indented as a tree.
   
   Canonical way: nest widget, layout, scrollarea
   '''
   formationLayout = formation.getLayout(top=True)
   viewport = QWidget()
   viewport.setLayout(formationLayout)
   
   # A hack so scroll bars not obscure buttons?
   # !!! left, top, right, bottom (not top, left... as usual.)
   viewport.setContentsMargins(10, 10, 10, 10)
   
   scrollArea = QScrollArea()
   scrollArea.setWidget(viewport)
   
   '''
   Assert width of contents is less than screen width (even mobile screens.)
   Can't assert height of contents less than screen height,
   e.g. a stylesheet has large height that must be vertically scrolled.
   Note this is statically determined, at design time,
   by ensuring that all rows are narrow.
   TODO dynamically enable horizontal and vertical scroll bar policy
   by calculations based on screen size and size of dialog needs?
   
   At one time, this not work: it obscured contents.
   Before I shortened many labels and model names???
   '''
   scrollArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
   return scrollArea
开发者ID:bootchk,项目名称:documentStyle,代码行数:35,代码来源:styleDialogWidget.py

示例2: initUI

# 需要导入模块: from PyQt5.QtWidgets import QScrollArea [as 别名]
# 或者: from PyQt5.QtWidgets.QScrollArea import setHorizontalScrollBarPolicy [as 别名]
    def initUI(self):
        self.setWindowTitle('Twitter Client')
        self.setWindowIcon(QIcon("twitter.svg"))
        QIcon.setThemeName("Adwaita")

        lay = QVBoxLayout(self)
        scr = QScrollArea(self)
        scr.setWidgetResizable(True)
        scr.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)

        lay2 = QVBoxLayout()
        self.setLayout(lay)
        placehold = QWidget()
        lay.addWidget(scr)
        scr.setWidget(placehold)
        placehold.setLayout(lay2)
        self.lay = lay2

        lay2.setSpacing(0)
        lay.setSpacing(0)
        lay.setContentsMargins(0, 0, 0, 0)

        but = QPushButton("Refresh")
        lay.addWidget(but)
        but.pressed.connect(self.fetch_tweets)

        self.show()
开发者ID:grsakea,项目名称:pyt,代码行数:29,代码来源:window.py

示例3: __init__

# 需要导入模块: from PyQt5.QtWidgets import QScrollArea [as 别名]
# 或者: from PyQt5.QtWidgets.QScrollArea import setHorizontalScrollBarPolicy [as 别名]
 def __init__(self, config, app, plugins):
     QDialog.__init__(self, None)
     BaseWizard.__init__(self, config, plugins)
     self.setWindowTitle('Vialectrum  -  ' + _('Install Wizard'))
     self.app = app
     self.config = config
     # Set for base base class
     self.language_for_seed = config.get('language')
     self.setMinimumSize(600, 400)
     self.accept_signal.connect(self.accept)
     self.title = QLabel()
     self.main_widget = QWidget()
     self.back_button = QPushButton(_("Back"), self)
     self.back_button.setText(_('Back') if self.can_go_back() else _('Cancel'))
     self.next_button = QPushButton(_("Next"), self)
     self.next_button.setDefault(True)
     self.logo = QLabel()
     self.please_wait = QLabel(_("Please wait..."))
     self.please_wait.setAlignment(Qt.AlignCenter)
     self.icon_filename = None
     self.loop = QEventLoop()
     self.rejected.connect(lambda: self.loop.exit(0))
     self.back_button.clicked.connect(lambda: self.loop.exit(1))
     self.next_button.clicked.connect(lambda: self.loop.exit(2))
     outer_vbox = QVBoxLayout(self)
     inner_vbox = QVBoxLayout()
     inner_vbox.addWidget(self.title)
     inner_vbox.addWidget(self.main_widget)
     inner_vbox.addStretch(1)
     inner_vbox.addWidget(self.please_wait)
     inner_vbox.addStretch(1)
     scroll_widget = QWidget()
     scroll_widget.setLayout(inner_vbox)
     scroll = QScrollArea()
     scroll.setWidget(scroll_widget)
     scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
     scroll.setWidgetResizable(True)
     icon_vbox = QVBoxLayout()
     icon_vbox.addWidget(self.logo)
     icon_vbox.addStretch(1)
     hbox = QHBoxLayout()
     hbox.addLayout(icon_vbox)
     hbox.addSpacing(5)
     hbox.addWidget(scroll)
     hbox.setStretchFactor(scroll, 1)
     outer_vbox.addLayout(hbox)
     outer_vbox.addLayout(Buttons(self.back_button, self.next_button))
     self.set_icon('vialectrum.png')
     self.show()
     self.raise_()
     self.refresh_gui()  # Need for QT on MacOSX.  Lame.
开发者ID:vialectrum,项目名称:vialectrum,代码行数:53,代码来源:installwizard.py

示例4: __init__

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

        # Add a scrollArea that if they are more plugins that fit into the
        # settings page
        scrollArea = QScrollArea(self)
        scrollArea.setWidgetResizable(True)
        scrollArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        baseLayout = QVBoxLayout()
        self.setLayout(baseLayout)
        baseWidget = QWidget()
        scrollArea.setWidget(baseWidget)
        baseLayout.addWidget(scrollArea)

        self._vbox = QVBoxLayout()
        baseWidget.setLayout(self._vbox)
开发者ID:hlamer,项目名称:enki,代码行数:18,代码来源:pluginspage.py

示例5: Browser

# 需要导入模块: from PyQt5.QtWidgets import QScrollArea [as 别名]
# 或者: from PyQt5.QtWidgets.QScrollArea import setHorizontalScrollBarPolicy [as 别名]
class Browser(QWidget):
	def __init__(self,parent_,url,cname,fname):
		super(Browser,self).__init__(parent_)
		self.parent_=parent_
		self.initUI(url,cname,fname)

	def initUI(self,url,cname,fname):
		lbl = QLabel()
		lbl.setText('Forum News - '+cname)
		lbl.setObjectName('hlbl')
		self.browser = QTextBrowser()
		self.browser.document().setDefaultStyleSheet('p{font-size:12px;} div{margin-left:20px;}')

		f = open(url,'r')
		ftext = '<div><br><h3><b>%s</b></h3>'%fname + str(f.read())+'<br></div>'
		self.browser.setHtml(ftext)
		self.browser.setFrameStyle(QFrame.NoFrame)

		self.backBtn = QPushButton(QIcon(':/Assets/close2.png'),'Close')
		self.backBtn.setObjectName('backBtn')
		self.backBtn.clicked.connect(partial(self.parent_.closeTextBrowser))
		frame = topFrame(self.backBtn,lbl)
		frame.setObjectName('nFrameEven')


		self.widget = QWidget(self)
		self.vbox = QVBoxLayout()
		self.vbox.setSpacing(3)
		self.vbox.addWidget(frame)
		self.vbox.addWidget(self.browser)

		self.vbox.setContentsMargins(0,0,0,0)
		self.widget.setLayout(self.vbox)
		self.scroll = QScrollArea(self)
		self.scroll.setWidget(self.widget)
		self.scroll.setWidgetResizable(True)
		self.scroll.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
		self.scroll.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)

		vbox1 = QVBoxLayout()
		vbox1.setContentsMargins(0,0,0,0)
		vbox1.setSpacing(0)

		vbox1.addWidget(self.scroll)
		self.setLayout(vbox1)
开发者ID:AkshayAgarwal007,项目名称:Moodly,代码行数:47,代码来源:view.py

示例6: __init__

# 需要导入模块: from PyQt5.QtWidgets import QScrollArea [as 别名]
# 或者: from PyQt5.QtWidgets.QScrollArea import setHorizontalScrollBarPolicy [as 别名]
    def __init__(self, diffs, parent=None):
        super(PayDiffsWidget, self).__init__()

        widget = QWidget()
        diffs_layout = QVBoxLayout()
        for employee in diffs:
            box = self.create_box(employee, diffs[employee])
            diffs_layout.addWidget(box)
        widget.setLayout(diffs_layout)

        scroll = QScrollArea()
        scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        scroll.setWidgetResizable(True)
        scroll.setWidget(widget)

        widget_layout = QVBoxLayout()
        widget_layout.addWidget(scroll)
        self.setLayout(widget_layout)
开发者ID:Davincier,项目名称:payrun,代码行数:21,代码来源:paydiffs_widget.py

示例7: __init__

# 需要导入模块: from PyQt5.QtWidgets import QScrollArea [as 别名]
# 或者: from PyQt5.QtWidgets.QScrollArea import setHorizontalScrollBarPolicy [as 别名]
 def __init__(self, path, parent=None):
     super(Window, self).__init__()
     self.config = configparser.ConfigParser()
     self.config.read('prefs.cfg')
     if Window.menu is None:
         Window.menu = GlobalMenu()
     Window.menu.new_window_signal.connect(self.on_parent_window)
     Window.menu.clean_up_signal.connect(self.on_clean_up)
     Window.menu.delete_signal.connect(self.on_delete)
     Window.menu.rename_signal.connect(self.on_rename)
     Window.menu.file_signal.connect(self.on_file)
     Window.menu.drawer_signal.connect(self.on_drawer)
     Window.menu.trash_action_signal.connect(self.on_empty_trash)
     self.setWindowTitle(path.rsplit('/', 1)[-1])
     Window.pattern = self.config.get("background", "file")
     self.path = path
     self.widget = QWidget()
     self.palette = QPalette()
     self.palette.setBrush(
         QPalette.Background, QBrush(QPixmap(self.pattern)))
     self.widget.setPalette(self.palette)
     layout = QVBoxLayout(self)
     self._drag_widget = DragWidget(path, parent=self)
     self._drag_widget.new_window_signal.connect(self.on_new_window)
     self._drag_widget.query.connect(self.on_query)
     layout.addWidget(self._drag_widget)
     self.widget.setLayout(layout)
     scroll = QScrollArea()
     scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
     scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
     scroll.setWidgetResizable(True)
     scroll.setWidget(self.widget)
     vlayout = QVBoxLayout(self)
     vlayout.setContentsMargins(0, 0, 0, 0)
     vlayout.setSpacing(0)
     vlayout.addWidget(scroll)
     self.setLayout(vlayout)
     Window.child_windows.append(self)
     self.center()
     self.show()
开发者ID:freeaks,项目名称:filer,代码行数:42,代码来源:filer.py

示例8: get_scrollable

# 需要导入模块: from PyQt5.QtWidgets import QScrollArea [as 别名]
# 或者: from PyQt5.QtWidgets.QScrollArea import setHorizontalScrollBarPolicy [as 别名]
def get_scrollable(layout):
    """
    Convert layout to a scrollable widget.
    """

    widget = QWidget()

    groupbox = QGroupBox()
    groupbox.setLayout(layout)
    scroll = QScrollArea()
    scroll.setWidget(groupbox)
    scroll.setWidgetResizable(True)
    scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
    scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)

    this_vbox = QVBoxLayout(widget)
    this_vbox.addWidget(scroll)
    this_vbox.setContentsMargins(0, 0, 0, 0)
    this_vbox.setSpacing(0)
    layout.setContentsMargins(0, 0, 0, 0)
    layout.setSpacing(0)
    return widget
开发者ID:aq1,项目名称:Hospital-Helper-2,代码行数:24,代码来源:utils.py

示例9: __init__

# 需要导入模块: from PyQt5.QtWidgets import QScrollArea [as 别名]
# 或者: from PyQt5.QtWidgets.QScrollArea import setHorizontalScrollBarPolicy [as 别名]
    def __init__(self, parent, repo):
        """QWidget Dictionary -> Void
        Consumes the parent and the repository dictionary and sets up the
        install page in the settings area"""
        QWidget.__init__(self, parent)
        self._userPlugins = helper.getPlugins()
        self._repo = repo

        # Add a scrollArea that if they are more plugins that fit into the
        # settings page
        scrollArea = QScrollArea(self)
        scrollArea.setWidgetResizable(True)
        scrollArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        baseLayout = QVBoxLayout()
        baseLayout.setAlignment(Qt.AlignTop)
        self.setLayout(baseLayout)
        baseWidget = QWidget()
        scrollArea.setWidget(baseWidget)
        baseLayout.addWidget(scrollArea)

        self._vbox = QVBoxLayout()
        baseWidget.setLayout(self._vbox)
开发者ID:bjones1,项目名称:enki,代码行数:24,代码来源:installpage.py

示例10: __init__

# 需要导入模块: from PyQt5.QtWidgets import QScrollArea [as 别名]
# 或者: from PyQt5.QtWidgets.QScrollArea import setHorizontalScrollBarPolicy [as 别名]
 def __init__(self, path, parent=None):
     super(Window, self).__init__()
     self.setWindowTitle(path)
     # self.pattern = "images/pattern.png"
     self.pattern = os.path.dirname(os.path.realpath(__file__)) + "/images/pattern7.png"
     self.path = path
     self.widget = QWidget()
     self.palette = QPalette()
     self.palette.setBrush(
         QPalette.Background, QBrush(QPixmap(self.pattern)))
     self.widget.setPalette(self.palette)
     layout = QVBoxLayout(self)
     self._drag_widget = DragWidget(path)
     self._drag_widget.windowclass_signal.connect(self.on_make_new_window)
     self._drag_widget.query.connect(self.on_query)
     layout.addWidget(self._drag_widget)
     self.widget.setLayout(layout)
     scroll = QScrollArea()
     scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
     scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
     scroll.setWidgetResizable(True)
     scroll.setWidget(self.widget)
     self.setStyleSheet("""
         QScrollBar:vertical { border:none; width:6px }
         QScrollBar::handle:vertical { background: lightgray; }
         QScrollBar::add-line:vertical { background: none; }
         QScrollBar::sub-line:vertical { background: none; }
         QScrollBar:horizontal { border:none; height:6px }
         QScrollBar::handle:horizontal { background: lightgray; }
         QScrollBar::add-line:horizontal { background: none; }
         QScrollBar::sub-line:horizontal { background: none; }
         """)
     vlayout = QVBoxLayout(self)
     vlayout.setContentsMargins(0, 0, 0, 0)
     vlayout.setSpacing(0)
     vlayout.addWidget(scroll)
     self.setLayout(vlayout)
     self.show()
开发者ID:ReneVolution,项目名称:filer,代码行数:40,代码来源:Kickstart.py

示例11: ConfigurationWidget

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

#.........这里部分代码省略.........
    def __setupUi(self):
        """
        Private method to perform the general setup of the configuration
        widget.
        """
        self.setObjectName("ConfigurationDialog")
        self.resize(900, 650)
        self.verticalLayout_2 = QVBoxLayout(self)
        self.verticalLayout_2.setSpacing(6)
        self.verticalLayout_2.setContentsMargins(6, 6, 6, 6)
        self.verticalLayout_2.setObjectName("verticalLayout_2")
        
        self.configSplitter = QSplitter(self)
        self.configSplitter.setOrientation(Qt.Horizontal)
        self.configSplitter.setObjectName("configSplitter")
        
        self.configListWidget = QWidget(self.configSplitter)
        self.leftVBoxLayout = QVBoxLayout(self.configListWidget)
        self.leftVBoxLayout.setContentsMargins(0, 0, 0, 0)
        self.leftVBoxLayout.setSpacing(0)
        self.leftVBoxLayout.setObjectName("leftVBoxLayout")
        self.configListSearch = E5ClearableLineEdit(
            self, self.tr("Enter search text..."))
        self.configListSearch.setObjectName("configListSearch")
        self.leftVBoxLayout.addWidget(self.configListSearch)
        self.configList = QTreeWidget()
        self.configList.setObjectName("configList")
        self.leftVBoxLayout.addWidget(self.configList)
        self.configListSearch.textChanged.connect(self.__searchTextChanged)
        
        self.scrollArea = QScrollArea(self.configSplitter)
        self.scrollArea.setFrameShape(QFrame.NoFrame)
        self.scrollArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        self.scrollArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        self.scrollArea.setWidgetResizable(False)
        self.scrollArea.setObjectName("scrollArea")
        
        self.configStack = QStackedWidget()
        self.configStack.setFrameShape(QFrame.Box)
        self.configStack.setFrameShadow(QFrame.Sunken)
        self.configStack.setObjectName("configStack")
        self.scrollArea.setWidget(self.configStack)
        
        self.emptyPage = QWidget()
        self.emptyPage.setGeometry(QRect(0, 0, 372, 591))
        self.emptyPage.setObjectName("emptyPage")
        self.vboxlayout = QVBoxLayout(self.emptyPage)
        self.vboxlayout.setSpacing(6)
        self.vboxlayout.setContentsMargins(6, 6, 6, 6)
        self.vboxlayout.setObjectName("vboxlayout")
        spacerItem = QSpacerItem(
            20, 20, QSizePolicy.Minimum, QSizePolicy.Expanding)
        self.vboxlayout.addItem(spacerItem)
        self.emptyPagePixmap = QLabel(self.emptyPage)
        self.emptyPagePixmap.setAlignment(Qt.AlignCenter)
        self.emptyPagePixmap.setObjectName("emptyPagePixmap")
        self.emptyPagePixmap.setPixmap(
            QPixmap(os.path.join(getConfig('ericPixDir'), 'eric.png')))
        self.vboxlayout.addWidget(self.emptyPagePixmap)
        self.textLabel1 = QLabel(self.emptyPage)
        self.textLabel1.setAlignment(Qt.AlignCenter)
        self.textLabel1.setObjectName("textLabel1")
        self.vboxlayout.addWidget(self.textLabel1)
        spacerItem1 = QSpacerItem(
            20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
        self.vboxlayout.addItem(spacerItem1)
开发者ID:pycom,项目名称:EricShort,代码行数:70,代码来源:ConfigurationDialog.py

示例12: GlyphCollectionWidget

# 需要导入模块: from PyQt5.QtWidgets import QScrollArea [as 别名]
# 或者: from PyQt5.QtWidgets.QScrollArea import setHorizontalScrollBarPolicy [as 别名]
class GlyphCollectionWidget(QWidget):
    def __init__(self, parent=None):
        super(GlyphCollectionWidget, self).__init__(parent)
        self.setAttribute(Qt.WA_KeyCompression)
        self._glyphs = []
        # TODO: hide behind a façade
        self.squareSize = 56
        self._columns = 10
        self._selection = set()
        self._oldSelection = None
        self._lastSelectedCell = None

        self.characterSelectedCallback = None
        self.doubleClickCallback = None
        self.updateCurrentGlyph = False
        self._maybeDragPosition = None

        self.setFocusPolicy(Qt.ClickFocus)
        self._currentDropIndex = None
        self._scrollArea = QScrollArea(parent)
        self._scrollArea.dragEnterEvent = self.pipeDragEnterEvent
        self._scrollArea.dragMoveEvent = self.pipeDragMoveEvent
        self._scrollArea.dragLeaveEvent = self.pipeDragLeaveEvent
        self._scrollArea.dropEvent = self.pipeDropEvent
        self._scrollArea.setAcceptDrops(True)
        self._scrollArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self._scrollArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        self._scrollArea.setWidget(self)

    def _get_glyphs(self):
        return self._glyphs

    def _set_glyphs(self, glyphs):
        self._glyphs = glyphs
        self.adjustSize()
        self.selection = set()
        #self.update() # self.selection changed will do it

    glyphs = property(_get_glyphs, _set_glyphs, doc="A list of glyphs \
        displayed. Clears selection and schedules display refresh when set.")

    def _get_selection(self):
        return self._selection

    def _set_selection(self, selection):
        self._selection = selection
        self.computeCharacterSelected()
        self.update()

    selection = property(_get_selection, _set_selection, doc="A set that contains \
        indexes of selected glyphs. Schedules display refresh when set.")

    def getSelectedGlyphs(self):
        return [self._glyphs[key] for key in sorted(self._selection)]

    def _get_lastSelectedCell(self):
        return self._lastSelectedCell

    def _set_lastSelectedCell(self, index):
        self._lastSelectedCell = index
        if self.updateCurrentGlyph:
            glyph = self.lastSelectedGlyph()
            app = QApplication.instance()
            app.setCurrentGlyph(glyph)
        if index is not None:
            self.scrollToCell(index)

    lastSelectedCell = property(_get_lastSelectedCell, _set_lastSelectedCell,
        doc="The current lastSelectedCell in selection.")

    def lastSelectedGlyph(self):
        index = self._lastSelectedCell
        return self._glyphs[index] if index is not None else None

    def scrollArea(self):
        return self._scrollArea

    def scrollToCell(self, index):
        x = (.5 + index % self._columns) * self.squareSize
        y = (.5 + index // self._columns) * self.squareSize
        self._scrollArea.ensureVisible(x, y, .5*self.squareSize, .5*self.squareSize)

    def _get_currentDropIndex(self):
        return self._currentDropIndex

    def _set_currentDropIndex(self, index):
        self._currentDropIndex = index
        self.update()

    currentDropIndex = property(_get_currentDropIndex, _set_currentDropIndex)

    def pipeDragEnterEvent(self, event):
        # glyph reordering
        if event.source() == self:
            event.acceptProposedAction()

    def pipeDragMoveEvent(self, event):
        if event.source() == self:
            pos = event.posF()
            self.currentDropIndex = int(self._columns * (pos.y() // self.squareSize) \
#.........这里部分代码省略.........
开发者ID:konkis,项目名称:trufont,代码行数:103,代码来源:glyphCollectionView.py

示例13: itemTab

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

#.........这里部分代码省略.........

		for i2 in range(0,len(self.obj.courses[self.id_].items)):
			if self.obj.courses[self.id_].items[i2].saved==1:
				self.iFrames.append(itemFrames(self.lbl[i2],self.gbtn[i2],self.sbtn[i2],self.obtn[i2],self.tag_lbl[i2]))
			elif self.obj.courses[self.id_].items[i2].saved==0:
				self.iFrames.append(itemFramesNew(self.lbl[i2],self.gbtn[i2],self.sbtn[i2],self.tag_lbl[i2]))
			else:
				self.iFrames.append(itemFramesForum(self.lbl[i2],self.gbtn[i2],self.tag_lbl[i2]))

		self.widget = QWidget(self)

		self.vbox = QVBoxLayout()
		self.vbox.setSpacing(3)

		for index, frame in enumerate(self.iFrames):
			if index%2==0:
				frame.setObjectName('nFrameEven')
			else:
				frame.setObjectName('nFrameEven')
			self.vbox.addWidget(frame)

		self.vbox.setContentsMargins(0,0,0,0)

		if len(self.iFrames)<4:
			self.dframe = QFrame()
			self.dframe.setObjectName('nFrameDummy')
			self.vbox.addWidget(self.dframe)
			self.d_=True

		self.widget.setLayout(self.vbox)
		self.scroll = QScrollArea(self)
		self.scroll.setWidget(self.widget)
		self.scroll.setWidgetResizable(True)
		self.scroll.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
		self.scroll.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)

		vbox1 = QVBoxLayout()
		vbox1.setContentsMargins(0,0,0,0)
		vbox1.setSpacing(0)

		vbox1.addWidget(self.scroll)
		self.setLayout(vbox1)


	def shortenTabName(self,cname):
		list1 =[]
		for i, ch in enumerate(cname):
				list1.append(ch)
				if len(list1)==40:
					if list1[i]== ' ':
						list1.pop(i)
					list1.append('...')
					break
		return ''.join(list1)

	def updater(self):
		self.x=+1
		if self.obj.courses[self.id_].dummy_items is '':
			return
		else:
			if  self.d_==True:
				child = self.vbox.takeAt(len(self.iFrames))
				if child.widget() is not None:
					child.widget().deleteLater()
				elif child.layout() is not None:
					clearLayout(child.layout())
开发者ID:AkshayAgarwal007,项目名称:Moodly,代码行数:70,代码来源:view.py

示例14: SearchReplaceSlidingWidget

# 需要导入模块: from PyQt5.QtWidgets import QScrollArea [as 别名]
# 或者: from PyQt5.QtWidgets.QScrollArea import setHorizontalScrollBarPolicy [as 别名]
class SearchReplaceSlidingWidget(QWidget):
    """
    Class implementing the search and replace widget with sliding behavior.
    
    @signal searchListChanged() emitted to indicate a change of the search list
    """
    searchListChanged = pyqtSignal()
    
    def __init__(self, replace, vm, parent=None):
        """
        Constructor
        
        @param replace flag indicating a replace widget is called
        @param vm reference to the viewmanager object
        @param parent parent widget of this widget (QWidget)
        """
        super(SearchReplaceSlidingWidget, self).__init__(parent)
        
        self.__searchReplaceWidget = \
            SearchReplaceWidget(replace, vm, self, True)
        
        self.__layout = QHBoxLayout(self)
        self.setLayout(self.__layout)
        self.__layout.setContentsMargins(0, 0, 0, 0)
        self.__layout.setAlignment(Qt.AlignTop)
        
        self.__leftButton = QToolButton(self)
        self.__leftButton.setArrowType(Qt.LeftArrow)
        self.__leftButton.setSizePolicy(
            QSizePolicy.Minimum, QSizePolicy.MinimumExpanding)
        self.__leftButton.setAutoRepeat(True)
        
        self.__scroller = QScrollArea(self)
        self.__scroller.setWidget(self.__searchReplaceWidget)
        self.__scroller.setSizePolicy(
            QSizePolicy.Expanding, QSizePolicy.Minimum)
        self.__scroller.setFrameShape(QFrame.NoFrame)
        self.__scroller.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.__scroller.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.__scroller.setWidgetResizable(False)
        
        self.__rightButton = QToolButton(self)
        self.__rightButton.setArrowType(Qt.RightArrow)
        self.__rightButton.setSizePolicy(
            QSizePolicy.Minimum, QSizePolicy.MinimumExpanding)
        self.__rightButton.setAutoRepeat(True)
        
        self.__layout.addWidget(self.__leftButton)
        self.__layout.addWidget(self.__scroller)
        self.__layout.addWidget(self.__rightButton)
        
        self.setMaximumHeight(self.__searchReplaceWidget.sizeHint().height())
        self.adjustSize()
        
        self.__searchReplaceWidget.searchListChanged.connect(
            self.searchListChanged)
        self.__leftButton.clicked.connect(self.__slideLeft)
        self.__rightButton.clicked.connect(self.__slideRight)
    
    def changeEvent(self, evt):
        """
        Protected method handling state changes.

        @param evt event containing the state change (QEvent)
        """
        if evt.type() == QEvent.FontChange:
            self.setMaximumHeight(
                self.__searchReplaceWidget.sizeHint().height())
            self.adjustSize()
    
    def findNext(self):
        """
        Public slot to find the next occurrence of text.
        """
        self.__searchReplaceWidget.findNext()
    
    def findPrev(self):
        """
        Public slot to find the next previous of text.
        """
        self.__searchReplaceWidget.findPrev()
    
    def selectionChanged(self):
        """
        Public slot tracking changes of selected text.
        """
        editor = self.sender()
        self.__searchReplaceWidget.updateSelectionCheckBox(editor)
    
    @pyqtSlot(Editor)
    def updateSelectionCheckBox(self, editor):
        """
        Public slot to update the selection check box.
        
        @param editor reference to the editor (Editor)
        """
        self.__searchReplaceWidget.updateSelectionCheckBox(editor)

    def show(self, text=''):
        """
#.........这里部分代码省略.........
开发者ID:testmana2,项目名称:test,代码行数:103,代码来源:SearchReplaceWidget.py

示例15: GlyphCollectionWidget

# 需要导入模块: from PyQt5.QtWidgets import QScrollArea [as 别名]
# 或者: from PyQt5.QtWidgets.QScrollArea import setHorizontalScrollBarPolicy [as 别名]
class GlyphCollectionWidget(QWidget):
    """
    A widget that presents a list of glyphs in cells.
    """

    def __init__(self, parent=None):
        super(GlyphCollectionWidget, self).__init__(parent)
        self.setAttribute(Qt.WA_KeyCompression)
        self._glyphs = []
        self._squareSize = 56
        self._columns = 10
        self._selection = set()
        self._oldSelection = None
        self._lastSelectedCell = None
        self._inputString = ""
        self._lastKeyInputTime = None

        self.glyphSelectedCallback = None
        self.doubleClickCallback = None
        self.updateCurrentGlyph = False
        self._maybeDragPosition = None

        self.setFocusPolicy(Qt.ClickFocus)
        self._currentDropIndex = None
        self._scrollArea = QScrollArea(parent)
        self._scrollArea.dragEnterEvent = self.pipeDragEnterEvent
        self._scrollArea.dragMoveEvent = self.pipeDragMoveEvent
        self._scrollArea.dragLeaveEvent = self.pipeDragLeaveEvent
        self._scrollArea.dropEvent = self.pipeDropEvent
        self._scrollArea.resizeEvent = self.resizeEvent
        self._scrollArea.setAcceptDrops(True)
        self._scrollArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self._scrollArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        self._scrollArea.setWidget(self)

    def _get_glyphs(self):
        return self._glyphs

    def _set_glyphs(self, glyphs):
        self._glyphs = glyphs
        self.adjustSize()
        self.selection = set()
        # self.update() # self.selection changed will do it

    glyphs = property(
        _get_glyphs, _set_glyphs, doc="A list of glyphs displayed. Clears "
        "selection and schedules display refresh when set.")

    def _get_selection(self):
        return self._selection

    def _set_selection(self, selection):
        self._selection = selection
        if not len(self._selection):
            self.lastSelectedCell = None
        self._computeGlyphSelection()
        self.update()

    selection = property(
        _get_selection, _set_selection, doc="A set that contains indexes of "
        "selected glyphs. Schedules display refresh when set.")

    def getSelectedGlyphs(self):
        return [self._glyphs[key] for key in sorted(self._selection)]

    def _get_lastSelectedCell(self):
        if self._lastSelectedCell is not None and \
                self._lastSelectedCell >= len(self._glyphs):
            return None
        return self._lastSelectedCell

    def _set_lastSelectedCell(self, index):
        self._lastSelectedCell = index
        if self.updateCurrentGlyph:
            glyph = self.lastSelectedGlyph()
            app = QApplication.instance()
            app.setCurrentGlyph(glyph)
        if index is not None:
            self.scrollToCell(index)

    lastSelectedCell = property(
        _get_lastSelectedCell, _set_lastSelectedCell,
        doc="The current lastSelectedCell in selection.")

    def lastSelectedGlyph(self):
        index = self.lastSelectedCell
        return self._glyphs[index] if index is not None else None

    def scrollArea(self):
        return self._scrollArea

    def scrollToCell(self, index):
        x = (.5 + index % self._columns) * self.squareSize
        y = (.5 + index // self._columns) * self.squareSize
        self._scrollArea.ensureVisible(
            x, y, .5 * self.squareSize, .5 * self.squareSize)

    def _get_currentDropIndex(self):
        return self._currentDropIndex

#.........这里部分代码省略.........
开发者ID:bitforks,项目名称:trufont,代码行数:103,代码来源:glyphCollectionView.py


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