fields.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:cmt 作者: chadmv 项目源码 文件源码
def browse(self, line_edit, relative_to_combobox):
        root = cmds.workspace(q=True, rd=True)
        file_path = cmds.fileDialog2(fileFilter=self.filter, dialogStyle=2, caption=self.name,
                                     fileMode=1, returnFilter=False, startingDirectory=root)
        if file_path:
            # Modify the file path to be a path based on the relative_to value
            file_path = file_path[0].replace('\\', '/')
            relative_to = relative_to_combobox.currentText().replace('\\', '/')
            if relative_to == FilePathField.project_root:
                project_root = cmds.workspace(q=True, rd=True).replace('\\', '/')
                file_path = file_path.replace(project_root, '')
            elif relative_to == FilePathField.full_path:
                # Do nothing, just take the full path
                pass
            else:
                # Account for if the relative_to is an environment variable.
                file_path = os.path.expandvars(file_path)
                # Account for if the relative_to is an actual file path.
                file_path = re.sub('^{0}'.format(relative_to), '', file_path)
            line_edit.setText(file_path)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号