当前位置: 首页>>代码示例>>Python>>正文


Python QtWidgets.QTreeView方法代码示例

本文整理汇总了Python中PySide2.QtWidgets.QTreeView方法的典型用法代码示例。如果您正苦于以下问题:Python QtWidgets.QTreeView方法的具体用法?Python QtWidgets.QTreeView怎么用?Python QtWidgets.QTreeView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PySide2.QtWidgets的用法示例。


在下文中一共展示了QtWidgets.QTreeView方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: folderPathDialog

# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QTreeView [as 别名]
def folderPathDialog(self):
        """
        updates folder_path label when called from pyside native button

        link to explanation on how to enable multiple directories selection:
            https://stackoverflow.com/questions/38252419/qt-get-qfiledialog-to-select-and-return-multiple-folders
        """
        if self.folder_path.text() == "":
            default_path = os.getenv("HOME")
        else:
            default_path = self.folder_path.text().split(self.paths_separator)[0]
        
        dialog = QtWidgets.QFileDialog(self, "Select a folder with textures for conversion:", default_path)
        dialog.setFileMode(QtWidgets.QFileDialog.Directory)

        # don't use native dialog, enable multiple dir selection
        dialog.setOption(QtWidgets.QFileDialog.DontUseNativeDialog, True)
        file_view = dialog.findChild(QtWidgets.QListView, 'listView')
        f_tree_view = dialog.findChild(QtWidgets.QTreeView)

        if file_view:
            file_view.setSelectionMode(QtWidgets.QAbstractItemView.MultiSelection)
        if f_tree_view:
            f_tree_view.setSelectionMode(QtWidgets.QAbstractItemView.MultiSelection)

        # exec dialog
        if dialog.exec_() == QtWidgets.QDialog.Accepted:
            path = str( self.paths_separator.join( dialog.selectedFiles() ) )
            self.folder_path.setText(path) 
开发者ID:jtomori,项目名称:batch_textures_convert,代码行数:31,代码来源:gui.py

示例2: setupUi

# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QTreeView [as 别名]
def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.setWindowModality(QtCore.Qt.ApplicationModal)
        Dialog.resize(1304, 753)
        self.verticalLayout = QtWidgets.QVBoxLayout(Dialog)
        self.verticalLayout.setObjectName("verticalLayout")
        self.label = QtWidgets.QLabel(Dialog)
        self.label.setObjectName("label")
        self.verticalLayout.addWidget(self.label)
        self.versions_treeView = QtWidgets.QTreeView(Dialog)
        self.versions_treeView.setObjectName("versions_treeView")
        self.verticalLayout.addWidget(self.versions_treeView)
        self.horizontalWidget = QtWidgets.QWidget(Dialog)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.horizontalWidget.sizePolicy().hasHeightForWidth())
        self.horizontalWidget.setSizePolicy(sizePolicy)
        self.horizontalWidget.setObjectName("horizontalWidget")
        self.horizontalLayout = QtWidgets.QHBoxLayout(self.horizontalWidget)
        self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
        self.horizontalLayout.setObjectName("horizontalLayout")
        spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem)
        self.selectNone_pushButton = QtWidgets.QPushButton(self.horizontalWidget)
        self.selectNone_pushButton.setObjectName("selectNone_pushButton")
        self.horizontalLayout.addWidget(self.selectNone_pushButton)
        self.selectAll_pushButton = QtWidgets.QPushButton(self.horizontalWidget)
        self.selectAll_pushButton.setObjectName("selectAll_pushButton")
        self.horizontalLayout.addWidget(self.selectAll_pushButton)
        self.update_pushButton = QtWidgets.QPushButton(self.horizontalWidget)
        self.update_pushButton.setObjectName("update_pushButton")
        self.horizontalLayout.addWidget(self.update_pushButton)
        self.cancel_pushButton = QtWidgets.QPushButton(self.horizontalWidget)
        self.cancel_pushButton.setObjectName("cancel_pushButton")
        self.horizontalLayout.addWidget(self.cancel_pushButton)
        self.verticalLayout.addWidget(self.horizontalWidget)

        self.retranslateUi(Dialog)
        QtCore.QMetaObject.connectSlotsByName(Dialog) 
开发者ID:eoyilmaz,项目名称:anima,代码行数:42,代码来源:version_updater_UI_pyside2.py

示例3: itemFileSystem

# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QTreeView [as 别名]
def itemFileSystem(self):

        self.item_fs = QtWidgets.QWidget()
        layout = QtWidgets.QVBoxLayout()
        self.item_fs.setLayout(layout)

        # instance of QFileSystemModel
        filesystem_model = FileSystem.FileSystemModel()
        root_path = filesystem_model.rootPath()

        self.tree = QtWidgets.QTreeView()
        self.tree.setModel(filesystem_model)
        self.tree.setRootIndex(filesystem_model.index(root_path))
        self.tree.setAnimated(True)

        # hide size column
        self.tree.setColumnHidden(1, True)
        # hide type column
        self.tree.setColumnHidden(2, True)
        # hide date modified column
        self.tree.setColumnHidden(3, True)

        # hide the header line of the filesystem tree
        # the header line would consist of name, date, type, size
        # the latter three are hidden anyway (see above)
        header = self.tree.header()
        header.hide()

        # handler
        self.tree.clicked.connect(filesystem_model.onFileSelected)
        self.tree.doubleClicked.connect(filesystem_model.onFileLoad)

        layout.addWidget(self.tree, stretch=12)
        # layout.setAlignment(QtCore.Qt.AlignTop)

        self.header = QtWidgets.QLabel('Loaded airfoil(s)')
        self.header.setEnabled(False)
        layout.addStretch(stretch=2)
        layout.addWidget(self.header)

        self.listwidget = ListWidget(self.parent)
        self.listwidget.setEnabled(False)
        # allow only single selections
        self.listwidget.setSelectionMode(QtWidgets.QAbstractItemView.
                                         SingleSelection)
        layout.addWidget(self.listwidget, stretch=5)
        layout.addStretch(stretch=1) 
开发者ID:chiefenne,项目名称:PyAero,代码行数:49,代码来源:ToolBox.py

示例4: setupUi

# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QTreeView [as 别名]
def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.resize(941, 590)
        self.verticalLayout = QtWidgets.QVBoxLayout(Dialog)
        self.verticalLayout.setContentsMargins(1, 1, 1, 1)
        self.verticalLayout.setObjectName("verticalLayout")
        self.frame = QtWidgets.QFrame(Dialog)
        self.frame.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.frame.setFrameShadow(QtWidgets.QFrame.Raised)
        self.frame.setObjectName("frame")
        self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.frame)
        self.verticalLayout_2.setContentsMargins(-1, -1, -1, 0)
        self.verticalLayout_2.setObjectName("verticalLayout_2")
        self.treeView = QtWidgets.QTreeView(self.frame)
        self.treeView.setAlternatingRowColors(True)
        self.treeView.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
        self.treeView.setAnimated(True)
        self.treeView.setObjectName("treeView")
        self.verticalLayout_2.addWidget(self.treeView)
        self.verticalLayout.addWidget(self.frame)
        self.frame_2 = QtWidgets.QFrame(Dialog)
        self.frame_2.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.frame_2.setFrameShadow(QtWidgets.QFrame.Raised)
        self.frame_2.setObjectName("frame_2")
        self.horizontalLayout = QtWidgets.QHBoxLayout(self.frame_2)
        self.horizontalLayout.setContentsMargins(-1, 0, -1, -1)
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.accept_selected_pushButton = QtWidgets.QPushButton(self.frame_2)
        self.accept_selected_pushButton.setText("")
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(":/Icons/icons/accept.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.accept_selected_pushButton.setIcon(icon)
        self.accept_selected_pushButton.setObjectName("accept_selected_pushButton")
        self.horizontalLayout.addWidget(self.accept_selected_pushButton)
        self.reject_selected_pushButton = QtWidgets.QPushButton(self.frame_2)
        self.reject_selected_pushButton.setText("")
        icon1 = QtGui.QIcon()
        icon1.addPixmap(QtGui.QPixmap(":/Icons/icons/delete.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.reject_selected_pushButton.setIcon(icon1)
        self.reject_selected_pushButton.setObjectName("reject_selected_pushButton")
        self.horizontalLayout.addWidget(self.reject_selected_pushButton)
        spacerItem = QtWidgets.QSpacerItem(632, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem)
        self.doit_pushButton = QtWidgets.QPushButton(self.frame_2)
        icon2 = QtGui.QIcon()
        icon2.addPixmap(QtGui.QPixmap(":/Icons/icons/accept2.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.doit_pushButton.setIcon(icon2)
        self.doit_pushButton.setObjectName("doit_pushButton")
        self.horizontalLayout.addWidget(self.doit_pushButton)
        self.verticalLayout.addWidget(self.frame_2)

        self.retranslateUi(Dialog)
        QtCore.QMetaObject.connectSlotsByName(Dialog) 
开发者ID:SanPen,项目名称:GridCal,代码行数:55,代码来源:gui.py


注:本文中的PySide2.QtWidgets.QTreeView方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。