Hi Justin,
Thanks for you quick answer !
I'm sorry but I don't understand everything, I just started to learn...
Can you please put it directly into the script ? :$
I'm so sorry but I don't get it...
Many many thanks !!
Le mardi 5 mars 2013 00:14:45 UTC, Justin Israel a écrit :
> Dictionaries are unsorted, but you can iterate over a sorted version like
> this:
>
>
> for name, widget in sorted(widget.iteritems()):
> ...
>
>
> This will sort on the keys.
>
> Also, from your snippet you can save a few steps of looping and converting
> your category names by just starting with a set:
>
>
> categories = set()
> for icon in icons:
> categoryName = icon.partition("__")[0]
>
> categories.add(categoryName)
>
>
> If you really need categories to be a list instead of a set, then you could
> convert it back now:
> categories = list(categories)
> But a set can still be looped over, and is faster for checking membership
> ("foo" in categories)
>
>
>
>
>
>
>
> On Tue, Mar 5, 2013 at 12:58 PM, ImLearning Python <[email protected]>
> wrote:
>
> Hi all :)
>
>
>
> I'm currently learning Python by myself then I'm doing some tutorials on the
> web like this excelent one from Jeremy Ernst:
>
>
>
> Building Maya Interfaces with Python: Video Four
>
> http://vimeo.com/44707576
>
>
>
> My window works pretty well but I would like to know if it's possible to
> store all Icons and frameLayout alphabetically ?
>
>
>
> Here is the part of the code to create Icons :
>
>
>
>
>
> """""""""""
>
>
>
> def populateIcons():
>
>
>
> IconPath = cmds.internalVar(upd = True) + "icons/m_Tools/"
>
>
>
> icons = os.listdir(IconPath)
>
>
>
> categories = []
>
> for icon in icons:
>
> categoryName = icon.partition("__")[0]
>
> categories.append(categoryName)
>
>
>
>
>
> categoryNames = list(set(categories))
>
>
>
> for name in categoryNames:
>
> # Create a frameLayout
>
> widgets[(name + "_frameLayout")] = cmds.frameLayout(label =
> name, collapsable = True, parent = widgets["mainLayout"])
>
> widgets[(name + "_mainLayout")] = cmds.rowColumnLayout(nc =
> 5, parent = widgets[(name + "_frameLayout")])
>
>
>
>
>
> for icon in icons:
>
> niceName = icon.partition(".")[0]
>
> category = icon.partition("__")[0]
>
> command = icon.partition("__")[2].partition(".")[0] #
> selectionne le nom apres les "__" et avant le "." de l'extension/ example :
>
>
>
> widgets[(niceName + "_button")] = cmds.symbolButton (w = 40,
> h = 40, image = (IconPath + icon), parent = widgets[(category +
> "_mainLayout")], c = partial(runMethod, command))
>
>
>
> """""""""""
>
>
>
> Many thanks !
>
>
>
> P.
>
>
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
>
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
>
> To post to this group, send email to [email protected].
>
> For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.