本文整理汇总了Python中qtpy.QtWidgets.QHBoxLayout.count方法的典型用法代码示例。如果您正苦于以下问题:Python QHBoxLayout.count方法的具体用法?Python QHBoxLayout.count怎么用?Python QHBoxLayout.count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtpy.QtWidgets.QHBoxLayout
的用法示例。
在下文中一共展示了QHBoxLayout.count方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ConvertFluxUnitGUI
# 需要导入模块: from qtpy.QtWidgets import QHBoxLayout [as 别名]
# 或者: from qtpy.QtWidgets.QHBoxLayout import count [as 别名]
class ConvertFluxUnitGUI(QDialog):
"""
GUI for unit conversions
"""
def __init__(self, controller, parent=None, convert_data=False):
super(ConvertFluxUnitGUI, self).__init__(parent=parent)
self.setWindowFlags(self.windowFlags() | Qt.Tool)
self.title = "Unit Conversion"
self.setMinimumSize(400, 270)
self.convert_data = convert_data
self.cubeviz_layout = controller.cubeviz_layout
self._hub = self.cubeviz_layout.session.hub
self.controller = controller
self.data = controller.data
self.controller_components = controller._components
self.current_unit = None
self.current_layout = None
self._init_ui()
def _init_ui(self):
# LINE 1: Data component drop down
self.component_prompt = QLabel("Data Component:")
self.component_prompt.setWordWrap(True)
# Add the data component labels to the drop down, with the ComponentID
# set as the userData:
if self.parent is not None and hasattr(self.parent, 'data_components'):
self.label_data = [(str(cid), cid) for cid in self.parent.data_components]
else:
self.label_data = [(str(cid), cid) for cid in self.data.visible_components]
default_index = 0
self.component_combo = QComboBox()
self.component_combo.setFixedWidth(200)
update_combobox(self.component_combo, self.label_data, default_index=default_index)
self.component_combo.currentIndexChanged.connect(self.update_unit_layout)
# hbl is short for Horizontal Box Layout
hbl1 = QHBoxLayout()
hbl1.addWidget(self.component_prompt)
hbl1.addWidget(self.component_combo)
hbl1.addStretch(1)
# LINE 2: Unit conversion layout
# This layout is filled by CubeVizUnit
self.unit_layout = QHBoxLayout() # this is hbl2
# LINE 3: Message box
self.message_box = QLabel("")
hbl3 = QHBoxLayout()
hbl3.addWidget(self.message_box)
hbl3.addStretch(1)
# Line 4: Buttons
ok_text = "Convert Data" if self.convert_data else "Convert Displayed Units"
ok_function = self.convert_data_units if self.convert_data else self.convert_displayed_units
self.okButton = QPushButton(ok_text)
self.okButton.clicked.connect(ok_function)
self.okButton.setDefault(True)
self.cancelButton = QPushButton("Cancel")
self.cancelButton.clicked.connect(self.cancel)
hbl4 = QHBoxLayout()
hbl4.addStretch(1)
hbl4.addWidget(self.cancelButton)
hbl4.addWidget(self.okButton)
vbl = QVBoxLayout()
vbl.addLayout(hbl1)
vbl.addLayout(self.unit_layout)
vbl.addLayout(hbl3)
vbl.addLayout(hbl4)
self.setLayout(vbl)
self.vbl = vbl
self.update_unit_layout(default_index)
self.show()
def update_unit_layout(self, index):
"""
Call back for component selection drop down.
"""
component_id = self.component_combo.currentData()
# STEP1: Clean up widgets from last component
widgets = (self.unit_layout.itemAt(i) for i in range(self.unit_layout.count()))
for w in widgets:
if isinstance(w, QSpacerItem):
self.unit_layout.removeItem(w)
continue
elif isinstance(w, QWidgetItem):
w = w.widget()
if hasattr(w, "deleteLater"):
#.........这里部分代码省略.........
示例2: FigureBrowser
# 需要导入模块: from qtpy.QtWidgets import QHBoxLayout [as 别名]
# 或者: from qtpy.QtWidgets.QHBoxLayout import count [as 别名]
#.........这里部分代码省略.........
self.setup_in_progress = True
self.mute_inline_action = create_action(
self, _("Mute inline plotting"),
tip=_("Mute inline plotting in the ipython console."),
toggled=lambda state:
self.option_changed('mute_inline_plotting', state)
)
self.mute_inline_action.setChecked(mute_inline_plotting)
self.show_plot_outline_action = create_action(
self, _("Show plot outline"),
tip=_("Show the plot outline."),
toggled=self.show_fig_outline_in_viewer
)
self.show_plot_outline_action.setChecked(show_plot_outline)
self.actions = [self.mute_inline_action, self.show_plot_outline_action]
self.setup_in_progress = False
def setup_options_button(self):
"""Add the cog menu button to the toolbar."""
if not self.options_button:
# When the FigureBowser widget is instatiated outside of the
# plugin (for testing purpose for instance), we need to create
# the options_button and set its menu.
self.options_button = create_toolbutton(
self, text=_('Options'), icon=ima.icon('tooloptions'))
actions = self.actions + [MENU_SEPARATOR] + self.plugin_actions
self.options_menu = QMenu(self)
add_actions(self.options_menu, actions)
self.options_button.setMenu(self.options_menu)
if self.tools_layout.itemAt(self.tools_layout.count() - 1) is None:
self.tools_layout.insertWidget(
self.tools_layout.count() - 1, self.options_button)
else:
self.tools_layout.addWidget(self.options_button)
def create_shortcuts(self):
"""Create shortcuts for this widget."""
# Configurable
copyfig = config_shortcut(self.copy_figure, context='plots',
name='copy', parent=self)
prevfig = config_shortcut(self.go_previous_thumbnail, context='plots',
name='previous figure', parent=self)
nextfig = config_shortcut(self.go_next_thumbnail, context='plots',
name='next figure', parent=self)
return [copyfig, prevfig, nextfig]
def get_shortcut_data(self):
"""
Return shortcut data, a list of tuples (shortcut, text, default).
shortcut (QShortcut or QAction instance)
text (string): action/shortcut description
default (string): default key sequence
"""
return [sc.data for sc in self.shortcuts]
def option_changed(self, option, value):
"""Handle when the value of an option has changed"""
setattr(self, to_text_string(option), value)
self.shellwidget.set_namespace_view_settings()
if self.setup_in_progress is False:
示例3: NamespaceBrowser
# 需要导入模块: from qtpy.QtWidgets import QHBoxLayout [as 别名]
# 或者: from qtpy.QtWidgets.QHBoxLayout import count [as 别名]
#.........这里部分代码省略.........
tip=_("Exclude references which name starts with an "
"uppercase character"),
toggled=lambda state:
self.sig_option_changed.emit('exclude_capitalized', state))
self.exclude_capitalized_action.setChecked(exclude_capitalized)
self.exclude_unsupported_action = create_action(self,
_("Exclude unsupported data types"),
tip=_("Exclude references to unsupported data types"
" (i.e. which won't be handled/saved correctly)"),
toggled=lambda state:
self.sig_option_changed.emit('exclude_unsupported', state))
self.exclude_unsupported_action.setChecked(exclude_unsupported)
self.actions = [
self.exclude_private_action, self.exclude_uppercase_action,
self.exclude_capitalized_action, self.exclude_unsupported_action]
if is_module_installed('numpy'):
self.actions.extend([MENU_SEPARATOR, self.editor.minmax_action])
self.setup_in_progress = False
def setup_options_button(self):
"""Add the cog menu button to the toolbar."""
if not self.options_button:
self.options_button = create_toolbutton(
self, text=_('Options'), icon=ima.icon('tooloptions'))
actions = self.actions + [MENU_SEPARATOR] + self.plugin_actions
self.options_menu = QMenu(self)
add_actions(self.options_menu, actions)
self.options_button.setMenu(self.options_menu)
if self.tools_layout.itemAt(self.tools_layout.count() - 1) is None:
self.tools_layout.insertWidget(
self.tools_layout.count() - 1, self.options_button)
else:
self.tools_layout.addWidget(self.options_button)
def option_changed(self, option, value):
"""Option has changed"""
setattr(self, to_text_string(option), value)
self.shellwidget.set_namespace_view_settings()
self.refresh_table()
def get_view_settings(self):
"""Return dict editor view settings"""
settings = {}
for name in REMOTE_SETTINGS:
settings[name] = getattr(self, name)
return settings
def refresh_table(self):
"""Refresh variable table"""
if self.is_visible and self.isVisible():
self.shellwidget.refresh_namespacebrowser()
try:
self.editor.resizeRowToContents()
except TypeError:
pass
def process_remote_view(self, remote_view):
"""Process remote view"""
if remote_view is not None:
self.set_data(remote_view)