本文整理汇总了Python中qtpy.QtWidgets.QHBoxLayout.addWidget方法的典型用法代码示例。如果您正苦于以下问题:Python QHBoxLayout.addWidget方法的具体用法?Python QHBoxLayout.addWidget怎么用?Python QHBoxLayout.addWidget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtpy.QtWidgets.QHBoxLayout
的用法示例。
在下文中一共展示了QHBoxLayout.addWidget方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from qtpy.QtWidgets import QHBoxLayout [as 别名]
# 或者: from qtpy.QtWidgets.QHBoxLayout import addWidget [as 别名]
def __init__(self, editor):
Panel.__init__(self, editor)
self._editor = editor
self._editor.sig_cursor_position_changed.connect(
self._handle_cursor_position_change_event
)
# The layout
hbox = QHBoxLayout()
self.class_cb = QComboBox()
self.method_cb = QComboBox()
hbox.addWidget(self.class_cb)
hbox.addWidget(self.method_cb)
hbox.setSpacing(0)
hbox.setContentsMargins(0, 0, 0, 0)
self.setLayout(hbox)
# Internal data
self.folds = None
self.parents = None
self.classes = None
self.funcs = None
# Initial data for the dropdowns.
self.class_cb.addItem("<None>", 0)
self.method_cb.addItem("<None>", 0)
# Attach some events.
self.class_cb.activated.connect(self.combobox_activated)
self.method_cb.activated.connect(self.combobox_activated)
示例2: create_controls
# 需要导入模块: from qtpy.QtWidgets import QHBoxLayout [as 别名]
# 或者: from qtpy.QtWidgets.QHBoxLayout import addWidget [as 别名]
def create_controls(self):
self.btn_start = QPushButton(tr("Start"))
self.btn_stop = QPushButton(tr("Stop"))
self.btn_stop.setEnabled(False)
self.btn_start.clicked.connect(self.start_recording)
self.btn_stop.clicked.connect(self.stop_recording)
self.chk_actions = QCheckBox(tr("Actions"))
self.chk_code = QCheckBox(tr("Code"))
for c in [self.chk_actions, self.chk_code]:
c.setChecked(True)
c.toggled.connect(self.update_filter)
hbox = QHBoxLayout()
for w in [self.btn_start, self.btn_stop]:
hbox.addWidget(w)
hbox2 = QHBoxLayout()
for w in [self.chk_actions, self.chk_code]:
hbox2.addWidget(w)
vbox = QVBoxLayout()
vbox.addLayout(hbox)
vbox.addLayout(hbox2)
wrap = QWidget()
wrap.setLayout(vbox)
height = vbox.sizeHint().height()
wrap.setFixedHeight(height)
self.setWidget(wrap)
示例3: __init__
# 需要导入模块: from qtpy.QtWidgets import QHBoxLayout [as 别名]
# 或者: from qtpy.QtWidgets.QHBoxLayout import addWidget [as 别名]
def __init__(self, parent):
QDialog.__init__(self, parent)
self.setWindowTitle("Spyder %s: %s" % (__version__,
_("Dependencies")))
self.setWindowIcon(ima.icon('tooloptions'))
self.setModal(True)
self.treewidget = DependenciesTreeWidget(self)
self.label = QLabel(_("Optional modules are not required to run "
"Spyder but enhance its functions."))
self.label2 = QLabel(_("<b>Note:</b> New dependencies or changed ones "
"will be correctly detected only after Spyder "
"is restarted."))
btn = QPushButton(_("Copy to clipboard"), )
btn.clicked.connect(self.copy_to_clipboard)
bbox = QDialogButtonBox(QDialogButtonBox.Ok)
bbox.accepted.connect(self.accept)
hlayout = QHBoxLayout()
hlayout.addWidget(btn)
hlayout.addStretch()
hlayout.addWidget(bbox)
vlayout = QVBoxLayout()
vlayout.addWidget(self.treewidget)
vlayout.addWidget(self.label)
vlayout.addWidget(self.label2)
vlayout.addLayout(hlayout)
self.setLayout(vlayout)
self.resize(840, 560)
示例4: AlgorithmProgressWidget
# 需要导入模块: from qtpy.QtWidgets import QHBoxLayout [as 别名]
# 或者: from qtpy.QtWidgets.QHBoxLayout import addWidget [as 别名]
class AlgorithmProgressWidget(QWidget):
"""
Widget consisting of a progress bar and a button.
"""
def __init__(self, parent=None):
super(AlgorithmProgressWidget, self).__init__(parent)
self.progress_bar = None
self.details_button = QPushButton('Details')
self.details_button.clicked.connect(self.show_dialog)
self.layout = QHBoxLayout()
self.layout.addStretch()
self.layout.addWidget(self.details_button)
self.setLayout(self.layout)
self.presenter = AlgorithmProgressPresenter(self)
def show_progress_bar(self):
if self.progress_bar is None:
self.progress_bar = QProgressBar()
self.progress_bar.setAlignment(Qt.AlignHCenter)
self.layout.insertWidget(0, self.progress_bar)
self.layout.removeItem(self.layout.takeAt(1))
def hide_progress_bar(self):
if self.progress_bar is not None:
self.layout.insertStretch(0)
self.layout.removeWidget(self.progress_bar)
self.progress_bar.close()
self.progress_bar = None
def show_dialog(self):
dialog = AlgorithmMonitorDialog(self, self.presenter.model)
dialog.show()
示例5: __init__
# 需要导入模块: from qtpy.QtWidgets import QHBoxLayout [as 别名]
# 或者: from qtpy.QtWidgets.QHBoxLayout import addWidget [as 别名]
def __init__(self, parent, model):
super(AlgorithmMonitorDialog, self).__init__(parent)
self.tree = QTreeWidget(self)
self.tree.setColumnCount(3)
self.tree.setSelectionMode(QTreeWidget.NoSelection)
self.tree.setColumnWidth(0, 220)
self.tree.setHeaderLabels(['Algorithm', 'Progress', ''])
header = self.tree.header()
header.setSectionResizeMode(1, QHeaderView.Stretch)
header.setSectionResizeMode(2, QHeaderView.Fixed)
header.setStretchLastSection(False)
button_layout = QHBoxLayout()
self.close_button = QPushButton('Close')
button_layout.addStretch()
button_layout.addWidget(self.close_button)
layout = QVBoxLayout()
layout.addWidget(self.tree)
layout.addLayout(button_layout)
self.setLayout(layout)
self.setWindowTitle('Mantid - Algorithm progress')
self.setWindowIcon(QIcon(":/MantidPlot_Icon_32offset.png"))
self.resize(500, 300)
self.presenter = AlgorithmProgressDialogPresenter(self, model)
self.presenter.update_gui()
示例6: create_combobox
# 需要导入模块: from qtpy.QtWidgets import QHBoxLayout [as 别名]
# 或者: from qtpy.QtWidgets.QHBoxLayout import addWidget [as 别名]
def create_combobox(self, text, choices, option, default=NoDefault,
tip=None, restart=False):
"""choices: couples (name, key)"""
label = QLabel(text)
combobox = QComboBox()
if tip is not None:
combobox.setToolTip(tip)
for name, key in choices:
if not (name is None and key is None):
combobox.addItem(name, to_qvariant(key))
# Insert separators
count = 0
for index, item in enumerate(choices):
name, key = item
if name is None and key is None:
combobox.insertSeparator(index + count)
count += 1
self.comboboxes[combobox] = (option, default)
layout = QHBoxLayout()
layout.addWidget(label)
layout.addWidget(combobox)
layout.addStretch(1)
layout.setContentsMargins(0, 0, 0, 0)
widget = QWidget(self)
widget.label = label
widget.combobox = combobox
widget.setLayout(layout)
combobox.restart_required = restart
combobox.label_text = text
return widget
示例7: __init__
# 需要导入模块: from qtpy.QtWidgets import QHBoxLayout [as 别名]
# 或者: from qtpy.QtWidgets.QHBoxLayout import addWidget [as 别名]
def __init__(self, parent, plugin, tabs, data, icon):
QDialog.__init__(self, parent)
# Variables
self.plugins_tabs = []
self.plugins_data = []
self.plugins_instances = []
self.add_plugin(plugin, tabs, data, icon)
self.plugin = None # Last plugin with focus
self.mode = self.FILE_MODE # By default start in this mode
self.initial_cursors = None # {fullpath: QCursor}
self.initial_path = None # Fullpath of initial active editor
self.initial_widget = None # Initial active editor
self.line_number = None # Selected line number in filer
self.is_visible = False # Is the switcher visible?
help_text = _("Press <b>Enter</b> to switch files or <b>Esc</b> to "
"cancel.<br><br>Type to filter filenames.<br><br>"
"Use <b>:number</b> to go to a line, e.g. "
"<b><code>main:42</code></b><br>"
"Use <b>@symbol_text</b> to go to a symbol, e.g. "
"<b><code>@init</code></b>"
"<br><br> Press <b>Ctrl+W</b> to close current tab.<br>")
# Either allow searching for a line number or a symbol but not both
regex = QRegExp("([A-Za-z0-9_]{0,100}@[A-Za-z0-9_]{0,100})|" +
"([A-Za-z0-9_]{0,100}:{0,1}[0-9]{0,100})")
# Widgets
self.edit = FilesFilterLine(self)
self.help = HelperToolButton()
self.list = QListWidget(self)
self.filter = KeyPressFilter()
regex_validator = QRegExpValidator(regex, self.edit)
# Widgets setup
self.setWindowFlags(Qt.Popup | Qt.FramelessWindowHint)
self.setWindowOpacity(0.95)
self.edit.installEventFilter(self.filter)
self.edit.setValidator(regex_validator)
self.help.setToolTip(help_text)
self.list.setItemDelegate(HTMLDelegate(self))
# Layout
edit_layout = QHBoxLayout()
edit_layout.addWidget(self.edit)
edit_layout.addWidget(self.help)
layout = QVBoxLayout()
layout.addLayout(edit_layout)
layout.addWidget(self.list)
self.setLayout(layout)
# Signals
self.rejected.connect(self.restore_initial_state)
self.filter.sig_up_key_pressed.connect(self.previous_row)
self.filter.sig_down_key_pressed.connect(self.next_row)
self.edit.returnPressed.connect(self.accept)
self.edit.textChanged.connect(self.setup)
self.list.itemSelectionChanged.connect(self.item_selection_changed)
self.list.clicked.connect(self.edit.setFocus)
示例8: __init__
# 需要导入模块: from qtpy.QtWidgets import QHBoxLayout [as 别名]
# 或者: from qtpy.QtWidgets.QHBoxLayout import addWidget [as 别名]
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.catalog_list = CatalogList()
layout = QHBoxLayout()
layout.addWidget(QLabel("Catalog:"))
layout.addWidget(self.catalog_list)
self.setLayout(layout)
示例9: __init__
# 需要导入模块: from qtpy.QtWidgets import QHBoxLayout [as 别名]
# 或者: from qtpy.QtWidgets.QHBoxLayout import addWidget [as 别名]
def __init__(self, parent=None, logname=None, level=logging.NOTSET):
QWidget.__init__(self, parent=parent)
# Create Widgets
self.label = QLabel('Minimum displayed log level: ', parent=self)
self.combo = QComboBox(parent=self)
self.text = QPlainTextEdit(parent=self)
self.text.setReadOnly(True)
self.clear_btn = QPushButton("Clear", parent=self)
# Create layout
layout = QVBoxLayout()
level_control = QHBoxLayout()
level_control.addWidget(self.label)
level_control.addWidget(self.combo)
layout.addLayout(level_control)
layout.addWidget(self.text)
layout.addWidget(self.clear_btn)
self.setLayout(layout)
# Allow QCombobox to control log level
for log_level, value in LogLevels.as_dict().items():
self.combo.addItem(log_level, value)
self.combo.currentIndexChanged[str].connect(self.setLevel)
# Allow QPushButton to clear log text
self.clear_btn.clicked.connect(self.clear)
# Create a handler with the default format
self.handler = GuiHandler(level=level, parent=self)
self.logFormat = self.default_format
self.handler.message.connect(self.write)
# Create logger. Either as a root or given logname
self.log = None
self.level = None
self.logName = logname or ''
self.logLevel = level
self.destroyed.connect(functools.partial(logger_destroyed, self.log))
示例10: set_corner_widgets
# 需要导入模块: from qtpy.QtWidgets import QHBoxLayout [as 别名]
# 或者: from qtpy.QtWidgets.QHBoxLayout import addWidget [as 别名]
def set_corner_widgets(self, corner_widgets):
"""
Set tabs corner widgets
corner_widgets: dictionary of (corner, widgets)
corner: Qt.TopLeftCorner or Qt.TopRightCorner
widgets: list of widgets (may contains integers to add spacings)
"""
assert isinstance(corner_widgets, dict)
assert all(key in (Qt.TopLeftCorner, Qt.TopRightCorner)
for key in corner_widgets)
self.corner_widgets.update(corner_widgets)
for corner, widgets in list(self.corner_widgets.items()):
cwidget = QWidget()
cwidget.hide()
prev_widget = self.cornerWidget(corner)
if prev_widget:
prev_widget.close()
self.setCornerWidget(cwidget, corner)
clayout = QHBoxLayout()
clayout.setContentsMargins(0, 0, 0, 0)
for widget in widgets:
if isinstance(widget, int):
clayout.addSpacing(widget)
else:
clayout.addWidget(widget)
cwidget.setLayout(clayout)
cwidget.show()
示例11: create_window
# 需要导入模块: from qtpy.QtWidgets import QHBoxLayout [as 别名]
# 或者: from qtpy.QtWidgets.QHBoxLayout import addWidget [as 别名]
def create_window():
# Create app and widgets
app = QApplication(sys.argv)
win = QMainWindow()
main_area = QWidget()
button_area = QWidget()
scroll_area = QScrollArea()
button = QPushButton("Start Video")
btn_grab = QPushButton("Grab Frame")
# Create layouts
vbox = QVBoxLayout()
hbox = QHBoxLayout()
# Fill Layouts
vbox.addWidget(scroll_area)
vbox.addWidget(button_area)
hbox.addStretch()
hbox.addWidget(button)
hbox.addWidget(btn_grab)
# Assign layouts to widgets
main_area.setLayout(vbox)
button_area.setLayout(hbox)
scroll_area.setLayout(QVBoxLayout())
# Attach some child widgets directly
win.setCentralWidget(main_area)
return app, win, button, btn_grab, scroll_area
示例12: __init__
# 需要导入模块: from qtpy.QtWidgets import QHBoxLayout [as 别名]
# 或者: from qtpy.QtWidgets.QHBoxLayout import addWidget [as 别名]
def __init__(self, plugin, id_,
history_filename, config_options,
additional_options, interpreter_versions,
connection_file=None, hostname=None,
menu_actions=None, slave=False,
external_kernel=False, given_name=None):
super(ClientWidget, self).__init__(plugin)
SaveHistoryMixin.__init__(self, history_filename)
# --- Init attrs
self.id_ = id_
self.connection_file = connection_file
self.hostname = hostname
self.menu_actions = menu_actions
self.slave = slave
self.given_name = given_name
# --- Other attrs
self.options_button = None
self.stop_button = None
self.stop_icon = ima.icon('stop')
self.history = []
self.allow_rename = True
self.stderr_dir = None
# --- Widgets
self.shellwidget = ShellWidget(config=config_options,
ipyclient=self,
additional_options=additional_options,
interpreter_versions=interpreter_versions,
external_kernel=external_kernel,
local_kernel=True)
self.infowidget = WebView(self)
self.set_infowidget_font()
self.loading_page = self._create_loading_page()
self._show_loading_page()
# --- Layout
vlayout = QVBoxLayout()
toolbar_buttons = self.get_toolbar_buttons()
hlayout = QHBoxLayout()
for button in toolbar_buttons:
hlayout.addWidget(button)
vlayout.addLayout(hlayout)
vlayout.setContentsMargins(0, 0, 0, 0)
vlayout.addWidget(self.shellwidget)
vlayout.addWidget(self.infowidget)
self.setLayout(vlayout)
# --- Exit function
self.exit_callback = lambda: plugin.close_client(client=self)
# --- Signals
# As soon as some content is printed in the console, stop
# our loading animation
document = self.get_control().document()
document.contentsChange.connect(self._hide_loading_page)
# --- Dialog manager
self.dialog_manager = DialogManager()
示例13: __init__
# 需要导入模块: from qtpy.QtWidgets import QHBoxLayout [as 别名]
# 或者: from qtpy.QtWidgets.QHBoxLayout import addWidget [as 别名]
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.uid_label = QLabel()
self.open_individually_button = QPushButton('Open individually')
self.open_individually_button.hide()
self.open_individually_button.clicked.connect(self._open_individually)
self.open_overplotted_button = QPushButton('Open over-plotted')
self.open_overplotted_button.hide()
self.open_overplotted_button.clicked.connect(self._open_overplotted)
self.open_overplotted_on_button = QPushButton('Add to tab...')
self.open_overplotted_on_button.hide()
self.open_overplotted_on_button.setEnabled(False)
self.open_overplotted_on_button.clicked.connect(self._open_overplotted_on)
self.copy_uid_button = QPushButton('Copy UID to Clipboard')
self.copy_uid_button.hide()
self.copy_uid_button.clicked.connect(self._copy_uid)
self.streams = QLabel()
self.entries = []
uid_layout = QHBoxLayout()
uid_layout.addWidget(self.uid_label)
uid_layout.addWidget(self.copy_uid_button)
layout = QVBoxLayout()
layout.addWidget(self.open_individually_button)
layout.addWidget(self.open_overplotted_button)
layout.addWidget(self.open_overplotted_on_button)
layout.addLayout(uid_layout)
layout.addWidget(self.streams)
self.setLayout(layout)
self._tab_titles = ()
示例14: __init__
# 需要导入模块: from qtpy.QtWidgets import QHBoxLayout [as 别名]
# 或者: from qtpy.QtWidgets.QHBoxLayout import addWidget [as 别名]
def __init__(self, parent=None, show_fullpath=True, fullpath_sorting=True,
show_all_files=True, show_comments=True):
QWidget.__init__(self, parent)
self.treewidget = OutlineExplorerTreeWidget(self,
show_fullpath=show_fullpath,
fullpath_sorting=fullpath_sorting,
show_all_files=show_all_files,
show_comments=show_comments)
self.visibility_action = create_action(self,
_("Show/hide outline explorer"),
icon='outline_explorer_vis.png',
toggled=self.toggle_visibility)
self.visibility_action.setChecked(True)
btn_layout = QHBoxLayout()
btn_layout.setAlignment(Qt.AlignLeft)
for btn in self.setup_buttons():
btn_layout.addWidget(btn)
layout = QVBoxLayout()
layout.setContentsMargins(0, 0, 0, 0)
layout.addLayout(btn_layout)
layout.addWidget(self.treewidget)
self.setLayout(layout)
示例15: __init__
# 需要导入模块: from qtpy.QtWidgets import QHBoxLayout [as 别名]
# 或者: from qtpy.QtWidgets.QHBoxLayout import addWidget [as 别名]
def __init__(self, *args, **kwargs):
super(ClosePackageManagerDialog, self).__init__(*args, **kwargs)
self.label_icon = QLabel()
self.label_about = QLabel('Conda is still busy.\n\n'
'Do you want to cancel the process?')
self.button_ok = QPushButton('Yes')
self.button_cancel = QPushButton('No')
self.buttonbox = QDialogButtonBox(Qt.Horizontal)
# Widget setup
self.buttonbox.addButton(self.button_ok, QDialogButtonBox.ActionRole)
self.buttonbox.addButton(self.button_cancel,
QDialogButtonBox.ActionRole)
# self.label_icon.setPixmap(QPixmap(images.ANACONDA_ICON_64_PATH))
self.setWindowTitle("Cancel Process")
# Layouts
h_layout = QHBoxLayout()
h_layout.addWidget(self.label_icon, 0, Qt.AlignTop)
h_layout.addSpacing(10)
h_layout.addWidget(self.label_about)
main_layout = QVBoxLayout()
main_layout.addLayout(h_layout)
main_layout.addSpacing(20)
main_layout.addWidget(self.buttonbox)
self.setLayout(main_layout)
# Signals
self.button_ok.clicked.connect(self.accept)
self.button_cancel.clicked.connect(self.reject)