本文整理汇总了Python中PyQt5.QtWidgets.QSplitter.widget方法的典型用法代码示例。如果您正苦于以下问题:Python QSplitter.widget方法的具体用法?Python QSplitter.widget怎么用?Python QSplitter.widget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QSplitter
的用法示例。
在下文中一共展示了QSplitter.widget方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _s_CentralWidget
# 需要导入模块: from PyQt5.QtWidgets import QSplitter [as 别名]
# 或者: from PyQt5.QtWidgets.QSplitter import widget [as 别名]
class _s_CentralWidget(QWidget):
###############################################################################
# CentralWidget SIGNALS
###############################################################################
"""
splitterCentralRotated()
"""
splitterCentralRotated = pyqtSignal()
###############################################################################
def __init__(self, parent=None):
super(_s_CentralWidget, self).__init__(parent)
self.parent = parent
#This variables are used to save the splitter sizes before hide
self._splitterMainSizes = None
self._splitterAreaSizes = None
self.lateralPanel = None
hbox = QHBoxLayout(self)
hbox.setContentsMargins(0, 0, 0, 0)
hbox.setSpacing(0)
#Create Splitters to divide the UI in: MainPanel, Explorer, Misc
self._splitterArea = QSplitter(Qt.Horizontal)
self._splitterMain = QSplitter(Qt.Vertical)
#Create scrollbar for follow mode
self.scrollBar = QScrollBar(Qt.Vertical, self)
self.scrollBar.setFixedWidth(20)
self.scrollBar.setToolTip('Follow Mode: Scroll the Editors together')
self.scrollBar.hide()
self.scrollBar.valueChanged[int].connect(self.move_follow_scrolls)
#Add to Main Layout
hbox.addWidget(self.scrollBar)
hbox.addWidget(self._splitterArea)
def insert_central_container(self, container):
self.mainContainer = container
self._splitterMain.insertWidget(0, container)
def insert_lateral_container(self, container):
self.lateralPanel = LateralPanel(container)
self._splitterArea.insertWidget(0, self.lateralPanel)
def insert_bottom_container(self, container):
self.misc = container
self._splitterMain.insertWidget(1, container)
def showEvent(self, event):
#Show Event
QWidget.showEvent(self, event)
#Avoid recalculate the panel sizes if they are already loaded
if self._splitterArea.count() == 2:
return
#Rearrange widgets on Window
self._splitterArea.insertWidget(0, self._splitterMain)
if not event.spontaneous():
self.change_misc_visibility()
if bin(settings.UI_LAYOUT)[-1] == '1':
self.splitter_central_rotate()
if bin(settings.UI_LAYOUT >> 1)[-1] == '1':
self.splitter_misc_rotate()
if bin(settings.UI_LAYOUT >> 2)[-1] == '1':
self.splitter_central_orientation()
qsettings = QSettings(resources.SETTINGS_PATH, QSettings.IniFormat)
#Lists of sizes as list of QVariant- heightList = [QVariant, QVariant]
heightList = list(qsettings.value("window/central/mainSize",
[(self.height() / 3) * 2, self.height() / 3]))
widthList = list(qsettings.value("window/central/areaSize",
[(self.width() / 6) * 5, self.width() / 6]))
self._splitterMainSizes = [int(heightList[0]), int(heightList[1])]
self._splitterAreaSizes = [int(widthList[0]), int(widthList[1])]
#Set the sizes to splitters
#self._splitterMain.setSizes(self._splitterMainSizes)
self._splitterMain.setSizes(self._splitterMainSizes)
self._splitterArea.setSizes(self._splitterAreaSizes)
self.misc.setVisible(
qsettings.value("window/show_misc", False, type=bool))
def change_misc_visibility(self, on_start=False):
if self.misc.isVisible():
self._splitterMainSizes = self._splitterMain.sizes()
self.misc.hide()
widget = self.mainContainer.get_actual_widget()
if widget:
widget.setFocus()
else:
self.misc.show()
self.misc.gain_focus()
def change_main_visibility(self):
if self.mainContainer.isVisible():
self.mainContainer.hide()
else:
self.mainContainer.show()
def change_explorer_visibility(self, force_hide=False):
#.........这里部分代码省略.........
示例2: MainWindow
# 需要导入模块: from PyQt5.QtWidgets import QSplitter [as 别名]
# 或者: from PyQt5.QtWidgets.QSplitter import widget [as 别名]
class MainWindow(QMainWindow):
KEY_WINDOW_SIZE = 'main_window/size'
KEY_WINDOW_MAXIMIZED = 'main_window/maximized'
KEY_WINDOW_POSITION = 'main_window/position'
KEY_H_SPLITTER_STATE = 'main_window/h_splitter_state'
def __init__(self):
super(MainWindow, self).__init__()
self.setWindowTitle('Mojuru')
app_icon = QIcon('images/mojuru_logo.png')
self.setWindowIcon(app_icon)
reload_modules_action = QAction('Reload MainWindow', self)
reload_modules_action.setShortcut('ctrl+shift+alt+r')
reload_modules_action.triggered.connect(self.reload_central_widget)
self.addAction(reload_modules_action)
quit_action = QAction('Quit', self)
quit_action.setShortcut('ctrl+q')
quit_action.triggered.connect(self.on_quit)
self.addAction(quit_action)
self.vertical_splitter = QSplitter(Qt.Vertical, self)
self.setCentralWidget(self.vertical_splitter)
self.load_central_widget()
self.file_menu = self.menuBar().addMenu(self.tr('&File'))
self.file_menu.addAction(quit_action)
self.file_menu.addSeparator()
self.module_menu = self.menuBar().addMenu(self.tr('&Modules'))
self.module_menu.addAction(reload_modules_action)
self.module_menu.addSeparator()
Alter.invoke_all('main_window_init', self)
#restore main window state
size = ModuleManager.core['settings'].Settings.value(
self.KEY_WINDOW_SIZE, QSize(600, 400))
maximized = ModuleManager.core['settings'].Settings.value(
self.KEY_WINDOW_MAXIMIZED, False)
position = ModuleManager.core['settings'].Settings.value(
self.KEY_WINDOW_POSITION, QPoint(0,0))
if maximized == 'true':
self.showMaximized()
else:
self.resize(size)
self.move(position)
def closeEvent(self, event):
self.on_quit()
def save_state(self):
ModuleManager.core['settings'].Settings.set_value(
self.KEY_WINDOW_SIZE, self.size())
ModuleManager.core['settings'].Settings.set_value(
self.KEY_WINDOW_MAXIMIZED, self.isMaximized())
ModuleManager.core['settings'].Settings.set_value(
self.KEY_WINDOW_POSITION, self.pos())
ModuleManager.core['settings'].Settings.set_value(
self.KEY_H_SPLITTER_STATE, self.horizontal_splitter.saveState())
def on_quit(self):
self.save_state()
self.close()
def load_central_widget(self):
self.populate_central_widget()
self.connect_widgets()
def populate_central_widget(self):
self.vertical_widgets = collections.OrderedDict()
self.horizontal_splitter = QSplitter(
Qt.Horizontal, self.vertical_splitter)
self.horizontal_widgets = collections.OrderedDict()
self.vertical_widgets["horizontal_splitter"] = self.horizontal_splitter
Alter.invoke_all(
'main_window_add_vertical_widget',
self.vertical_widgets,
self
)
for widget in self.vertical_widgets.values():
self.vertical_splitter.addWidget(widget)
Alter.invoke_all(
'main_window_add_horizontal_widget',
self.horizontal_widgets,
self.vertical_splitter
)
for widget in self.horizontal_widgets.values():
self.horizontal_splitter.addWidget(widget)
#restore horizontal splitter state
state = ModuleManager.core['settings'].Settings.value(
self.KEY_H_SPLITTER_STATE,
None
)
#.........这里部分代码省略.........
示例3: App
# 需要导入模块: from PyQt5.QtWidgets import QSplitter [as 别名]
# 或者: from PyQt5.QtWidgets.QSplitter import widget [as 别名]
class App(QWidget):
def __init__(self, lang='en'):
super().__init__()
self.params = Params(lang)
self.initUI()
def initUI(self):
self.txt2func = {
'はじめに': Introduction, 'Introduction': Introduction,
'分析タスク': TypeOfTask, 'Task': TypeOfTask,
'入力データ': SetFile, 'Input data': SetFile,
'データの確認': DataCheck, 'Data check': DataCheck,
'過学習': Overfitting, 'Overfitting': Overfitting,
'分析の実行': Analysis, 'Analysis': Analysis,
'結果の確認': Results, 'Results': Results,
'バイアスとバリアンス': BiasVariance, 'Bias and Variance': BiasVariance,
'学習曲線': LearningCurve, 'Learning curve': LearningCurve,
'特徴量選択': FeatureSelection, 'Feature selection': FeatureSelection,
'結果の確認2': Results2, 'Results 2': Results2,
'学習曲線2': LearningCurve2, 'Learning curve 2': LearningCurve2,
'予測': Prediction, 'Prediction': Prediction,
'Error': Error}
self.setMinimumSize(1280, 960)
self.setStyleSheet('background-color: rgb(242, 242, 242)')
vbox = QVBoxLayout(self)
vbox.setSpacing(0)
vbox.setContentsMargins(0, 0, 0, 0)
top = QFrame(self)
top.setFrameShape(QFrame.StyledPanel)
top.setFixedHeight(50)
top.setStyleSheet('background-color: white')
self.splitter = QSplitter(Qt.Horizontal, self)
self.splitter.setHandleWidth(0)
self.menuview = MenuView(self.splitter, self.update_content,
self.params)
self.menuview.setWidgetResizable(True)
self.contentview = Introduction(self.splitter,
self.menuview.edit_button, self.params)
self.contentview.setWidgetResizable(True)
self.splitter.addWidget(self.menuview)
self.splitter.addWidget(self.contentview)
vbox.addWidget(top)
vbox.addWidget(self.splitter)
self.setLayout(vbox)
self.center()
# self.showMaximized()
self.setWindowTitle('MALSS interactive')
self.show()
def center(self):
# Get a rectangle of the main window.
qr = self.frameGeometry()
# Figure out the screen resolution; and from this resolution,
# get the center point (x, y)
cp = QDesktopWidget().availableGeometry().center()
# Set the center of the rectangle to the center of the screen.
qr.moveCenter(cp)
self.move(qr.topLeft())
def update_content(self, text):
content = self.splitter.widget(1)
if content is not None:
if text in self.txt2func:
content.hide()
content.deleteLater()
self.contentview =\
self.txt2func[text](self.splitter,
self.menuview.edit_button,
self.params)
self.contentview.setWidgetResizable(True)
self.splitter.addWidget(self.contentview)
示例4: PanelContainer
# 需要导入模块: from PyQt5.QtWidgets import QSplitter [as 别名]
# 或者: from PyQt5.QtWidgets.QSplitter import widget [as 别名]
class PanelContainer(QWidget):
def __init__(self, panelWin):
super(QWidget, self).__init__()
self.panelWindow = panelWin
self.panelCount = 0
self.mainLayout = QGridLayout(self)
self.mainLayout.setContentsMargins(0, 0, 0, 0)
self.splitter = QSplitter(self)
self.containerParent = 0
self.mainLayout.addWidget(self.splitter, 0, 0)
def splitter(self):
return self.splitter
def addPanel(self, panel=None):
if panel:
panel.setParent(self)
panel.setContainer(self)
self.splitter.addWidget(panel)
self.panelCount += 1
self.updatePanelSignals(panel)
else:
panel = self.createPanel()
self.splitter.addWidget(panel)
return panel
def addPanelSplit(self, panel, direction):
panel = PanelWidget(self) if 0 else panel
# Store original size
origSize = panel.size()
# reparent the panel
panel.setParent(self)
panel.setContainer(self)
# set orientation and add the panel
self.splitter.setOrientation(direction)
self.splitter.addWidget(panel)
# add another panel for split
panel = self.createPanel()
self.splitter.addWidget(panel)
sizes = list()
origSize *= 0.5
if direction == Qt.Horizontal:
sizes.append(origSize.width())
sizes.append(origSize.width())
else:
sizes.append(origSize.height())
sizes.append(origSize.height())
self.splitter.setSizes(sizes)
self.panelCount += 1
def addContainer(self, child):
child = PanelContainer(self) if 0 else child
self.splitter.addWidget(child)
child.setParentContainer(self)
def insertContainer(self, child, index):
child = PanelContainer(self) if 0 else child
self.splitter.insertWidget(index, child)
child.setParentContainer(self)
def setParentContainer(self, parent):
self.containerParent = parent
def parentContainer(self):
return self.containerParent
def childContainers(self):
# childContainers = list()
# for index in range(0, self.splitter.count()):
# container = self.splitter.widget(index)
# if container:
# childContainers.append(container)
return self.sortedChildren()
def panels(self):
# panels = list()
# for index in range(0, self.splitter.count()):
# panel = self.splitter.widget(index)
# if panel:
# panels.append(panel)
return self.sortedChildren()
def sortedChildren(self):
return (self.splitter.widget(index) for index in range(self.splitter.count()))
def numberOfPanels(self):
return self.panelCount
def createPanel(self):
panel = PanelWidget(self)
#.........这里部分代码省略.........
示例5: SignalTabController
# 需要导入模块: from PyQt5.QtWidgets import QSplitter [as 别名]
# 或者: from PyQt5.QtWidgets.QSplitter import widget [as 别名]
class SignalTabController(QWidget):
frame_closed = pyqtSignal(SignalFrameController)
not_show_again_changed = pyqtSignal()
signal_created = pyqtSignal(Signal)
files_dropped = pyqtSignal(list)
frame_was_dropped = pyqtSignal(int, int)
@property
def num_frames(self):
return self.splitter.count() - 1
@property
def signal_frames(self):
"""
:rtype: list of SignalFrameController
"""
return [self.splitter.widget(i) for i in range(self.num_frames)]
@property
def signal_undo_stack(self):
return self.undo_stack
def __init__(self, project_manager, parent=None):
super().__init__(parent)
self.ui = Ui_Interpretation()
self.ui.setupUi(self)
self.splitter = QSplitter()
self.splitter.setStyleSheet("QSplitter::handle:vertical {\nmargin: 4px 0px; background-color: qlineargradient(x1:0, y1:0, x2:1, y2:0, \nstop:0 rgba(255, 255, 255, 0), \nstop:0.5 rgba(100, 100, 100, 100), \nstop:1 rgba(255, 255, 255, 0));\n image: url(:/icons/data/icons/splitter_handle_horizontal.svg);\n}")
self.splitter.setOrientation(Qt.Vertical)
self.splitter.setChildrenCollapsible(True)
self.splitter.setHandleWidth(6)
placeholder_widget = QWidget()
placeholder_widget.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
self.undo_stack = QUndoStack()
self.project_manager = project_manager
self.splitter.addWidget(placeholder_widget)
self.signal_vlay = QVBoxLayout()
self.signal_vlay.setContentsMargins(0,0,0,0)
self.signal_vlay.addWidget(self.splitter)
self.ui.scrlAreaSignals.setLayout(self.signal_vlay)
self.drag_pos = None
def on_files_dropped(self, files):
self.files_dropped.emit(files)
def close_frame(self, frame:SignalFrameController):
self.frame_closed.emit(frame)
def add_signal_frame(self, proto_analyzer):
sig_frame = SignalFrameController(proto_analyzer, self.undo_stack, self.project_manager, parent=self)
sframes = self.signal_frames
if len(proto_analyzer.signal.filename) == 0:
# new signal from "create signal from selection"
sig_frame.ui.btnSaveSignal.show()
self.__create_connects_for_signal_frame(signal_frame=sig_frame)
sig_frame.signal_created.connect(self.signal_created.emit)
sig_frame.not_show_again_changed.connect(self.not_show_again_changed.emit)
sig_frame.ui.lineEditSignalName.setToolTip(self.tr("Sourcefile: ") + proto_analyzer.signal.filename)
sig_frame.apply_to_all_clicked.connect(self.on_apply_to_all_clicked)
prev_signal_frame = sframes[-1] if len(sframes) > 0 else None
if prev_signal_frame is not None and hasattr(prev_signal_frame, "ui"):
sig_frame.ui.cbProtoView.setCurrentIndex(prev_signal_frame.ui.cbProtoView.currentIndex())
sig_frame.blockSignals(True)
if proto_analyzer.signal.qad_demod_file_loaded:
sig_frame.ui.cbSignalView.setCurrentIndex(1)
sig_frame.ui.cbSignalView.setDisabled(True)
self.splitter.insertWidget(self.num_frames, sig_frame)
sig_frame.blockSignals(False)
default_view = constants.SETTINGS.value('default_view', 0, int)
sig_frame.ui.cbProtoView.setCurrentIndex(default_view)
return sig_frame
def __create_connects_for_signal_frame(self, signal_frame: SignalFrameController):
signal_frame.hold_shift = constants.SETTINGS.value('hold_shift_to_drag', False, type=bool)
signal_frame.drag_started.connect(self.frame_dragged)
signal_frame.frame_dropped.connect(self.frame_dropped)
signal_frame.files_dropped.connect(self.on_files_dropped)
signal_frame.closed.connect(self.close_frame)
def add_empty_frame(self, filename: str, proto):
sig_frame = SignalFrameController(proto_analyzer=proto, undo_stack=self.undo_stack,
project_manager=self.project_manager, proto_bits=proto.decoded_proto_bits_str,
parent=self)
sig_frame.ui.lineEditSignalName.setText(filename)
sig_frame.setMinimumHeight(sig_frame.height())
sig_frame.set_empty_frame_visibilities()
#.........这里部分代码省略.........
示例6: MainWindow
# 需要导入模块: from PyQt5.QtWidgets import QSplitter [as 别名]
# 或者: from PyQt5.QtWidgets.QSplitter import widget [as 别名]
class MainWindow(QMainWindow):
KEY_WINDOW_SIZE = 'main_window/size'
KEY_WINDOW_MAXIMIZED = 'main_window/maximized'
KEY_WINDOW_POSITION = 'main_window/position'
KEY_H_SPLITTER_STATE = 'main_window/h_splitter_state'
def __init__(self):
super(MainWindow, self).__init__()
self.setWindowTitle('Mojuru')
app_icon = QIcon('images/mojuru_logo.png')
self.setWindowIcon(app_icon)
reload_modules_action = QAction('Reload MainWindow', self)
reload_modules_action.setShortcut('ctrl+shift+alt+r')
reload_modules_action.triggered.connect(self.reload_central_widget)
self.addAction(reload_modules_action)
quit_action = QAction('Quit', self)
quit_action.setShortcut('ctrl+q')
quit_action.triggered.connect(self.on_quit)
self.addAction(quit_action)
self.vertical_splitter = QSplitter(Qt.Vertical, self)
self.setCentralWidget(self.vertical_splitter)
self.load_central_widget()
self.file_menu = self.menuBar().addMenu(self.tr('&File'))
self.file_menu.addAction(quit_action)
self.file_menu.addSeparator()
self.module_menu = self.menuBar().addMenu(self.tr('&Modules'))
self.module_menu.addAction(reload_modules_action)
self.module_menu.addSeparator()
Alter.invoke_all('main_window_init', self)
#restore main window state
size = ModuleManager.core['settings'].Settings.value(
self.KEY_WINDOW_SIZE, QSize(600, 400))
maximized = ModuleManager.core['settings'].Settings.value(
self.KEY_WINDOW_MAXIMIZED, False)
position = ModuleManager.core['settings'].Settings.value(
self.KEY_WINDOW_POSITION, QPoint(0,0))
if maximized == 'true':
self.showMaximized()
else:
self.resize(size)
self.move(position)
def closeEvent(self, event):
self.on_quit()
def save_state(self):
ModuleManager.core['settings'].Settings.set_value(
self.KEY_WINDOW_SIZE, self.size())
ModuleManager.core['settings'].Settings.set_value(
self.KEY_WINDOW_MAXIMIZED, self.isMaximized())
ModuleManager.core['settings'].Settings.set_value(
self.KEY_WINDOW_POSITION, self.pos())
ModuleManager.core['settings'].Settings.set_value(
self.KEY_H_SPLITTER_STATE, self.horizontal_splitter.saveState())
def on_quit(self):
self.save_state()
self.close()
def load_central_widget(self):
self.populate_central_widget()
self.connect_widgets()
def populate_central_widget(self):
self.vertical_widgets = collections.OrderedDict()
self.horizontal_splitter = QSplitter(
Qt.Horizontal, self.vertical_splitter)
self.horizontal_widgets = collections.OrderedDict()
self.vertical_widgets["horizontal_splitter"] = self.horizontal_splitter
Alter.invoke_all(
'main_window_add_vertical_widget',
self.vertical_widgets,
self
)
for widget in self.vertical_widgets.values():
self.vertical_splitter.addWidget(widget)
Alter.invoke_all(
'main_window_add_horizontal_widget',
self.horizontal_widgets,
self.vertical_splitter
)
for widget in self.horizontal_widgets.values():
self.horizontal_splitter.addWidget(widget)
#restore horizontal splitter state
state = ModuleManager.core['settings'].Settings.value(
self.KEY_H_SPLITTER_STATE,
None
)
#.........这里部分代码省略.........