本文整理汇总了Python中AnyQt.QtWidgets.QHBoxLayout.addLayout方法的典型用法代码示例。如果您正苦于以下问题:Python QHBoxLayout.addLayout方法的具体用法?Python QHBoxLayout.addLayout怎么用?Python QHBoxLayout.addLayout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtWidgets.QHBoxLayout
的用法示例。
在下文中一共展示了QHBoxLayout.addLayout方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from AnyQt.QtWidgets import QHBoxLayout [as 别名]
# 或者: from AnyQt.QtWidgets.QHBoxLayout import addLayout [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()
示例2: __init__
# 需要导入模块: from AnyQt.QtWidgets import QHBoxLayout [as 别名]
# 或者: from AnyQt.QtWidgets.QHBoxLayout import addLayout [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)
示例3: __init__
# 需要导入模块: from AnyQt.QtWidgets import QHBoxLayout [as 别名]
# 或者: from AnyQt.QtWidgets.QHBoxLayout import addLayout [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
)
#.........这里部分代码省略.........
示例4: __init__
# 需要导入模块: from AnyQt.QtWidgets import QHBoxLayout [as 别名]
# 或者: from AnyQt.QtWidgets.QHBoxLayout import addLayout [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_()