本文整理汇总了Python中AnyQt.QtWidgets.QHBoxLayout类的典型用法代码示例。如果您正苦于以下问题:Python QHBoxLayout类的具体用法?Python QHBoxLayout怎么用?Python QHBoxLayout使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QHBoxLayout类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, parent):
QFrame.__init__(self, parent)
self.setContentsMargins(0, 0, 0, 0)
layout = QVBoxLayout()
layout.setContentsMargins(0, 0, 0, 0)
layout.setSpacing(1)
self._setNameLineEdit = QLineEdit(self)
layout.addWidget(self._setNameLineEdit)
self._setListView = QListView(self)
self._listModel = QStandardItemModel(self)
self._proxyModel = QSortFilterProxyModel(self)
self._proxyModel.setSourceModel(self._listModel)
self._setListView.setModel(self._proxyModel)
self._setListView.setItemDelegate(ListItemDelegate(self))
self._setNameLineEdit.textChanged.connect(
self._proxyModel.setFilterFixedString)
self._completer = QCompleter(self._listModel, self)
self._setNameLineEdit.setCompleter(self._completer)
self._listModel.itemChanged.connect(self._onSetNameChange)
layout.addWidget(self._setListView)
buttonLayout = QHBoxLayout()
self._addAction = QAction(
"+", self, toolTip="Add a new sort key")
self._updateAction = QAction(
"Update", self, toolTip="Update/save current selection")
self._removeAction = QAction(
"\u2212", self, toolTip="Remove selected sort key.")
self._addToolButton = QToolButton(self)
self._updateToolButton = QToolButton(self)
self._removeToolButton = QToolButton(self)
self._updateToolButton.setSizePolicy(
QSizePolicy.MinimumExpanding, QSizePolicy.Minimum)
self._addToolButton.setDefaultAction(self._addAction)
self._updateToolButton.setDefaultAction(self._updateAction)
self._removeToolButton.setDefaultAction(self._removeAction)
buttonLayout.addWidget(self._addToolButton)
buttonLayout.addWidget(self._updateToolButton)
buttonLayout.addWidget(self._removeToolButton)
layout.addLayout(buttonLayout)
self.setLayout(layout)
self._addAction.triggered.connect(self.addCurrentSelection)
self._updateAction.triggered.connect(self.updateSelectedSelection)
self._removeAction.triggered.connect(self.removeSelectedSelection)
self._setListView.selectionModel().selectionChanged.connect(
self._onListViewSelectionChanged)
self.selectionModel = None
self._selections = []
示例2: __init__
def __init__(self, parent=None, icon=QIcon(), text="", wordWrap=False,
textFormat=Qt.AutoText, standardButtons=NoButton, **kwargs):
super().__init__(parent, **kwargs)
self.__text = text
self.__icon = QIcon()
self.__wordWrap = wordWrap
self.__standardButtons = MessageWidget.NoButton
self.__buttons = []
layout = QHBoxLayout()
layout.setContentsMargins(8, 0, 8, 0)
self.__iconlabel = QLabel(objectName="icon-label")
self.__iconlabel.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
self.__textlabel = QLabel(objectName="text-label", text=text,
wordWrap=wordWrap, textFormat=textFormat)
if sys.platform == "darwin":
self.__textlabel.setAttribute(Qt.WA_MacSmallSize)
layout.addWidget(self.__iconlabel)
layout.addWidget(self.__textlabel)
self.setLayout(layout)
self.setIcon(icon)
self.setStandardButtons(standardButtons)
示例3: test_dock_standalone
def test_dock_standalone(self):
widget = QWidget()
layout = QHBoxLayout()
widget.setLayout(layout)
layout.addStretch(1)
widget.show()
dock = CollapsibleDockWidget()
layout.addWidget(dock)
list_view = QListView()
list_view.setModel(QStringListModel(["a", "b"], list_view))
label = QLabel("A label. ")
label.setWordWrap(True)
dock.setExpandedWidget(label)
dock.setCollapsedWidget(list_view)
dock.setExpanded(True)
self.app.processEvents()
def toogle():
dock.setExpanded(not dock.expanded())
self.singleShot(2000, toogle)
toogle()
self.app.exec_()
示例4: test_toolbox
def test_toolbox(self):
w = QWidget()
layout = QHBoxLayout()
reg = global_registry()
qt_reg = QtWidgetRegistry(reg)
triggered_actions = []
model = qt_reg.model()
file_action = qt_reg.action_for_widget(
"Orange.widgets.data.owfile.OWFile"
)
box = WidgetToolBox()
box.setModel(model)
box.triggered.connect(triggered_actions.append)
layout.addWidget(box)
box.setButtonSize(QSize(50, 80))
w.setLayout(layout)
w.show()
file_action.trigger()
box.setButtonSize(QSize(60, 80))
box.setIconSize(QSize(35, 35))
box.setTabButtonHeight(40)
box.setTabIconSize(QSize(30, 30))
self.app.exec_()
示例5: __init__
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
layout = QFormLayout(
fieldGrowthPolicy=QFormLayout.ExpandingFieldsGrow
)
layout.setContentsMargins(0, 0, 0, 0)
self.nameedit = QLineEdit(
placeholderText="Name...",
sizePolicy=QSizePolicy(QSizePolicy.Minimum,
QSizePolicy.Fixed)
)
self.expressionedit = QLineEdit(
placeholderText="Expression..."
)
self.attrs_model = itemmodels.VariableListModel(
["Select Feature"], parent=self)
self.attributescb = QComboBox(
minimumContentsLength=16,
sizeAdjustPolicy=QComboBox.AdjustToMinimumContentsLengthWithIcon,
sizePolicy=QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
)
self.attributescb.setModel(self.attrs_model)
sorted_funcs = sorted(self.FUNCTIONS)
self.funcs_model = itemmodels.PyListModelTooltip()
self.funcs_model.setParent(self)
self.funcs_model[:] = chain(["Select Function"], sorted_funcs)
self.funcs_model.tooltips[:] = chain(
[''],
[self.FUNCTIONS[func].__doc__ for func in sorted_funcs])
self.functionscb = QComboBox(
minimumContentsLength=16,
sizeAdjustPolicy=QComboBox.AdjustToMinimumContentsLengthWithIcon,
sizePolicy=QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum))
self.functionscb.setModel(self.funcs_model)
hbox = QHBoxLayout()
hbox.addWidget(self.attributescb)
hbox.addWidget(self.functionscb)
layout.addRow(self.nameedit, self.expressionedit)
layout.addRow(self.tr(""), hbox)
self.setLayout(layout)
self.nameedit.editingFinished.connect(self._invalidate)
self.expressionedit.textChanged.connect(self._invalidate)
self.attributescb.currentIndexChanged.connect(self.on_attrs_changed)
self.functionscb.currentIndexChanged.connect(self.on_funcs_changed)
self._modified = False
示例6: insertRow
def insertRow(self, index, actions, background="light-orange"):
"""Insert a row with `actions` at `index`.
"""
widget = QWidget(objectName="icon-row")
layout = QHBoxLayout()
layout.setContentsMargins(40, 0, 40, 0)
layout.setSpacing(65)
widget.setLayout(layout)
self.__mainLayout.insertWidget(index, widget, stretch=10,
alignment=Qt.AlignCenter)
for i, action in enumerate(actions):
self.insertAction(index, i, action, background)
示例7: __init__
def __init__(self):
super().__init__()
self.corpus = None
self.method = None
box = QGroupBox(title='Options')
box.setLayout(self.create_configuration_layout())
self.controlArea.layout().addWidget(box)
buttons_layout = QHBoxLayout()
buttons_layout.addSpacing(15)
buttons_layout.addWidget(
gui.auto_commit(None, self, 'autocommit', 'Commit', box=False)
)
self.controlArea.layout().addLayout(buttons_layout)
self.update_method()
示例8: __init__
def __init__(self, parent=None, label=""):
QWidget.__init__(self, parent)
OWComponent.__init__(self, None)
layout = QHBoxLayout()
layout.setContentsMargins(0, 0, 0, 0)
self.setLayout(layout)
self.position = 0
self.edit = lineEditFloatRange(self, self, "position", callback=self.edited.emit)
layout.addWidget(self.edit)
self.edit.focusIn.connect(self.focusIn.emit)
self.line = MovableVline(position=self.position, label=label)
connect_line(self.line, self, "position")
self.line.sigMoveFinished.connect(self.edited.emit)
示例9: __init__
def __init__(self):
super().__init__()
self.corpus = None
self.last_config = None # to avoid reruns with the same params
self.strings_attrs = []
self.profiler = TweetProfiler(on_server_down=self.Error.server_down)
# Settings
self.controlArea.layout().addWidget(self.generate_grid_layout())
# Auto commit
buttons_layout = QHBoxLayout()
buttons_layout.addSpacing(15)
buttons_layout.addWidget(
gui.auto_commit(None, self, 'auto_commit', 'Commit', box=False)
)
self.controlArea.layout().addLayout(buttons_layout)
示例10: test_widgettoolgrid
def test_widgettoolgrid(self):
w = QWidget()
layout = QHBoxLayout()
reg = global_registry()
qt_reg = QtWidgetRegistry(reg)
triggered_actions1 = []
triggered_actions2 = []
model = qt_reg.model()
data_descriptions = qt_reg.widgets("Data")
file_action = qt_reg.action_for_widget(
"Orange.widgets.data.owfile.OWFile"
)
actions = list(map(qt_reg.action_for_widget, data_descriptions))
grid = ToolGrid(w)
grid.setActions(actions)
grid.actionTriggered.connect(triggered_actions1.append)
layout.addWidget(grid)
grid = WidgetToolGrid(w)
# First category ("Data")
grid.setModel(model, rootIndex=model.index(0, 0))
self.assertIs(model, grid.model())
# Test order of buttons
grid_layout = grid.layout()
for i in range(len(actions)):
button = grid_layout.itemAtPosition(i / 4, i % 4).widget()
self.assertIs(button.defaultAction(), actions[i])
grid.actionTriggered.connect(triggered_actions2.append)
layout.addWidget(grid)
w.setLayout(layout)
w.show()
file_action.trigger()
self.app.exec_()
示例11: __init__
def __init__(self, master):
QWidget.__init__(self)
gui.OWComponent.__init__(self, master)
self.master = master
self.preprocessor = master.preprocessor
self.value = getattr(self.preprocessor, self.attribute)
# Title bar.
title_holder = QWidget()
title_holder.setSizePolicy(QSizePolicy.MinimumExpanding,
QSizePolicy.Fixed)
title_holder.setStyleSheet("""
.QWidget {
background: qlineargradient( x1:0 y1:0, x2:0 y2:1,
stop:0 #F8F8F8, stop:1 #C8C8C8);
border-bottom: 1px solid #B3B3B3;
}
""")
self.titleArea = QHBoxLayout()
self.titleArea.setContentsMargins(10, 5, 10, 5)
self.titleArea.setSpacing(0)
title_holder.setLayout(self.titleArea)
self.title_label = QLabel(self.title)
self.title_label.mouseDoubleClickEvent = self.on_toggle
self.title_label.setStyleSheet('font-size: 12px; border: 2px solid red;')
self.titleArea.addWidget(self.title_label)
self.off_label = QLabel('[disabled]')
self.off_label.setStyleSheet('color: #B0B0B0; margin-left: 5px;')
self.titleArea.addWidget(self.off_label)
self.off_label.hide()
self.titleArea.addStretch()
# Root.
self.rootArea = QVBoxLayout()
self.rootArea.setContentsMargins(0, 0, 0, 0)
self.rootArea.setSpacing(0)
self.setLayout(self.rootArea)
self.rootArea.addWidget(title_holder)
self.contents = QWidget()
contentArea = QVBoxLayout()
contentArea.setContentsMargins(15, 10, 15, 10)
self.contents.setLayout(contentArea)
self.rootArea.addWidget(self.contents)
self.method_layout = self.Layout()
self.setup_method_layout()
self.contents.layout().addLayout(self.method_layout)
if self.toggle_enabled:
self.on_off_button = OnOffButton(enabled=self.enabled)
self.on_off_button.stateChanged.connect(self.on_toggle)
self.on_off_button.setContentsMargins(0, 0, 0, 0)
self.titleArea.addWidget(self.on_off_button)
self.display_widget(update_master_width=False)
示例12: __setupUi
def __setupUi(self):
layout = QVBoxLayout()
layout.setContentsMargins(0, 0, 0, 0)
layout.setSpacing(0)
self.editor = SchemeInfoEdit(self)
self.editor.layout().setContentsMargins(20, 20, 20, 20)
self.editor.layout().setSpacing(15)
self.editor.setSizePolicy(QSizePolicy.MinimumExpanding,
QSizePolicy.MinimumExpanding)
heading = self.tr("Workflow Info")
heading = "<h3>{0}</h3>".format(heading)
self.heading = QLabel(heading, self, objectName="heading")
# Insert heading
self.editor.layout().insertRow(0, self.heading)
self.buttonbox = QDialogButtonBox(
QDialogButtonBox.Ok | QDialogButtonBox.Cancel,
Qt.Horizontal,
self
)
# Insert button box
self.editor.layout().addRow(self.buttonbox)
widget = StyledWidget(self, objectName="auto-show-container")
check_layout = QHBoxLayout()
check_layout.setContentsMargins(20, 10, 20, 10)
self.__showAtNewSchemeCheck = \
QCheckBox(self.tr("Show when I make a New Workflow."),
self,
objectName="auto-show-check",
checked=False,
)
check_layout.addWidget(self.__showAtNewSchemeCheck)
check_layout.addWidget(
QLabel(self.tr("You can also edit Workflow Info later "
"(File -> Workflow Info)."),
self,
objectName="auto-show-info"),
alignment=Qt.AlignRight)
widget.setLayout(check_layout)
widget.setSizePolicy(QSizePolicy.MinimumExpanding,
QSizePolicy.Fixed)
if self.__autoCommit:
self.buttonbox.accepted.connect(self.editor.commit)
self.buttonbox.accepted.connect(self.accept)
self.buttonbox.rejected.connect(self.reject)
layout.addWidget(self.editor, stretch=10)
layout.addWidget(widget)
self.setLayout(layout)
示例13: __init__
def __init__(self, parent=None, **kwargs):
BaseEditor.__init__(self, parent, **kwargs)
self.__method = DiscretizeEditor.EqualFreq
self.__nintervals = 4
layout = QVBoxLayout()
self.setLayout(layout)
self.__group = group = QButtonGroup(self, exclusive=True)
for method in [self.EntropyMDL, self.EqualFreq, self.EqualWidth,
self.Drop]:
rb = QRadioButton(
self, text=self.Names[method],
checked=self.__method == method
)
layout.addWidget(rb)
group.addButton(rb, method)
group.buttonClicked.connect(self.__on_buttonClicked)
self.__slbox = slbox = QGroupBox(
title="Number of intervals (for equal width/frequency)",
flat=True
)
slbox.setLayout(QHBoxLayout())
self.__slider = slider = QSlider(
orientation=Qt.Horizontal,
minimum=2, maximum=10, value=self.__nintervals,
enabled=self.__method in [self.EqualFreq, self.EqualWidth],
pageStep=1, tickPosition=QSlider.TicksBelow
)
slider.valueChanged.connect(self.__on_valueChanged)
slbox.layout().addWidget(slider)
self.__slabel = slabel = QLabel()
slbox.layout().addWidget(slabel)
container = QHBoxLayout()
container.setContentsMargins(13, 0, 0, 0)
container.addWidget(slbox)
self.layout().insertLayout(3, container)
self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Preferred)
示例14: __init__
def __init__(self, parent=None):
super().__init__(parent, Qt.CustomizeWindowHint | Qt.FramelessWindowHint | Qt.Window |
Qt.WindowStaysOnTopHint | Qt.X11BypassWindowManagerHint)
self.setAttribute(Qt.WA_DeleteOnClose)
self.installEventFilter(self)
self.setMouseTracking(True)
self._band = QRubberBand(QRubberBand.Rectangle, self)
self._resize_origin = None
self._drag_mask = 0
self._origin = None
self.selected_image = None
# Window background
desktop = QApplication.desktop()
if is_qt5():
g = desktop.geometry()
self._snapshot = QPixmap(g.width(), g.height())
painter = QPainter(self._snapshot)
for screen in QApplication.screens():
g = screen.geometry()
painter.drawPixmap(g, screen.grabWindow(0, g.x(), g.y(), g.width(), g.height()))
painter.end()
else:
self._snapshot = QPixmap.grabWindow(desktop.winId(), 0, 0, desktop.width(), desktop.height())
self.setGeometry(desktop.geometry())
self._darken = self._snapshot.copy()
painter = QPainter(self._darken)
brush = QBrush(QColor(0, 0, 0, 128))
painter.setBrush(brush)
painter.drawRect(self._darken.rect())
painter.end()
# Buttons
self._buttons = QWidget(self)
self._button_layout = QHBoxLayout(self._buttons)
self._button_layout.setSpacing(0)
self._button_layout.setContentsMargins(0, 0, 0, 0)
self._button_layout.setContentsMargins(0, 0, 0, 0)
self.save_as = QPushButton(self.tr('Save As'))
self.save_as.pressed.connect(self.save_image_as)
self.save_as.setCursor(Qt.ArrowCursor)
self._button_layout.addWidget(self.save_as)
self.copy = QPushButton(self.tr('Copy'))
self.copy.pressed.connect(self.copy_to_clipboard)
self.copy.setCursor(Qt.ArrowCursor)
self._button_layout.addWidget(self.copy)
self.share = QPushButton(self.tr('Share'))
self.share.pressed.connect(self.share_selection)
self.share.setCursor(Qt.ArrowCursor)
self._button_layout.addWidget(self.share)
self._buttons.hide()
示例15: test_dock_standalone
def test_dock_standalone(self):
widget = QWidget()
layout = QHBoxLayout()
widget.setLayout(layout)
layout.addStretch(1)
widget.show()
dock = CollapsibleDockWidget()
layout.addWidget(dock)
list_view = QListView()
list_view.setModel(QStringListModel(["a", "b"], list_view))
label = QLabel("A label. ")
label.setWordWrap(True)
dock.setExpandedWidget(label)
dock.setCollapsedWidget(list_view)
dock.setExpanded(True)
dock.setExpanded(False)
timer = QTimer(dock, interval=200)
timer.timeout.connect(lambda: dock.setExpanded(not dock.expanded()))
timer.start()