PySide QlistWidget选择了Item目录(路径)

时间:2017-12-04 02:21:44

标签: python pyside maya qlistwidget

我有问题;如何从“QListWidget”选中的项目中获取路径(目录)。

当我使用os.path时,这给了我Autodesk Maya Directory。但我需要从QListWidget项目中选择所选项目的目录。

from PySide.QtGui import *
from maya.app.general.mayaMixin import MayaQWidgetDockableMixin
import os
import maya.cmds as cm

从maya导入maya命令为cm。这不包括python源文件。

class projectManagerMainWindow(MayaQWidgetDockableMixin, QWidget):
    def __init__(self):
        super(projectManagerMainWindow, self).__init__()

        self.selectProject = QComboBox()
        self.selectProject.setFixedHeight(30)
        items = ["Main Projects","Assets"]
        self.selectProject.addItems(items)
        self.createNewProject = QPushButton()

        self.createNewProject.setFixedSize(100,30)
        icon = QPixmap('C:/Users/Faithcure/Documents/maya/2016/scripts/projectManager/new.png')
        self.createNewProject.setText("New Project")
        self.createNewProject.setIcon(icon)
        self.dir_label = QLabel()


        def select_driectory():
            select_path = cm.fileDialog2(fileMode=3, okc = "Select")
            self.sceneList.clear()
            for path in select_path:
                folders = os.listdir(path)
                self.sceneList.addItems(folders)
                self.dir_label.setText(path)


        self.choose_directory = QPushButton()
        self.choose_directory.setText("Directory")
        self.choose_directory.setIcon(icon)
        self.choose_directory.setFixedSize(100,30)
        self.choose_directory.clicked.connect(select_driectory)

        def new_project_window():
            import newProject
            reload(newProject)
            ui = newProject.start()
            ui.exec_()
        def selected_item_path():
            pass

        self.createNewProject.clicked.connect(new_project_window)

这是来自所选目录项的Qlistwidget。

        self.sceneLabel = QLabel()
        self.sceneLabel.setText("Episodes: ")
        self.sceneList = QListWidget()
        self.sceneList.itemClicked.connect(selected_item_path)

这是我的第二个列表小部件(我想在scneneList小部件的所选目录文件夹下列出...

        self.shotLabel = QLabel("Shots: ")
        self.shotList = QListWidget()


        self.topLayout = QHBoxLayout()
        self.topLayout.addWidget(self.selectProject)
        self.topLayout.addWidget(self.createNewProject)
        self.topLayout.addWidget(self.choose_directory)

        self.secondLayout = QVBoxLayout()

        self.thirdLayout = QHBoxLayout()
        self.thirdLayout.addWidget(self.sceneList)
        self.thirdLayout.addWidget(self.shotList)

        self.labels = QHBoxLayout()
        self.labels.addWidget(self.sceneLabel)
        self.labels.addWidget(self.shotLabel)

        self.saveSceneVer = QPushButton()
        self.saveSceneVer.setText("Save New Version")
        self.saveSceneVer.setFixedHeight(30)
        self.saveSceneVer.setStyleSheet("background-color:#00aff0")

        self.openTrack = QPushButton()
        self.openTrack.setText("Open Track")
        self.openTrack.setFixedHeight(30)
        self.openTrack.setStyleSheet("background-color:#ff5a80")

        self.opButtons = QHBoxLayout()
        self.opButtons.addWidget(self.saveSceneVer)
        self.opButtons.addWidget(self.openTrack)

        #Tab section for a lat of operations!
        self.operation_tabs = QTabWidget()

        tabWidget_Animation = QWidget()

        optimize_for_animator_scene = QPushButton()
        optimize_for_animator_scene.setText("I am an Animator")

        create_render_camera = QPushButton()
        create_render_camera.setText("Create Camera")

        make_playblast = QPushButton()
        make_playblast.setText("Playblast")

        tabWidget_Animation_Layout = QGridLayout()
        tabWidget_Animation.setLayout(tabWidget_Animation_Layout)
        tabWidget_Animation_Layout.addWidget(optimize_for_animator_scene,0,0,0)
        tabWidget_Animation_Layout.addWidget(create_render_camera,       0,1,0)
        tabWidget_Animation_Layout.addWidget(make_playblast,             0,2,0)


        tabWidget_render = QWidget()       
        tabWidget_td = QWidget()

        self.operation_tabs.addTab(tabWidget_Animation,"Animation")
        self.operation_tabs.addTab(tabWidget_render,"Render")
        self.operation_tabs.addTab(tabWidget_td,"Compositing")

        self.masterLayout = QVBoxLayout()
        self.masterLayout.addLayout(self.topLayout)
        self.masterLayout.addWidget(self.dir_label)
        self.masterLayout.addLayout(self.secondLayout)
        self.masterLayout.addLayout(self.labels)
        self.masterLayout.addLayout(self.thirdLayout)
        self.masterLayout.addLayout(self.opButtons)
        self.masterLayout.addWidget(self.operation_tabs)
        self.setLayout(self.masterLayout)

def start():
    ui = projectManagerMainWindow()
    ui.setWindowTitle("Project Manager")
    ui.setFixedWidth(400)
    ui.show(dockable=True, floating=False, area='right')
    return ui

这是Autodesk Maya的脚本。

0 个答案:

没有答案