本文整理汇总了Python中PyQt5.QtWidgets.QSplitter.setCollapsible方法的典型用法代码示例。如果您正苦于以下问题:Python QSplitter.setCollapsible方法的具体用法?Python QSplitter.setCollapsible怎么用?Python QSplitter.setCollapsible使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QSplitter
的用法示例。
在下文中一共展示了QSplitter.setCollapsible方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SubTabWidget
# 需要导入模块: from PyQt5.QtWidgets import QSplitter [as 别名]
# 或者: from PyQt5.QtWidgets.QSplitter import setCollapsible [as 别名]
class SubTabWidget(QWidget):
_tabChanged = pyqtSignal(int, name = "tabChanged")
def __init__(self, subtitleData, videoWidget, parent = None):
super(SubTabWidget, self).__init__(parent)
self._subtitleData = subtitleData
self.__initTabWidget(videoWidget)
def __initTabWidget(self, videoWidget):
settings = SubSettings()
mainLayout = QVBoxLayout(self)
mainLayout.setContentsMargins(0, 0, 0, 0)
mainLayout.setSpacing(0)
#TabBar
self.tabBar = QTabBar(self)
# Splitter (bookmarks + pages)
self.splitter = QSplitter(self)
self.splitter.setObjectName("sidebar_splitter")
self._toolbox = ToolBox(self._subtitleData, self)
self._toolbox.setObjectName("sidebar")
self._toolbox.setMinimumWidth(100)
self._toolbox.addTool(Details(self._subtitleData, self))
self._toolbox.addTool(Synchronizer(videoWidget, self._subtitleData, self))
self._toolbox.addTool(History(self))
self.rightWidget = QWidget()
rightLayout = QGridLayout()
rightLayout.setContentsMargins(0, 0, 0, 0)
self.rightWidget.setLayout(rightLayout)
self._mainTab = FileList(_("Subtitles"), self._subtitleData, self)
self.pages = QStackedWidget(self)
rightLayout.addWidget(self.pages, 0, 0)
self.tabBar.addTab(self._mainTab.name)
self.pages.addWidget(self._mainTab)
self.splitter.addWidget(self._toolbox)
self.splitter.addWidget(self.rightWidget)
self.__drawSplitterHandle(1)
# Setting widgets
mainLayout.addWidget(self.tabBar)
mainLayout.addWidget(self.splitter)
# Widgets settings
self.tabBar.setMovable(True)
self.tabBar.setTabsClosable(True)
self.tabBar.setExpanding(False)
# Don't resize left panel if it's not needed
leftWidgetIndex = self.splitter.indexOf(self._toolbox)
rightWidgetIndex = self.splitter.indexOf(self.rightWidget)
self.splitter.setStretchFactor(leftWidgetIndex, 0)
self.splitter.setStretchFactor(rightWidgetIndex, 1)
self.splitter.setCollapsible(leftWidgetIndex, False)
self.splitter.setSizes([250])
# Some signals
self.tabBar.currentChanged.connect(self.showTab)
self.tabBar.tabCloseRequested.connect(self.closeTab)
self.tabBar.tabMoved.connect(self.moveTab)
self._mainTab.requestOpen.connect(self.openTab)
self._mainTab.requestRemove.connect(self.removeFile)
self.tabChanged.connect(lambda i: self._toolbox.setContentFor(self.tab(i)))
self.setLayout(mainLayout)
def __addTab(self, filePath):
"""Returns existing tab index. Creates a new one if it isn't opened and returns its index
otherwise."""
for i in range(self.tabBar.count()):
widget = self.pages.widget(i)
if not widget.isStatic and filePath == widget.filePath:
return i
tab = SubtitleEditor(filePath, self._subtitleData, self)
newIndex = self.tabBar.addTab(self._createTabName(tab.name, tab.history.isClean()))
tab.history.cleanChanged.connect(
lambda clean: self._cleanStateForFileChanged(filePath, clean))
self.pages.addWidget(tab)
return newIndex
def __drawSplitterHandle(self, index):
splitterHandle = self.splitter.handle(index)
splitterLayout = QVBoxLayout(splitterHandle)
splitterLayout.setSpacing(0)
splitterLayout.setContentsMargins(0, 0, 0, 0)
line = QFrame(splitterHandle)
line.setFrameShape(QFrame.HLine)
line.setFrameShadow(QFrame.Sunken)
#.........这里部分代码省略.........
示例2: __initUI__
# 需要导入模块: from PyQt5.QtWidgets import QSplitter [as 别名]
# 或者: from PyQt5.QtWidgets.QSplitter import setCollapsible [as 别名]
def __initUI__(self):
# ---- TAB WIDGET
# download weather data :
splash.showMessage("Initializing download weather data...")
self.tab_dwnld_data = DwnldWeatherWidget(self)
self.tab_dwnld_data.set_workdir(self.projectdir)
# gapfill weather data :
splash.showMessage("Initializing gapfill weather data...")
self.tab_fill_weather_data = GapFillWeatherGUI(self)
self.tab_fill_weather_data.set_workdir(self.projectdir)
# hydrograph :
splash.showMessage("Initializing plot hydrograph...")
self.tab_hydrograph = HydroPrint.HydroprintGUI(self.dmanager)
splash.showMessage("Initializing analyse hydrograph...")
self.tab_hydrocalc = HydroCalc.WLCalc(self.dmanager)
self.tab_hydrocalc.sig_new_mrc.connect(
self.tab_hydrograph.mrc_wl_changed)
self.tab_hydrocalc.rechg_eval_widget.sig_new_gluedf.connect(
self.tab_hydrograph.glue_wl_changed)
# ---- TABS ASSEMBLY
self.tab_widget = TabWidget()
self.tab_widget.addTab(self.tab_dwnld_data, 'Download Weather')
self.tab_widget.addTab(self.tab_fill_weather_data, 'Gapfill Weather')
self.tab_widget.addTab(self.tab_hydrograph, 'Plot Hydrograph')
self.tab_widget.addTab(self.tab_hydrocalc, 'Analyze Hydrograph')
self.tab_widget.setCornerWidget(self.pmanager)
self.tab_widget.currentChanged.connect(self.sync_datamanagers)
# ---- Main Console
splash.showMessage("Initializing main window...")
self.main_console = QTextEdit()
self.main_console.setReadOnly(True)
self.main_console.setLineWrapMode(QTextEdit.NoWrap)
style = 'Regular'
family = StyleDB().fontfamily
size = self.whatPref.fontsize_console
fontSS = ('font-style: %s;'
'font-size: %s;'
'font-family: %s;'
) % (style, size, family)
self.main_console.setStyleSheet("QWidget{%s}" % fontSS)
msg = '<font color=black>Thanks for using %s.</font>' % __appname__
self.write2console(msg)
self.write2console('<font color=black>'
'Please report any bug or wishful feature at'
' [email protected]'
'</font>')
# ---- Signal Piping
issuer = self.tab_dwnld_data
issuer.ConsoleSignal.connect(self.write2console)
issuer = self.tab_fill_weather_data
issuer.ConsoleSignal.connect(self.write2console)
issuer = self.tab_hydrograph
issuer.ConsoleSignal.connect(self.write2console)
# ---- Splitter Widget
splitter = QSplitter(self)
splitter.setOrientation(Qt.Vertical)
splitter.addWidget(self.tab_widget)
splitter.addWidget(self.main_console)
splitter.setCollapsible(0, True)
splitter.setStretchFactor(0, 100)
# Forces initially the main_console to its minimal height:
splitter.setSizes([100, 1])
# ---- Main Grid
main_widget = QWidget()
self.setCentralWidget(main_widget)
mainGrid = QGridLayout(main_widget)
mainGrid.addWidget(splitter, 0, 0)
mainGrid.addWidget(self.tab_fill_weather_data.pbar, 1, 0)
mainGrid.addWidget(self.tab_dwnld_data.pbar, 2, 0)
mainGrid.addWidget(
self.tab_hydrocalc.rechg_eval_widget.progressbar, 3, 0)
示例3: __init__
# 需要导入模块: from PyQt5.QtWidgets import QSplitter [as 别名]
# 或者: from PyQt5.QtWidgets.QSplitter import setCollapsible [as 别名]
def __init__(self, panel):
super(Widget, self).__init__(panel)
layout = QVBoxLayout()
self.setLayout(layout)
layout.setSpacing(0)
self.searchEntry = SearchLineEdit()
self.treeView = QTreeView(contextMenuPolicy=Qt.CustomContextMenu)
self.textView = QTextBrowser()
applyButton = QToolButton(autoRaise=True)
editButton = QToolButton(autoRaise=True)
addButton = QToolButton(autoRaise=True)
self.menuButton = QPushButton(flat=True)
menu = QMenu(self.menuButton)
self.menuButton.setMenu(menu)
splitter = QSplitter(Qt.Vertical)
top = QHBoxLayout()
layout.addLayout(top)
splitter.addWidget(self.treeView)
splitter.addWidget(self.textView)
layout.addWidget(splitter)
splitter.setSizes([200, 100])
splitter.setCollapsible(0, False)
top.addWidget(self.searchEntry)
top.addWidget(applyButton)
top.addSpacing(10)
top.addWidget(addButton)
top.addWidget(editButton)
top.addWidget(self.menuButton)
# action generator for actions added to search entry
def act(slot, icon=None):
a = QAction(self, triggered=slot)
self.addAction(a)
a.setShortcutContext(Qt.WidgetWithChildrenShortcut)
icon and a.setIcon(icons.get(icon))
return a
# hide if ESC pressed in lineedit
a = act(self.slotEscapePressed)
a.setShortcut(QKeySequence(Qt.Key_Escape))
# import action
a = self.importAction = act(self.slotImport, 'document-open')
menu.addAction(a)
# export action
a = self.exportAction = act(self.slotExport, 'document-save-as')
menu.addAction(a)
# apply button
a = self.applyAction = act(self.slotApply, 'edit-paste')
applyButton.setDefaultAction(a)
menu.addSeparator()
menu.addAction(a)
# add button
a = self.addAction_ = act(self.slotAdd, 'list-add')
a.setShortcut(QKeySequence(Qt.Key_Insert))
addButton.setDefaultAction(a)
menu.addSeparator()
menu.addAction(a)
# edit button
a = self.editAction = act(self.slotEdit, 'document-edit')
a.setShortcut(QKeySequence(Qt.Key_F2))
editButton.setDefaultAction(a)
menu.addAction(a)
# set shortcut action
a = self.shortcutAction = act(self.slotShortcut, 'preferences-desktop-keyboard-shortcuts')
menu.addAction(a)
# delete action
a = self.deleteAction = act(self.slotDelete, 'list-remove')
a.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_Delete))
menu.addAction(a)
# restore action
a = self.restoreAction = act(self.slotRestore)
menu.addSeparator()
menu.addAction(a)
# help button
a = self.helpAction = act(self.slotHelp, 'help-contents')
menu.addSeparator()
menu.addAction(a)
self.treeView.setSelectionBehavior(QTreeView.SelectRows)
self.treeView.setSelectionMode(QTreeView.ExtendedSelection)
self.treeView.setRootIsDecorated(False)
self.treeView.setAllColumnsShowFocus(True)
self.treeView.setModel(model.model())
self.treeView.setCurrentIndex(QModelIndex())
# signals
#.........这里部分代码省略.........
示例4: MyCodeEditor
# 需要导入模块: from PyQt5.QtWidgets import QSplitter [as 别名]
# 或者: from PyQt5.QtWidgets.QSplitter import setCollapsible [as 别名]
class MyCodeEditor(QWidget):
def __init__(self,parent=None):
QWidget.__init__(self,parent)
self.__editorSettings = EditorSettings()
self.__textDocument = PythonTextDocument()
self.__splitter = QSplitter(self)
# 横纵滚动条
self.__verticalScrollBar = QScrollBar(self)
self.__verticalScrollBar.adjustSize()
self.__verticalScrollBar.setMinimumWidth(self.__verticalScrollBar.width())
self.__verticalScrollBar.setMaximumWidth(self.__verticalScrollBar.width())
self.__verticalScrollBar.valueChanged.connect(self.__onVScrollValueChanged)
self.__editorSettings.startDisLineNumberChangedSignal.connect(self.__verticalScrollBar.setValue)
self.__horizontalScrollBar = QScrollBar(QtCore.Qt.Horizontal,self)
self.__horizontalScrollBar.adjustSize()
self.__horizontalScrollBar.setMinimumHeight(self.__horizontalScrollBar.height())
self.__horizontalScrollBar.setMaximumHeight(self.__horizontalScrollBar.height())
self.__horizontalScrollBar.valueChanged.connect(self.__onHScrollValueChanged)
self.__editorSettings.startDisLetterXOffChangedSignal.connect(self.__horizontalScrollBar.setValue)
self.__lineNumberWidget = LineNumberWidget(self.__editorSettings,self.__splitter)
setattr(self.__lineNumberWidget,'resizeEvent',self.__onLineNumberWidgetSizeChanged)
self.__codeTextWidget = CodeTextWidget(self.__textDocument,self.__editorSettings,self.__splitter)
self.__codeTextWidget.document().totalLevelTextChangedSignal.connect(self.__onCodeTextChanged)
self.__codeTextWidget.settings().lineTextMaxPixelChangedSignal.connect(self.__onLineStrLengthChanged)
self.__codeTextWidget.visibleLineYOffInfoChangedSignal.connect( self.__lineNumberWidget.setVisibleLineYOffInfoArray )
self.__splitter.addWidget( self.__lineNumberWidget )
self.__splitter.addWidget( self.__codeTextWidget )
self.__splitter.setCollapsible( 0,False )
self.__splitter.setCollapsible( 1,False )
self.setText = self.__codeTextWidget.setText
self.getText = self.__codeTextWidget.getText
def __onLineStrLengthChanged(self,newMaxLength):
hMax = newMaxLength-1
self.__horizontalScrollBar.setRange(0,hMax)
if self.__horizontalScrollBar.value() > hMax:
self.__horizontalScrollBar.setValue(hMax)
def __onCodeTextChanged(self,*arg1,**arg2):
vMax = self.__codeTextWidget.document().getLineCount()-1
self.__verticalScrollBar.setRange(0,vMax)
if self.__verticalScrollBar.value() > vMax:
self.__verticalScrollBar.setValue(vMax)
def __onVScrollValueChanged(self):
self.__codeTextWidget.showLineNumberAsTop(self.__verticalScrollBar.value())
def __onHScrollValueChanged(self):
self.__codeTextWidget.showLeftXOffAsLeft(self.__horizontalScrollBar.value())
def __onLineNumberWidgetSizeChanged(self,*arg1,**arg2):
lineNumberWidgetWidth = self.__lineNumberWidget.width()
vScrollBarWidth = self.__verticalScrollBar.width()
hScrollBarHeight = self.__horizontalScrollBar.height()
self.__horizontalScrollBar.setGeometry(lineNumberWidgetWidth,self.height()-hScrollBarHeight, \
self.width()-vScrollBarWidth-lineNumberWidgetWidth,hScrollBarHeight)
def resizeEvent(self, event):
vScrollBarWidth = self.__verticalScrollBar.width()
hScrollBarHeight = self.__horizontalScrollBar.height()
self.__splitter.setGeometry( 0,0,self.width()-vScrollBarWidth,self.height()-hScrollBarHeight )
self.__verticalScrollBar.setGeometry(self.width()-vScrollBarWidth,0,vScrollBarWidth,self.height()-hScrollBarHeight)
self.__onLineNumberWidgetSizeChanged()
def wheelEvent(self, event):
changedV = 3 if event.angleDelta().y() < 0 else -3
self.__verticalScrollBar.setValue( self.__verticalScrollBar.value() + changedV )