Python writes a plugin for viewing directory listings in Maya

Source: Internet
Author: User

Before writing an article that uses Python to traverse a folder, extend the code today and make it a Maya plugin with UI user interface that can run directly in Maya;

function is to display a list of files in the disk partition directory;

ImportOSdefChdisk (): CD= Mc.optionmenu (OP, V=1, Q=1) MLS=Os.listdir (CD)#switching between listsMc.textscrolllist (Directorylist, e=1, removeall=1) mc.textscrolllist (Directorylist, E=1, append=MLS)#get a list of any directorydefClick (diskname): DiskN=Os.listdir (diskname) listsize=Len (DISKN) forIinchRange (0, listsize, 1):        PrintDiskn[i].decode ('GBK')        #formMc.window (title = ('Disk View'). Decode ('GBK'), height=600) mc.columnlayout ()#Add drop-down menuop = Mc.optionmenu (label= ('Catalogue'). Decode ('GBK'), CC ="Chdisk ()") #options in the menuMc.menuitem (label ='c:\\') mc.menuitem (label='d:\\') mc.menuitem (label='f:\\')#Get directory listDirList1 = mc.textscrolllist (numberofrows = 1, append = Os.listdir ("c:\\")) DirList2= Mc.textscrolllist (numberofrows = 1, append = Os.listdir ("d:\\")) DirList3= Mc.textscrolllist (numberofrows = 1, append = Os.listdir ("f:\\"))#Test Printing F-disk listClick"f:\\") Mc.showwindow ()

  

The window is named "Disk View"-the effect is as follows:

The function of the plugin is to display the list of files in the disk partition directory;

If necessary, you can add the ability to click on the list name to display the subordinate file, similar to the effect of the resource manager.

Python can customize plug-ins for a variety of functions, accelerating production processes and increasing productivity.

Python writes a plugin for viewing directory listings in Maya

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.