本文整理汇总了Python中AnyQt.QtWidgets.QVBoxLayout.addStretch方法的典型用法代码示例。如果您正苦于以下问题:Python QVBoxLayout.addStretch方法的具体用法?Python QVBoxLayout.addStretch怎么用?Python QVBoxLayout.addStretch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtWidgets.QVBoxLayout
的用法示例。
在下文中一共展示了QVBoxLayout.addStretch方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from AnyQt.QtWidgets import QVBoxLayout [as 别名]
# 或者: from AnyQt.QtWidgets.QVBoxLayout import addStretch [as 别名]
def __init__(self):
super().__init__()
self.corpus = None
self.learning_thread = None
# Commit button
gui.auto_commit(self.buttonsArea, self, 'autocommit', 'Commit', box=False)
button_group = QButtonGroup(self, exclusive=True)
button_group.buttonClicked[int].connect(self.change_method)
self.widgets = []
method_layout = QVBoxLayout()
self.controlArea.layout().addLayout(method_layout)
for i, (method, attr_name) in enumerate(self.methods):
widget = method(self, title='Options')
widget.setFixedWidth(self.control_area_width)
widget.valueChanged.connect(self.commit)
self.widgets.append(widget)
setattr(self, attr_name, widget)
rb = QRadioButton(text=widget.Model.name)
button_group.addButton(rb, i)
method_layout.addWidget(rb)
method_layout.addWidget(widget)
button_group.button(self.method_index).setChecked(True)
self.toggle_widgets()
method_layout.addStretch()
# Topics description
self.topic_desc = TopicViewer()
self.topic_desc.topicSelected.connect(self.send_topic_by_id)
self.mainArea.layout().addWidget(self.topic_desc)
self.topic_desc.setFocus()
示例2: __init__
# 需要导入模块: from AnyQt.QtWidgets import QVBoxLayout [as 别名]
# 或者: from AnyQt.QtWidgets.QVBoxLayout import addStretch [as 别名]
def __init__(self, parent=None):
super().__init__(parent)
self.corpus = None
self.initial_ngram_range = None # initial range of input corpus — used for inplace
self.preprocessor = preprocess.Preprocessor()
# -- INFO --
info_box = gui.widgetBox(self.controlArea, 'Info')
info_box.setFixedWidth(self.control_area_width)
self.controlArea.layout().addStretch()
self.info_label = gui.label(info_box, self, '')
self.update_info()
# -- PIPELINE --
frame = QFrame()
frame.setContentsMargins(0, 0, 0, 0)
frame.setFrameStyle(QFrame.Box)
frame.setStyleSheet('.QFrame { border: 1px solid #B3B3B3; }')
frame_layout = QVBoxLayout()
frame_layout.setContentsMargins(0, 0, 0, 0)
frame_layout.setSpacing(0)
frame.setLayout(frame_layout)
self.stages = []
for stage in self.preprocessors:
widget = stage(self)
self.stages.append(widget)
setattr(self, stage.attribute, widget)
frame_layout.addWidget(widget)
widget.change_signal.connect(self.settings_invalidated)
frame_layout.addStretch()
self.scroll = QScrollArea()
self.scroll.setWidget(frame)
self.scroll.setWidgetResizable(True)
self.scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
self.scroll.resize(frame_layout.sizeHint())
self.scroll.setMinimumHeight(500)
self.set_minimal_width()
self.mainArea.layout().addWidget(self.scroll)
# Buttons area
self.report_button.setFixedWidth(self.control_area_width)
commit_button = gui.auto_commit(self.buttonsArea, self, 'autocommit',
'Commit', box=False)
commit_button.setFixedWidth(self.control_area_width - 5)
self.buttonsArea.layout().addWidget(commit_button)
示例3: __init__
# 需要导入模块: from AnyQt.QtWidgets import QVBoxLayout [as 别名]
# 或者: from AnyQt.QtWidgets.QVBoxLayout import addStretch [as 别名]
def __init__(self):
super().__init__()
main_layout = QVBoxLayout()
main_layout.setContentsMargins(10, 10, 10, 10)
self.controlArea.layout().addLayout(main_layout)
box = QGroupBox(title=self.tr("Default Method"), flat=False)
box_layout = QVBoxLayout(box)
main_layout.addWidget(box)
button_group = QButtonGroup()
button_group.buttonClicked[int].connect(self.set_default_method)
for i, method in enumerate(self.METHODS):
if not method.columns_only:
button = QRadioButton(method.name)
button.setChecked(i == self.default_method_index)
button_group.addButton(button, i)
box_layout.addWidget(button)
self.default_button_group = button_group
box = QGroupBox(title=self.tr("Individual Attribute Settings"),
flat=False)
main_layout.addWidget(box)
horizontal_layout = QHBoxLayout(box)
main_layout.addWidget(box)
self.varview = QListView(
selectionMode=QListView.ExtendedSelection
)
self.varview.setItemDelegate(DisplayFormatDelegate())
self.varmodel = itemmodels.VariableListModel()
self.varview.setModel(self.varmodel)
self.varview.selectionModel().selectionChanged.connect(
self._on_var_selection_changed
)
self.selection = self.varview.selectionModel()
horizontal_layout.addWidget(self.varview)
method_layout = QVBoxLayout()
horizontal_layout.addLayout(method_layout)
button_group = QButtonGroup()
for i, method in enumerate(self.METHODS):
button = QRadioButton(text=method.name)
button_group.addButton(button, i)
method_layout.addWidget(button)
self.value_combo = QComboBox(
minimumContentsLength=8,
sizeAdjustPolicy=QComboBox.AdjustToMinimumContentsLength,
activated=self._on_value_selected
)
self.value_combo.currentIndexChanged.connect(self._on_value_changed)
self.value_double = QDoubleSpinBox(
editingFinished=self._on_value_selected,
minimum=-1000., maximum=1000., singleStep=.1, decimals=3,
value=self.default_value
)
self.value_stack = value_stack = QStackedLayout()
value_stack.addWidget(self.value_combo)
value_stack.addWidget(self.value_double)
method_layout.addLayout(value_stack)
button_group.buttonClicked[int].connect(
self.set_method_for_current_selection
)
method_layout.addStretch(2)
reset_button = QPushButton(
"Restore All to Default", checked=False, checkable=False,
clicked=self.reset_variable_methods, default=False,
autoDefault=False)
method_layout.addWidget(reset_button)
self.variable_button_group = button_group
box = gui.auto_commit(
self.controlArea, self, "autocommit", "Apply",
orientation=Qt.Horizontal, checkbox_label="Apply automatically")
box.layout().insertSpacing(0, 80)
box.layout().insertWidget(0, self.report_button)
self.data = None
self.modified = False
self.default_method = self.METHODS[self.default_method_index]
self.update_varview()
示例4: __init__
# 需要导入模块: from AnyQt.QtWidgets import QVBoxLayout [as 别名]
# 或者: from AnyQt.QtWidgets.QVBoxLayout import addStretch [as 别名]
def __init__(self):
super().__init__()
self.data = None
self.editors = {}
box = gui.vBox(self.controlArea, "Variable Definitions")
toplayout = QHBoxLayout()
toplayout.setContentsMargins(0, 0, 0, 0)
box.layout().addLayout(toplayout)
self.editorstack = QStackedWidget(
sizePolicy=QSizePolicy(QSizePolicy.MinimumExpanding,
QSizePolicy.MinimumExpanding)
)
for descclass, editorclass in self.EDITORS:
editor = editorclass()
editor.featureChanged.connect(self._on_modified)
self.editors[descclass] = editor
self.editorstack.addWidget(editor)
self.editorstack.setEnabled(False)
buttonlayout = QVBoxLayout(spacing=10)
buttonlayout.setContentsMargins(0, 0, 0, 0)
self.addbutton = QPushButton(
"New", toolTip="Create a new variable",
minimumWidth=120,
shortcut=QKeySequence.New
)
def unique_name(fmt, reserved):
candidates = (fmt.format(i) for i in count(1))
return next(c for c in candidates if c not in reserved)
def reserved_names():
varnames = []
if self.data is not None:
varnames = [var.name for var in
self.data.domain.variables + self.data.domain.metas]
varnames += [desc.name for desc in self.featuremodel]
return set(varnames)
def generate_newname(fmt):
return unique_name(fmt, reserved_names())
menu = QMenu(self.addbutton)
cont = menu.addAction("Numeric")
cont.triggered.connect(
lambda: self.addFeature(
ContinuousDescriptor(generate_newname("X{}"), "", 3))
)
disc = menu.addAction("Categorical")
disc.triggered.connect(
lambda: self.addFeature(
DiscreteDescriptor(generate_newname("D{}"), "",
("A", "B"), -1, False))
)
string = menu.addAction("Text")
string.triggered.connect(
lambda: self.addFeature(
StringDescriptor(generate_newname("S{}"), ""))
)
menu.addSeparator()
self.duplicateaction = menu.addAction("Duplicate Selected Variable")
self.duplicateaction.triggered.connect(self.duplicateFeature)
self.duplicateaction.setEnabled(False)
self.addbutton.setMenu(menu)
self.removebutton = QPushButton(
"Remove", toolTip="Remove selected variable",
minimumWidth=120,
shortcut=QKeySequence.Delete
)
self.removebutton.clicked.connect(self.removeSelectedFeature)
buttonlayout.addWidget(self.addbutton)
buttonlayout.addWidget(self.removebutton)
buttonlayout.addStretch(10)
toplayout.addLayout(buttonlayout, 0)
toplayout.addWidget(self.editorstack, 10)
# Layout for the list view
layout = QVBoxLayout(spacing=1, margin=0)
self.featuremodel = DescriptorModel(parent=self)
self.featureview = QListView(
minimumWidth=200,
sizePolicy=QSizePolicy(QSizePolicy.Minimum,
QSizePolicy.MinimumExpanding)
)
self.featureview.setItemDelegate(FeatureItemDelegate(self))
self.featureview.setModel(self.featuremodel)
self.featureview.selectionModel().selectionChanged.connect(
self._on_selectedVariableChanged
)
#.........这里部分代码省略.........
示例5: __init__
# 需要导入模块: from AnyQt.QtWidgets import QVBoxLayout [as 别名]
# 或者: from AnyQt.QtWidgets.QVBoxLayout import addStretch [as 别名]
def __init__(self):
super().__init__()
self.data = None # type: Optional[Orange.data.Table]
self.learner = None # type: Optional[Learner]
self.default_learner = SimpleTreeLearner()
self.modified = False
self.executor = qconcurrent.ThreadExecutor(self)
self.__task = None
main_layout = QVBoxLayout()
main_layout.setContentsMargins(10, 10, 10, 10)
self.controlArea.layout().addLayout(main_layout)
box = QGroupBox(title=self.tr("Default Method"), flat=False)
box_layout = QVBoxLayout(box)
main_layout.addWidget(box)
button_group = QButtonGroup()
button_group.buttonClicked[int].connect(self.set_default_method)
for method, _ in list(METHODS.items())[1:-1]:
imputer = self.create_imputer(method)
button = QRadioButton(imputer.name)
button.setChecked(method == self.default_method_index)
button_group.addButton(button, method)
box_layout.addWidget(button)
self.default_button_group = button_group
box = QGroupBox(title=self.tr("Individual Attribute Settings"),
flat=False)
main_layout.addWidget(box)
horizontal_layout = QHBoxLayout(box)
main_layout.addWidget(box)
self.varview = QListView(
selectionMode=QListView.ExtendedSelection,
uniformItemSizes=True
)
self.varview.setItemDelegate(DisplayFormatDelegate())
self.varmodel = itemmodels.VariableListModel()
self.varview.setModel(self.varmodel)
self.varview.selectionModel().selectionChanged.connect(
self._on_var_selection_changed
)
self.selection = self.varview.selectionModel()
horizontal_layout.addWidget(self.varview)
method_layout = QVBoxLayout()
horizontal_layout.addLayout(method_layout)
button_group = QButtonGroup()
for method in Method:
imputer = self.create_imputer(method)
button = QRadioButton(text=imputer.name)
button_group.addButton(button, method)
method_layout.addWidget(button)
self.value_combo = QComboBox(
minimumContentsLength=8,
sizeAdjustPolicy=QComboBox.AdjustToMinimumContentsLength,
activated=self._on_value_selected
)
self.value_double = QDoubleSpinBox(
editingFinished=self._on_value_selected,
minimum=-1000., maximum=1000., singleStep=.1, decimals=3,
)
self.value_stack = value_stack = QStackedWidget()
value_stack.addWidget(self.value_combo)
value_stack.addWidget(self.value_double)
method_layout.addWidget(value_stack)
button_group.buttonClicked[int].connect(
self.set_method_for_current_selection
)
method_layout.addStretch(2)
reset_button = QPushButton(
"Restore All to Default", checked=False, checkable=False,
clicked=self.reset_variable_state, default=False,
autoDefault=False)
method_layout.addWidget(reset_button)
self.variable_button_group = button_group
box = gui.auto_commit(
self.controlArea, self, "autocommit", "Apply",
orientation=Qt.Horizontal,
checkbox_label="Apply automatically")
box.button.setFixedWidth(180)
box.layout().insertStretch(0)
示例6: __init__
# 需要导入模块: from AnyQt.QtWidgets import QVBoxLayout [as 别名]
# 或者: from AnyQt.QtWidgets.QVBoxLayout import addStretch [as 别名]
def __init__(self, parent=None, filename=None):
super(MainForm, self).__init__(parent)
self.view = GraphicsView()
background = QPixmap(filename)
# assume screnshots were taken on the same system stamper is being used on
# DPI check might be more robust, can be added if needed
background.setDevicePixelRatio(self.devicePixelRatioF())
self.filename = os.path.splitext(filename)[0]
if ("-%s" % ORG) in self.filename:
self.filename = self.filename[:-len(ORG)-5] + ".png"
# self.view.setBackgroundBrush(QBrush(background))
# self.view.setCacheMode(QGraphicsView.CacheBackground)
# self.view.setDragMode(QGraphicsView.ScrollHandDrag)
self.scene = QGraphicsScene(self)
self.scene.addPixmap(background)
global scene
scene = self.scene
self.view.dialog = self
self.view.setScene(self.scene)
self.prevPoint = QPoint()
self.lastStamp = -1
buttonLayout = QVBoxLayout()
for text, slot in (
("&Tag", self.addTag),
("Align &bottom", self.alignBottom),
("Align &left", self.alignLeft),
("&Save", self.save),
("&Quit", self.accept)):
button = QPushButton(text)
button.clicked.connect(slot)
if not MAC:
button.setFocusPolicy(Qt.NoFocus)
self.lineedit.returnPressed.connect(self.updateUi)
if text == "&Save":
buttonLayout.addStretch(5)
if text == "&Quit":
buttonLayout.addStretch(1)
buttonLayout.addWidget(button)
buttonLayout.addStretch()
size = background.size() / background.devicePixelRatioF()
self.view.resize(size.width(), size.height())
self.scene.setSceneRect(0, 0, size.width(), size.height())
self.view.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
layout = QHBoxLayout()
layout.addWidget(self.view, 1)
layout.addLayout(buttonLayout)
self.setLayout(layout)
self.setWindowTitle(AppName)
info_name = self.filename + "-" + TAG + ".txt"
if os.path.exists(info_name):
for tag, x, y in [line.strip().split("\t") for line in open(info_name, "rt").readlines()]:
self.addTag(int(tag), QPointF(int(x), int(y)), adjust_position=False)
global Dirty; Dirty=False
self.show()
self.raise_()
示例7: test
# 需要导入模块: from AnyQt.QtWidgets import QVBoxLayout [as 别名]
# 或者: from AnyQt.QtWidgets.QVBoxLayout import addStretch [as 别名]
def test(self):
window = QWidget()
layout = QVBoxLayout()
window.setLayout(layout)
stack = stackedwidget.AnimatedStackedWidget()
stack.transitionFinished.connect(self.app.exit)
layout.addStretch(2)
layout.addWidget(stack)
layout.addStretch(2)
window.show()
widget1 = QLabel("A label " * 10)
widget1.setWordWrap(True)
widget2 = QGroupBox("Group")
widget3 = QListView()
self.assertEqual(stack.count(), 0)
self.assertEqual(stack.currentIndex(), -1)
stack.addWidget(widget1)
self.assertEqual(stack.count(), 1)
self.assertEqual(stack.currentIndex(), 0)
stack.addWidget(widget2)
stack.addWidget(widget3)
self.assertEqual(stack.count(), 3)
self.assertEqual(stack.currentIndex(), 0)
def widgets():
return [stack.widget(i) for i in range(stack.count())]
self.assertSequenceEqual([widget1, widget2, widget3],
widgets())
stack.show()
stack.removeWidget(widget2)
self.assertEqual(stack.count(), 2)
self.assertEqual(stack.currentIndex(), 0)
self.assertSequenceEqual([widget1, widget3],
widgets())
stack.setCurrentIndex(1)
# wait until animation finished
self.app.exec_()
self.assertEqual(stack.currentIndex(), 1)
widget2 = QGroupBox("Group")
stack.insertWidget(1, widget2)
self.assertEqual(stack.count(), 3)
self.assertEqual(stack.currentIndex(), 2)
self.assertSequenceEqual([widget1, widget2, widget3],
widgets())
stack.transitionFinished.disconnect(self.app.exit)
self.singleShot(2000, lambda: stack.setCurrentIndex(0))
self.singleShot(4000, lambda: stack.setCurrentIndex(1))
self.singleShot(6000, lambda: stack.setCurrentIndex(2))
self.app.exec_()
示例8: test
# 需要导入模块: from AnyQt.QtWidgets import QVBoxLayout [as 别名]
# 或者: from AnyQt.QtWidgets.QVBoxLayout import addStretch [as 别名]
def test(self):
window = QWidget()
layout = QVBoxLayout()
window.setLayout(layout)
stack = stackedwidget.AnimatedStackedWidget()
stack.transitionFinished.connect(self.app.exit)
layout.addStretch(2)
layout.addWidget(stack)
layout.addStretch(2)
window.show()
widget1 = QLabel("A label " * 10)
widget1.setWordWrap(True)
widget2 = QGroupBox("Group")
widget3 = QListView()
self.assertEqual(stack.count(), 0)
self.assertEqual(stack.currentIndex(), -1)
stack.addWidget(widget1)
self.assertEqual(stack.count(), 1)
self.assertEqual(stack.currentIndex(), 0)
stack.addWidget(widget2)
stack.addWidget(widget3)
self.assertEqual(stack.count(), 3)
self.assertEqual(stack.currentIndex(), 0)
def widgets():
return [stack.widget(i) for i in range(stack.count())]
self.assertSequenceEqual([widget1, widget2, widget3],
widgets())
stack.show()
stack.removeWidget(widget2)
self.assertEqual(stack.count(), 2)
self.assertEqual(stack.currentIndex(), 0)
self.assertSequenceEqual([widget1, widget3],
widgets())
stack.setCurrentIndex(1)
# wait until animation finished
self.app.exec_()
self.assertEqual(stack.currentIndex(), 1)
widget2 = QGroupBox("Group")
stack.insertWidget(1, widget2)
self.assertEqual(stack.count(), 3)
self.assertEqual(stack.currentIndex(), 2)
self.assertSequenceEqual([widget1, widget2, widget3],
widgets())
stack.transitionFinished.disconnect(self.app.exit)
def toogle():
idx = stack.currentIndex()
stack.setCurrentIndex((idx + 1) % stack.count())
timer = QTimer(stack, interval=1000)
timer.timeout.connect(toogle)
timer.start()
self.app.exec_()