热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

python怎么创建文件浏览窗体_python–如何在主窗口内的pyqt中创建文件夹视图

使用模型和视图.AnexampleofhowtousemodelsandviewsinPyQt4.Modelviewdocumentationcanbefoundathttp

使用模型和视图.

"""An example of how to use models and views in PyQt4.

Model/view documentation can be found at

http://doc.qt.nokia.com/latest/model-view-programming.html.

"""

import sys

from PyQt4.QtGui import (QApplication, QColumnView, QFileSystemModel,

QSplitter, QTreeView)

from PyQt4.QtCore import QDir, Qt

if __name__ == '__main__':

app = QApplication(sys.argv)

# Splitter to show 2 views in same widget easily.

splitter = QSplitter()

# The model.

model = QFileSystemModel()

# You can setRootPath to any path.

model.setRootPath(QDir.rootPath())

# List of views.

views = []

for ViewType in (QColumnView, QTreeView):

# Create the view in the splitter.

view = ViewType(splitter)

# Set the model of the view.

view.setModel(model)

# Set the root index of the view as the user's home directory.

view.setRootIndex(model.index(QDir.homePath()))

# Show the splitter.

splitter.show()

# Maximize the splitter.

splitter.setWindowState(Qt.WindowMaximized)

# Start the main loop.

sys.exit(app.exec_())



推荐阅读
author-avatar
干杯13ds_198
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有