本文整理汇总了Python中PyQt5.QtWidgets.QTreeWidget类的典型用法代码示例。如果您正苦于以下问题:Python QTreeWidget类的具体用法?Python QTreeWidget怎么用?Python QTreeWidget使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QTreeWidget类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_mid_group
def create_mid_group(self):
self.ddi_tree = QTreeWidget()
self.ddi_tree.itemSelectionChanged.connect(self.show_ddi_details)
ddi_details = QGroupBox()
ddi_details_layout = QGridLayout()
ddi_details_layout.setContentsMargins(0,0,0,0)
ddi_details_layout.addWidget(self.create_common_ddi_details(), 0, 0, 1, 1)
ddi_details_layout.addWidget(self.create_specific_ddi_details(), 1, 0, 3, 1)
ddi_details.setLayout(ddi_details_layout)
self.step_tree = QTreeWidget()
self.step_tree.itemSelectionChanged.connect(self.show_step_details)
step_details = QGroupBox()
step_details_layout = QGridLayout()
step_details_layout.setContentsMargins(0,0,0,0)
step_details_layout.addWidget(self.create_common_step_details(), 0, 0, 1, 1)
# step_details_layout.addWidget(self.create_specific_step_details(), 1, 0, 3, 1)
step_details.setLayout(step_details_layout)
splitter = QSplitter(self)
splitter.addWidget(self.ddi_tree)
splitter.addWidget(ddi_details)
splitter.addWidget(self.step_tree)
splitter.addWidget(step_details)
hbox = QHBoxLayout()
hbox.setContentsMargins(0,0,0,0)
# self.__mix_to_layout(hbox, self.ddi_tree, ddi_details, self.step_tree, step_details)
hbox.addWidget(splitter)
# group_box.setLayout(hbox)
return hbox
示例2: keyPressEvent
def keyPressEvent(self, e):
if e.key() == Qt.Key_Enter or e.key() == Qt.Key_Return:
item = self.currentItem()
col = self.currentColumn()
self.editItem(item, col)
elif e.key() == Qt.Key_Left or e.key() == Qt.Key_Right:
curr_idx = self.currentIndex()
if e.key() == Qt.Key_Left:
if curr_idx.column() > 0:
next_idx = curr_idx.sibling(curr_idx.row(), curr_idx.column()-1)
self.setCurrentIndex(next_idx)
else:
if curr_idx.column() < self.colSELOPT:
next_idx = curr_idx.sibling(curr_idx.row(), curr_idx.column()+1)
self.setCurrentIndex(next_idx)
elif (e.key() == Qt.Key_Up or e.key() == Qt.Key_Down) and e.modifiers() == Qt.ControlModifier:
item = self.currentItem()
idx = self.currentIndex()
if e.key() == Qt.Key_Up:
if item.childCount():
self.collapseItem(item)
else:
if item.parent():
self.collapseItem( item.parent() )
p_idx = idx.parent()
self.setCurrentIndex( p_idx.sibling( p_idx.row(), idx.column() ) )
else:
if item.childCount():
self.expandItem(item)
else:
QTreeWidget.keyPressEvent(self, e)
示例3: __init__
def __init__(self, parent, items):
QTreeWidget.__init__( self )
self.setColumnCount( 2 )
header = QTreeWidgetItem( SubtleTreeWidget.ITEM_ROLE )
header.setText(0, 'File')
header.setText(1, 'Status')
self.setHeaderItem( header )
self.addTopLevelItems( items )
示例4: __init__
def __init__(self, parent=None):
QTreeWidget.__init__(self, parent)
self.singleOverlaySelection = True
self.header().close()
self.setSortingEnabled(True)
self.installEventFilter(self)
self.spacePressed.connect(self.spacePressedTreewidget)
self.itemChanged.connect(self.treeItemChanged)
示例5: keyPressEvent
def keyPressEvent(self, event: QKeyEvent):
if self.window().is_dirty() \
and (event.matches(QKeySequence.MoveToNextLine) or event.matches(QKeySequence.MoveToPreviousLine)):
veto = self.window().central_widget.promptToSave()
if not veto:
QTreeWidget.keyPressEvent(self, event)
else:
event.ignore()
else:
QTreeWidget.keyPressEvent(self, event)
示例6: __init__
def __init__(self):
QTreeWidget.__init__(self)
self.setAnimated(True)
self.setHeaderLabel(self.tr("Folders"))
self.header().setStretchLastSection(False)
self.header().setHidden(True)
self.header().setSectionResizeMode(0, QHeaderView.ResizeToContents)
self.itemClicked.connect(self._open_file)
Amaru.load_component("tree_project", self)
示例7: __init__
def __init__(self, jack_client, parent=None, **kwargs):
super().__init__(parent)
self.resize(600, 400)
self.setLayout(QGridLayout())
# self.layout().setContentsMargins(0, 0, 0, 0)
self.output_widget = QTreeWidget(self)
self.output_widget.setHeaderLabels(['Output ports'])
self.input_widget = QTreeWidget(self)
self.input_widget.setHeaderLabels(['Input ports'])
self.connections_widget = ConnectionsWidget(self.output_widget,
self.input_widget,
parent=self)
self.output_widget.itemExpanded.connect(self.connections_widget.update)
self.output_widget.itemCollapsed.connect(self.connections_widget.update)
self.input_widget.itemExpanded.connect(self.connections_widget.update)
self.input_widget.itemCollapsed.connect(self.connections_widget.update)
self.input_widget.itemSelectionChanged.connect(
self.__input_selection_changed)
self.output_widget.itemSelectionChanged.connect(
self.__output_selection_changed)
self.layout().addWidget(self.output_widget, 0, 0)
self.layout().addWidget(self.connections_widget, 0, 1)
self.layout().addWidget(self.input_widget, 0, 2)
self.layout().setColumnStretch(0, 2)
self.layout().setColumnStretch(1, 1)
self.layout().setColumnStretch(2, 2)
self.connectButton = QPushButton('Connect', self)
self.connectButton.clicked.connect(self.__disconnect_selected)
self.connectButton.setEnabled(False)
self.layout().addWidget(self.connectButton, 1, 1)
self.dialogButtons = QDialogButtonBox(
QDialogButtonBox.Cancel | QDialogButtonBox.Ok)
self.dialogButtons.accepted.connect(self.accept)
self.dialogButtons.rejected.connect(self.reject)
self.layout().addWidget(self.dialogButtons, 2, 0, 1, 3)
self.__jack_client = jack_client
self.__selected_in = None
self.__selected_out = None
self.connections = []
self.update_graph()
示例8: _load_ui
def _load_ui(self):
main_layout = QVBoxLayout(self)
main_layout.addWidget(QLabel(translations.TR_SESSIONS_DIALOG_BODY))
main_hbox = QHBoxLayout()
# Session list
session_layout = QVBoxLayout()
self._session_list = QTreeWidget()
self._session_list.setHeaderLabels(["Session", "Last Modified"])
session_layout.addWidget(self._session_list)
# Content frame
content_frame = QFrame()
content_frame.hide()
frame_layout = QVBoxLayout(content_frame)
content_frame.setFrameStyle(QFrame.StyledPanel | QFrame.Sunken)
session_layout.addWidget(content_frame)
frame_layout.setContentsMargins(0, 0, 0, 0)
self._content_list = QTreeWidget()
self._content_list.setHeaderHidden(True)
frame_layout.addWidget(self._content_list)
# Separator line
line_frame = QFrame()
line_frame.setFrameStyle(QFrame.VLine | QFrame.Sunken)
# Buttons
btn_layout = QVBoxLayout()
btn_create = QPushButton(translations.TR_SESSIONS_BTN_CREATE)
btn_activate = QPushButton(translations.TR_SESSIONS_BTN_ACTIVATE)
btn_update = QPushButton(translations.TR_SESSIONS_BTN_UPDATE)
btn_delete = QPushButton(translations.TR_SESSIONS_BTN_DELETE)
btn_details = QPushButton(translations.TR_SESSIONS_BTN_DETAILS)
btn_details.setCheckable(True)
# Add buttons to layout
btn_layout.addWidget(btn_create)
btn_layout.addWidget(btn_activate)
btn_layout.addWidget(btn_update)
btn_layout.addWidget(btn_delete)
btn_layout.addStretch()
btn_layout.addWidget(btn_details)
# Add widgets and layouts to the main layout
main_layout.addLayout(main_hbox)
main_hbox.addLayout(session_layout)
main_hbox.addWidget(line_frame)
main_hbox.addLayout(btn_layout)
main_hbox.setSizeConstraint(QLayout.SetFixedSize)
btn_details.toggled[bool].connect(content_frame.setVisible)
# Connections
self._session_list.itemSelectionChanged.connect(
self.load_session_content)
btn_activate.clicked.connect(self.open_session)
btn_update.clicked.connect(self.save_session)
btn_create.clicked.connect(self.create_session)
btn_delete.clicked.connect(self.delete_session)
示例9: __init__
def __init__(self, parent=None):
QTreeWidget.__init__(self, parent)
self._model = None
self._catRow = [-1, -1, -1]
self._filter = ""
self._lastID = -1
self._updating = False
self._showSubPlot = False
self.setRootIsDecorated(False)
self.setIndentation(10)
self.setColumnCount(1)
self._rootItem = QTreeWidgetItem()
self.insertTopLevelItem(0, self._rootItem)
示例10: fillTreeWidget
def fillTreeWidget(self, widget : QTreeWidget, tree : Tree):
def helper(t : Tree, parent):
item = QTreeWidgetItem()
item.setText(0, t.name)
item.setIcon(0, QIcon('data/gfx/folder.png'))
if type(parent) == QTreeWidget:
parent.insertTopLevelItem(0, item)
else:
parent.addChild(item)
for ch in t.children:
helper(ch, item)
widget.setColumnCount(1)
helper(tree, widget)
示例11: __init__
def __init__(self, parent=None):
QTreeWidget.__init__(self, parent)
self._model = None
self._catRow = [-1, -1, -1]
self._filter = ""
self._lastID = -1
self._updating = False
self.setRootIsDecorated(False)
self.setIndentation(10)
self.setHeaderHidden(True)
self.setIconSize(QSize(24, 24))
self.setColumnCount(1)
self._rootItem = QTreeWidgetItem()
self.insertTopLevelItem(0, self._rootItem)
示例12: __init__
def __init__(self, show_root=False, scan="Scan", scan_whats_this='', whats_this=''):
""" Initialise the editor. """
super().__init__()
self.package = None
self.project = None
self._show_root = show_root
self._package_edit = QTreeWidget(whatsThis=whats_this)
self._package_edit.header().hide()
self._package_edit.itemChanged.connect(self._package_changed)
self.addWidget(self._package_edit, 0, 0, 3, 1)
self._scan_button = QPushButton(scan, whatsThis=scan_whats_this,
clicked=self._scan, enabled=False)
self.addWidget(self._scan_button, 0, 1)
self._remove_button = QPushButton("Remove all",
whatsThis="Remove all of the scanned directories and files.",
clicked=self._remove_all, enabled=False)
self.addWidget(self._remove_button, 0, 2)
self._include_button = QPushButton("Include all",
whatsThis="Select all of the scanned directories and files.",
clicked=self._include_all, enabled=False)
self.addWidget(self._include_button, 1, 1)
self._exclude_button = QPushButton("Exclude all",
whatsThis="Deselect all of the scanned directories and files.",
clicked=self._exclude_all, enabled=False)
self.addWidget(self._exclude_button, 1, 2)
self._exclusions_edit = QTreeWidget(
whatsThis="Any directory or file that matches any of the "
"these patterns will be automatically ignored when "
"scanning. Double-click on a pattern to edit or remove "
"it. Double-click below the last pattern in order to "
"add a new one.")
self._exclusions_edit.setHeaderLabel("Exclusions")
self._exclusions_edit.setEditTriggers(
QTreeWidget.DoubleClicked|QTreeWidget.SelectedClicked|
QTreeWidget.EditKeyPressed)
self._exclusions_edit.setRootIsDecorated(False)
self._exclusions_edit.itemChanged.connect(self._exclusion_changed)
self.addWidget(self._exclusions_edit, 2, 1, 1, 2)
示例13: createDockWindows
def createDockWindows(self):
dock = QDockWidget("Available Garments Types", self)
#dock.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)
self.availableItems = QListWidget(dock)
self.availableItems.setMinimumWidth(350)
self.availableItems.setMaximumWidth(350)
#self.availableItems.addItems(("stuff"))
self.availableItems.itemClicked.connect(self.itemClicked_Click)
dock.setWidget(self.availableItems)
self.addDockWidget(Qt.RightDockWidgetArea, dock)
self.viewMenu.addAction(dock.toggleViewAction())
dock.hide()
self.dock = QDockWidget("Available Garment Sizes", self)
self.orderItem = QTreeWidget(dock)
#self.orderItem.setMinimumWidth(350)
#self.orderItem.setMaximumWidth(350)
#self.orderItem.insertText(("more stuff"))
self.dock.setWidget(self.orderItem)
self.addDockWidget(Qt.RightDockWidgetArea, self.dock)
self.viewMenu.addAction(self.dock.toggleViewAction())
self.dock.hide()
#Create a tree widget for use when the t-shirt is clicked.
self.treeDock = QDockWidget("Order Items", self)
self.garmentTree = QTreeWidget(self.treeDock)
self.garmentTree.setObjectName('garmentTree')
self.garmentTree.itemClicked.connect(CSRWidgets.sumQuantity)
self.garmentTree.itemClicked.connect(lambda: CSRWidgets.updateNameDesign(self))
self.garmentTree.setMaximumWidth(480)
self.garmentTree.setMinimumWidth(480)
self.treeDock.hide()
示例14: __init__
def __init__(self, pathProjects, parent=None):
#pathProjects must be a list
super(AddToProject, self).__init__(parent)
self.setWindowTitle(_translate("AddToProject", "Add File to Project"))
self.pathSelected = ''
vbox = QVBoxLayout(self)
self._tree = QTreeWidget()
self._tree.header().setHidden(True)
self._tree.setSelectionMode(QTreeWidget.SingleSelection)
self._tree.setAnimated(True)
vbox.addWidget(self._tree)
hbox = QHBoxLayout()
btnAdd = QPushButton(_translate("AddToProject", "Add here!"))
btnCancel = QPushButton(_translate("AddToProject", "Cancel"))
hbox.addWidget(btnCancel)
hbox.addWidget(btnAdd)
vbox.addLayout(hbox)
#load folders
self._root = None
self._loading_items = {}
self.loading_projects(pathProjects)
self._thread_execution = ThreadExecution(
self._thread_load_projects, args=[pathProjects])
self._thread_execution.finished.connect(self._callback_load_project)
self._thread_execution.start()
btnCancel.clicked['bool'].connect(self.close)
btnAdd.clicked['bool'].connect(self._select_path)
示例15: dropEvent
def dropEvent(self, event: QDropEvent):
"""custom drop event to prevent reparenting
"""
# data = event.mimeData()
# if data.hasFormat('application/x-qabstractitemmodeldatalist'):
# the_bytearray = data.data('application/x-qabstractitemmodeldatalist')
# data_item = self.decodeMimeData(the_bytearray)
# print("got a drop event", data_item)
# item Drop above
pos = event.pos()
dest_item = self.itemAt(pos)
if dest_item is None:
return
dest_parent = dest_item.parent()
selected_items = self.selectedItems()
for x in selected_items:
if x.parent() != dest_parent:
return
res = QTreeWidget.dropEvent(self, event)
if isinstance(dest_item, OutlineVirtualHelixItem):
part = dest_item.part()
vhi_list = [dest_parent.child(i) for i in range(dest_parent.childCount())]
part.setImportedVHelixOrder([vhi.idNum() for vhi in vhi_list], check_batch=False)