本文整理汇总了Python中PyQt5.QtWidgets.QFileSystemModel.index方法的典型用法代码示例。如果您正苦于以下问题:Python QFileSystemModel.index方法的具体用法?Python QFileSystemModel.index怎么用?Python QFileSystemModel.index使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QFileSystemModel
的用法示例。
在下文中一共展示了QFileSystemModel.index方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_file_tree
# 需要导入模块: from PyQt5.QtWidgets import QFileSystemModel [as 别名]
# 或者: from PyQt5.QtWidgets.QFileSystemModel import index [as 别名]
def update_file_tree(self):
model = QFileSystemModel()
model.setRootPath(self._root_dir)
self.localFilesTreeView.setModel(model)
local_selection_model = self.localFilesTreeView.selectionModel()
local_selection_model.selectionChanged.connect(self.local_file_selection_changed)
self.localFilesTreeView.setRootIndex(model.index(self._root_dir))
示例2: FileChooser
# 需要导入模块: from PyQt5.QtWidgets import QFileSystemModel [as 别名]
# 或者: from PyQt5.QtWidgets.QFileSystemModel import index [as 别名]
class FileChooser(QWidget):
fileOpened = pyqtSignal(str)
def __init__(self, parent=None):
super().__init__(parent)
self.folderBox = QComboBox(self)
self.explorerTree = FileTreeView(self)
self.explorerTree.doubleClickCallback = self._fileOpened
self.explorerModel = QFileSystemModel(self)
self.explorerModel.setFilter(
QDir.AllDirs | QDir.Files | QDir.NoDotAndDotDot)
self.explorerModel.setNameFilters(["*.py"])
self.explorerModel.setNameFilterDisables(False)
self.explorerTree.setModel(self.explorerModel)
for index in range(1, self.explorerModel.columnCount()):
self.explorerTree.hideColumn(index)
self.setCurrentFolder()
self.folderBox.currentIndexChanged[int].connect(
self.updateCurrentFolder)
layout = QVBoxLayout(self)
layout.addWidget(self.folderBox)
layout.addWidget(self.explorerTree)
layout.setContentsMargins(5, 5, 0, 0)
def _fileOpened(self, modelIndex):
path = self.explorerModel.filePath(modelIndex)
if os.path.isfile(path):
self.fileOpened.emit(path)
def currentFolder(self):
return self.explorerModel.rootPath()
def setCurrentFolder(self, path=None):
if path is None:
app = QApplication.instance()
path = app.getScriptsDirectory()
else:
assert os.path.isdir(path)
self.explorerModel.setRootPath(path)
self.explorerTree.setRootIndex(self.explorerModel.index(path))
self.folderBox.blockSignals(True)
self.folderBox.clear()
style = self.style()
dirIcon = style.standardIcon(style.SP_DirIcon)
self.folderBox.addItem(dirIcon, os.path.basename(path))
self.folderBox.insertSeparator(1)
self.folderBox.addItem(self.tr("Browse…"))
self.folderBox.setCurrentIndex(0)
self.folderBox.blockSignals(False)
def updateCurrentFolder(self, index):
if index < self.folderBox.count() - 1:
return
path = QFileDialog.getExistingDirectory(
self, self.tr("Choose Directory"), self.currentFolder(),
QFileDialog.ShowDirsOnly)
if path:
QSettings().setValue("scripting/path", path)
self.setCurrentFolder(path)
示例3: createDockWindows
# 需要导入模块: from PyQt5.QtWidgets import QFileSystemModel [as 别名]
# 或者: from PyQt5.QtWidgets.QFileSystemModel import index [as 别名]
def createDockWindows(self):
dock = QDockWidget("Folders", self)
dock.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)
#Code to Create FileView Colums and FolderTree
self.FileView = QtWidgets.QColumnView()
self.FileView.setGeometry(QtCore.QRect(240, 10, 291, 281))
self.FolderTree = QtWidgets.QTreeView()
self.FolderTree.setGeometry(QtCore.QRect(10, 10, 221, 281))
FolderTree = self.FolderTree
#FolderTree.hidecolumn(1),... ?? to show only name column
#include FolderTree to a Dock at the left side
dock.setWidget(FolderTree)
self.addDockWidget(Qt.LeftDockWidgetArea, dock)
#set the model and rootpath for filling the FolderTree from self.ui
dirmodel = QFileSystemModel()
#set filter to show only folders
dirmodel.setFilter(QDir.NoDotAndDotDot | QDir.AllDirs)
dirmodel.setRootPath(rootpath)
#filemodel and filter for only files on right side
filemodel = QFileSystemModel()
filemodel.setFilter(QDir.NoDotAndDotDot | QDir.Files)
filemodel.setRootPath(rootpath)
FolderView = self.FolderTree
FolderView.setModel(dirmodel)
FolderView.setRootIndex(dirmodel.index(rootpath))
FileView = self.FileView
FileView.setModel(filemodel)
dock = QDockWidget("Files", self)
dock.setWidget(FileView)
self.addDockWidget(Qt.RightDockWidgetArea, dock)
#important lines for the connection, which does not work
self.FolderTree.clicked['QModelIndex'].connect(self.setpathonclick)
示例4: LocalPathView
# 需要导入模块: from PyQt5.QtWidgets import QFileSystemModel [as 别名]
# 或者: from PyQt5.QtWidgets.QFileSystemModel import index [as 别名]
class LocalPathView(QTreeView):
def __init__ (self):
super(LocalPathView, self).__init__()
self._model = QFileSystemModel()
self._model.setFilter(QDir.Dirs | QDir.Drives | QDir.NoDotAndDotDot | QDir.AllDirs)
self._model.setRootPath('')
self.setModel(self._model )
self.hideColumn(1); # removing Size Column
self.hideColumn(2); # removing Type Column
self.setAnimated(False)
self.setSortingEnabled(True)
self.header().setSortIndicator(0, Qt.AscendingOrder)
width = self.size().width() >> 1
self.setColumnWidth(0, width*0.7)
self.setColumnWidth(1, width*0.3)
index = self._model.index(QDir.currentPath())
self.selectionModel().setCurrentIndex(index, QItemSelectionModel.Select | QItemSelectionModel.Rows)
self.expand(index)
self.scrollTo(index)
@property
def selectedDir(self):
return self._model.filePath(self.selectionModel().selectedIndexes()[0])
示例5: AssetBrowser
# 需要导入模块: from PyQt5.QtWidgets import QFileSystemModel [as 别名]
# 或者: from PyQt5.QtWidgets.QFileSystemModel import index [as 别名]
class AssetBrowser(QMainWindow, Ui_MainWindow):
asset_clicked = pyqtSignal(str, str, name='assetClicked')
def __init__(self):
super(AssetBrowser, self).__init__()
self.setupUi(self)
self.dir_model = QFileSystemModel()
self.dir_model.setFilter(QDir.NoDotAndDotDot | QDir.AllDirs)
self.dir_model.setReadOnly(False)
self.dir_view.setModel(self.dir_model)
self.dir_view.hideColumn(1)
self.dir_view.hideColumn(2)
self.dir_view.hideColumn(3)
self.file_model = QFileSystemModel()
self.file_model.setFilter(QDir.NoDotAndDotDot | QDir.Files)
self.file_model.setReadOnly(False)
self.file_view.setModel(self.file_model)
def open_project(self, project_dir):
path = os.path.join(project_dir)
self.dir_model.setRootPath(path)
self.file_model.setRootPath(path)
self.dir_view.setRootIndex(self.dir_model.index(path))
self.file_view.setRootIndex(self.file_model.index(path))
def dir_clicked(self, idx):
path = self.dir_model.fileInfo(idx).absoluteFilePath()
self.file_view.setRootIndex(self.file_model.setRootPath(path))
def file_doubleclicked(self, idx):
fileinfo = self.file_model.fileInfo(idx)
path = fileinfo.absoluteFilePath()
ext = fileinfo.suffix()
self.asset_clicked.emit(path, ext)
示例6: initRootDir
# 需要导入模块: from PyQt5.QtWidgets import QFileSystemModel [as 别名]
# 或者: from PyQt5.QtWidgets.QFileSystemModel import index [as 别名]
def initRootDir(self,indexDir):
if not indexDir:
return
self.indexDir = indexDir
model = QFileSystemModel()
model.setRootPath('')
self.setModel(model)
self.setAnimated(False)
self.setIndentation(20)
self.setSortingEnabled(True)
self.setRootIndex(model.index(self.indexDir))
for i in range(1,model.columnCount()):
self.hideColumn(i)
示例7: load_dir
# 需要导入模块: from PyQt5.QtWidgets import QFileSystemModel [as 别名]
# 或者: from PyQt5.QtWidgets.QFileSystemModel import index [as 别名]
def load_dir(self, dir_path):
if dir_path == self.dir_path:
return
self.dir_path = dir_path
model = QFileSystemModel()
model.setRootPath(dir_path)
self.setModel(model)
index_root = model.index(model.rootPath())
self.setRootIndex(index_root)
# hide unwanted info
self.hideColumn(1)
self.hideColumn(2)
self.hideColumn(3)
self.setHeaderHidden(True)
示例8: load_tree
# 需要导入模块: from PyQt5.QtWidgets import QFileSystemModel [as 别名]
# 或者: from PyQt5.QtWidgets.QFileSystemModel import index [as 别名]
def load_tree(self, project):
"""Load the tree view on the right based on the project selected."""
qfsm = QFileSystemModel()
qfsm.setRootPath(project.path)
load_index = qfsm.index(qfsm.rootPath())
qfsm.setFilter(QDir.AllDirs | QDir.NoDotAndDotDot)
qfsm.setNameFilterDisables(False)
pext = ["*{0}".format(x) for x in project.extensions]
qfsm.setNameFilters(pext)
self._tree.setModel(qfsm)
self._tree.setRootIndex(load_index)
t_header = self._tree.header()
t_header.setHorizontalScrollMode(QAbstractItemView.ScrollPerPixel)
t_header.setSectionResizeMode(0, QHeaderView.Stretch)
t_header.setStretchLastSection(False)
t_header.setClickable(True)
self._tree.hideColumn(1) # Size
self._tree.hideColumn(2) # Type
self._tree.hideColumn(3) # Modification date
示例9: FilenamePrompt
# 需要导入模块: from PyQt5.QtWidgets import QFileSystemModel [as 别名]
# 或者: from PyQt5.QtWidgets.QFileSystemModel import index [as 别名]
class FilenamePrompt(_BasePrompt):
"""A prompt for a filename."""
def __init__(self, question, parent=None):
super().__init__(question, parent)
self._init_texts(question)
self._init_fileview()
self._set_fileview_root(question.default)
self._lineedit = LineEdit(self)
if question.default:
self._lineedit.setText(question.default)
self._lineedit.textEdited.connect(self._set_fileview_root)
self._vbox.addWidget(self._lineedit)
self.setFocusProxy(self._lineedit)
self._init_key_label()
if config.get('ui', 'prompt-filebrowser'):
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
@pyqtSlot(str)
def _set_fileview_root(self, path, *, tabbed=False):
"""Set the root path for the file display."""
separators = os.sep
if os.altsep is not None:
separators += os.altsep
dirname = os.path.dirname(path)
try:
if not path:
pass
elif path in separators and os.path.isdir(path):
# Input "/" -> don't strip anything
pass
elif path[-1] in separators and os.path.isdir(path):
# Input like /foo/bar/ -> show /foo/bar/ contents
path = path.rstrip(separators)
elif os.path.isdir(dirname) and not tabbed:
# Input like /foo/ba -> show /foo contents
path = dirname
else:
return
except OSError:
log.prompt.exception("Failed to get directory information")
return
root = self._file_model.setRootPath(path)
self._file_view.setRootIndex(root)
@pyqtSlot(QModelIndex)
def _insert_path(self, index, *, clicked=True):
"""Handle an element selection.
Args:
index: The QModelIndex of the selected element.
clicked: Whether the element was clicked.
"""
path = os.path.normpath(self._file_model.filePath(index))
if clicked:
path += os.sep
else:
# On Windows, when we have C:\foo and tab over .., we get C:\
path = path.rstrip(os.sep)
log.prompt.debug('Inserting path {}'.format(path))
self._lineedit.setText(path)
self._lineedit.setFocus()
self._set_fileview_root(path, tabbed=True)
if clicked:
# Avoid having a ..-subtree highlighted
self._file_view.setCurrentIndex(QModelIndex())
def _init_fileview(self):
self._file_view = QTreeView(self)
self._file_model = QFileSystemModel(self)
self._file_view.setModel(self._file_model)
self._file_view.clicked.connect(self._insert_path)
if config.get('ui', 'prompt-filebrowser'):
self._vbox.addWidget(self._file_view)
else:
self._file_view.hide()
# Only show name
self._file_view.setHeaderHidden(True)
for col in range(1, 4):
self._file_view.setColumnHidden(col, True)
# Nothing selected initially
self._file_view.setCurrentIndex(QModelIndex())
# The model needs to be sorted so we get the correct first/last index
self._file_model.directoryLoaded.connect(
lambda: self._file_model.sort(0))
def accept(self, value=None):
text = value if value is not None else self._lineedit.text()
text = downloads.transform_path(text)
if text is None:
#.........这里部分代码省略.........
示例10: AssetBrowser
# 需要导入模块: from PyQt5.QtWidgets import QFileSystemModel [as 别名]
# 或者: from PyQt5.QtWidgets.QFileSystemModel import index [as 别名]
class AssetBrowser(QMainWindow, Ui_MainWindow, PlaygroundModule):
Name = "asset_browser"
def __init__(self, module_manager):
super(AssetBrowser, self).__init__()
self.setupUi(self)
self.init_module(module_manager)
self.dir_model = QFileSystemModel()
self.dir_model.setFilter(QDir.NoDotAndDotDot | QDir.AllDirs)
self.dir_model.setReadOnly(False)
self.dir_view.setModel(self.dir_model)
self.dir_view.hideColumn(1)
self.dir_view.hideColumn(2)
self.dir_view.hideColumn(3)
self.file_model = QFileSystemModel()
self.file_model.setFilter(QDir.NoDotAndDotDot | QDir.Files)
self.file_model.setReadOnly(False)
self.file_view.setModel(self.file_model)
self.dock = self.modules_manager.new_docked(self, self.Name, "Asset browser",
Qt.BottomDockWidgetArea)
self.modules_manager.main_window.splitDockWidget(self.dock,
self.modules_manager["asset_view"].dock, Qt.Horizontal)
def on_open_project(self, project):
project_dir = project.project_dir
path = os.path.join(project_dir)
self.dir_model.setRootPath(path)
self.file_model.setRootPath(path)
self.dir_view.setRootIndex(self.dir_model.index(path))
self.file_view.setRootIndex(self.file_model.index(path))
def dir_clicked(self, idx):
path = self.dir_model.fileInfo(idx).absoluteFilePath()
self.file_view.setRootIndex(self.file_model.setRootPath(path))
def file_doubleclicked(self, idx):
fileinfo = self.file_model.fileInfo(idx)
path = fileinfo.absoluteFilePath()
ext = fileinfo.suffix()
asset_name = path.replace(self.project_manager.project_dir, '').replace('/src/', '').split('.')[0]
self.modules_manager.open_asset(path, asset_name, ext)
def file_clicked(self, idx):
fileinfo = self.file_model.fileInfo(idx)
path = fileinfo.absoluteFilePath()
ext = fileinfo.suffix()
asset_name = path.replace(self.project_manager.project_dir, '').replace('/src/', '').split('.')[0]
self.modules_manager.show_asset(path, asset_name, ext)
示例11: QFileSystemModel
# 需要导入模块: from PyQt5.QtWidgets import QFileSystemModel [as 别名]
# 或者: from PyQt5.QtWidgets.QFileSystemModel import index [as 别名]
parser.addPositionalArgument('directory', "The directory to start in.")
parser.process(app)
try:
rootPath = parser.positionalArguments().pop(0)
except IndexError:
rootPath = None
model = QFileSystemModel()
model.setRootPath('')
if parser.isSet(dontUseCustomDirectoryIconsOption):
model.iconProvider().setOptions(
QFileIconProvider.DontUseCustomDirectoryIcons)
tree = QTreeView()
tree.setModel(model)
if rootPath is not None:
rootIndex = model.index(QDir.cleanPath(rootPath))
if rootIndex.isValid():
tree.setRootIndex(rootIndex)
# Demonstrating look and feel features.
tree.setAnimated(False)
tree.setIndentation(20)
tree.setSortingEnabled(True)
availableSize = QApplication.desktop().availableGeometry(tree).size()
tree.resize(availableSize / 2)
tree.setColumnWidth(0, tree.width() / 3)
tree.setWindowTitle("Dir View")
tree.show()
示例12: load_project_structure2
# 需要导入模块: from PyQt5.QtWidgets import QFileSystemModel [as 别名]
# 或者: from PyQt5.QtWidgets.QFileSystemModel import index [as 别名]
def load_project_structure2(self):
model = QFileSystemModel()
model.setRootPath(My_Sync.path2)
self.treeView_2.setModel(model)
self.treeView_2.setRootIndex(model.index(My_Sync.path2))
self.treeView_2.show()
示例13: Explorer
# 需要导入模块: from PyQt5.QtWidgets import QFileSystemModel [as 别名]
# 或者: from PyQt5.QtWidgets.QFileSystemModel import index [as 别名]
class Explorer(QDialog):
def __init__(
self, parent, window_title=_("Select resources"), subtitle=_("Select files and/or folders to include")
):
super().__init__(parent)
self.logger = logging.getLogger(__name__)
self.setModal(True)
self.setSizeGripEnabled(True)
self.setWindowTitle(window_title)
self.subtitle = subtitle
self.file_set = set()
self.config = Configuration()
self.__init_ui__()
self.filename_filter = FilenameFilter()
# self.show()
def __init_ui__(self):
# layout
vert = QVBoxLayout(self)
vert.setContentsMargins(0, 0, 0, 0)
resource_dir = self.config.cfg_resource_dir()
p_top = QVBoxLayout()
lb_subtitle = QLabel(self.subtitle)
lb_subtitle.setContentsMargins(10, 10, 10, 0)
p_top.addWidget(lb_subtitle)
self.model = QFileSystemModel()
self.model.setRootPath(resource_dir)
self.view = QTreeView()
self.view.setModel(self.model)
self.view.setRootIndex(self.model.index(self.model.rootPath()))
self.view.setAlternatingRowColors(True)
self.view.setSelectionMode(QAbstractItemView.MultiSelection)
self.view.selectionModel().selectionChanged.connect(self.selection_changed)
self.view.collapsed.connect(self.item_collapsed)
self.view.expanded.connect(self.item_expanded)
p_top.addWidget(self.view)
p_info = QHBoxLayout()
lb_resource = QLabel(_("resource dir") + ": " + resource_dir)
lb_resource.setContentsMargins(10, 0, 10, 0)
self.lb_selection_count = QLabel(str(self.selected_file_count()) + " " + _("resources selected"))
self.lb_selection_count.setContentsMargins(10, 0, 10, 0)
p_info.addWidget(self.lb_selection_count)
p_info.addStretch(1)
p_info.addWidget(lb_resource)
p_top.addLayout(p_info)
p_bottom = QHBoxLayout()
self.pb_deselect = QPushButton(_("Deselect all"))
self.pb_deselect.clicked.connect(self.pb_deselect_clicked)
self.pb_deselect.setEnabled(self.selected_file_count() > 0)
p_bottom.addWidget(self.pb_deselect)
p_bottom.addStretch(1)
self.pb_ok = QPushButton(_("OK"))
self.pb_ok.setAutoDefault(True)
self.pb_ok.clicked.connect(self.accept)
p_bottom.addWidget(self.pb_ok)
pb_cancel = QPushButton(_("Cancel"))
pb_cancel.clicked.connect(self.reject)
p_bottom.addWidget(pb_cancel)
vert.addLayout(p_top)
vert.addLayout(p_bottom)
self.setLayout(vert)
self.resize(self.config.explorer_width(), self.config.explorer_height())
width = self.view.width() - 50
self.view.setColumnWidth(0, width / 2)
self.view.setColumnWidth(1, width / 6)
self.view.setColumnWidth(2, width / 6)
self.view.setColumnWidth(3, width / 6)
def __persist__(self):
# persist properties of the explorer
self.config.set_explorer_width(self.width())
self.config.set_explorer_height(self.height())
self.config.persist()
def __compute_filenames__(self, item_selection):
# item_selection: a QItemSelection
# return corresponding absolute filenames as a set, including filenames in underlying folders
s = set()
for index in item_selection.indexes():
# we have an index for each column in the model
if index.column() == 0:
path = index.model().filePath(index)
if os.path.isdir(path):
for root, directories, filenames in os.walk(path):
for filename in filenames:
if self.filename_filter.accept(filename):
#.........这里部分代码省略.........
示例14: AbstractPathCompleter
# 需要导入模块: from PyQt5.QtWidgets import QFileSystemModel [as 别名]
# 或者: from PyQt5.QtWidgets.QFileSystemModel import index [as 别名]
class AbstractPathCompleter(AbstractCompleter):
"""Base class for PathCompleter and GlobCompleter
"""
mustBeLoaded = True
# global object. Reused by all completers
_fsModel = QFileSystemModel()
_ERROR = 'error'
_HEADER = 'currentDir'
_STATUS = 'status'
_DIRECTORY = 'directory'
_FILE = 'file'
def __init__(self, text):
self._originalText = text
self._dirs = []
self._files = []
self._error = None
self._status = None
"""hlamer: my first approach is making self._model static member of class. But, sometimes it
returns incorrect icons. I really can't understand when and why.
When it is private member of instance, it seems it works
"""
self._model = None # can't construct in the construtor, must be constructed in GUI thread
@staticmethod
def _filterHidden(paths):
"""Remove hidden and ignored files from the list
"""
return [path for path in paths
if not os.path.basename(path).startswith('.') and
not core.fileFilter().regExp().match(path)]
def _classifyRowIndex(self, row):
"""Get list item type and index by it's row
"""
if self._error:
assert row == 0
return (self._ERROR, 0)
if row == 0:
return (self._HEADER, 0)
row -= 1
if self._status:
if row == 0:
return (self._STATUS, 0)
row -= 1
if row in range(len(self._dirs)):
return (self._DIRECTORY, row)
row -= len(self._dirs)
if row in range(len(self._files)):
return (self._FILE, row)
assert False
def _formatHeader(self, text):
"""Format current directory for show it in the list of completions
"""
return '<font style="background-color: %s; color: %s">%s</font>' % \
(QApplication.instance().palette().color(QPalette.Window).name(),
QApplication.instance().palette().color(QPalette.WindowText).name(),
htmlEscape(text))
def rowCount(self):
"""Row count in the list of completions
"""
if self._error:
return 1
else:
count = 1 # current directory
if self._status:
count += 1
count += len(self._dirs)
count += len(self._files)
return count
def _iconForPath(self, path):
"""Get icon for file or directory path. Uses QFileSystemModel
"""
if self._model is None:
self._model = QFileSystemModel()
index = self._model.index(path)
return self._model.data(index, Qt.DecorationRole)
def text(self, row, column):
"""Item text in the list of completions
"""
rowType, index = self._classifyRowIndex(row)
if rowType == self._ERROR:
return '<font color=red>%s</font>' % htmlEscape(self._error)
elif rowType == self._HEADER:
return self._formatHeader(self._headerText())
#.........这里部分代码省略.........
示例15: Ui_MainWindow
# 需要导入模块: from PyQt5.QtWidgets import QFileSystemModel [as 别名]
# 或者: from PyQt5.QtWidgets.QFileSystemModel import index [as 别名]
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(680, 482)
self.centralWidget = QtWidgets.QWidget(MainWindow)
self.centralWidget.setObjectName("centralWidget")
self.frame = E(self.centralWidget)
self.frame.setGeometry(QtCore.QRect(9, 9, 431, 411))
self.frame.setFrameShape(QtWidgets.QFrame.StyledPanel)
self.frame.setFrameShadow(QtWidgets.QFrame.Raised)
self.frame.setObjectName("frame")
self.c = Communicate()
self.c.spriteDrawMsg.connect(self.frame.spriteDrawController)
self.c.rectDrawMsg.connect(self.frame.rectDrawController)
self.c.circleDrawMsg.connect(self.frame.circleDrawController)
self.tabWidget = QtWidgets.QTabWidget(self.centralWidget)
self.tabWidget.setGeometry(QtCore.QRect(450, 10, 221, 411))
self.tabWidget.setObjectName("tabWidget")
self.tab = QtWidgets.QWidget()
self.tab.setObjectName("tab")
self.tabWidget.addTab(self.tab, "")
self.tab_2 = QtWidgets.QWidget()
self.tab_2.setObjectName("tab_2")
self.treeView = QtWidgets.QTreeView(self.tab_2)
self.treeView.setGeometry(QtCore.QRect(0, 0, 221, 221))
self.treeView.setObjectName("treeView")
########################################### get selected sprite file path and send signal to frame
def sendSpriteDrawMsg(item):
index = self.treeView.currentIndex()
p = self.model.filePath(index)
self.c.spriteDrawMsg.emit(p, "sprite")
self.treeView.doubleClicked.connect(sendSpriteDrawMsg)
##################################################################################################
########################################### send drawRect signal to frame
def sendRectDrawMsg(item):
# do needed things here
self.c.spriteDrawMsg.emit("rect")
# send a signal to sendRectDrawMsg here
##########################################################################
########################################### send drawCircle signal to frame
def sendCircleDrawMsg(item):
# do needed things here
self.c.spriteDrawMsg.emit("circle")
# send a signal to sendCircleDrawMsg here
#############################################################################
self.model = QFileSystemModel()
self.path = "."
self.model.setRootPath(self.path)
# self.filter = Iterable("*.png")
# self.model.setNameFilters(self.filter)
# self.model.removeColumn(1)
# self.model.removeColumn(2)
# self.model.removeColumn(3)
# self.model.setFilter(QDir.AllDirs | QDir.NoDotAndDotDot | QDir.AllEntries)
#
# self.proxyModel = QSortFilterProxyModel()
# self.proxyModel.setSourceModel(model)
# self.proxyModel.removeColumn(1)
# self.proxyModel.removeColumn(2)
# self.proxyModel.removeColumn(3)
self.treeView.setModel(self.model)
self.treeView.setRootIndex(self.model.index(self.path))
self.treeView.expandAll()
self.listView = QtWidgets.QListView(self.tab_2)
self.listView.setGeometry(QtCore.QRect(0, 240, 221, 141))
self.listView.setObjectName("listView")
self.line = QtWidgets.QFrame(self.tab_2)
self.line.setGeometry(QtCore.QRect(30, 220, 151, 20))
self.line.setFrameShape(QtWidgets.QFrame.HLine)
self.line.setFrameShadow(QtWidgets.QFrame.Sunken)
self.line.setObjectName("line")
#.........这里部分代码省略.........