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