GUI help (BEGINNER EASY)

Post here if you need help with creating a Graphical User Interface in Python.

GUI help (BEGINNER EASY)

Postby marcofgodai » Thu Oct 17, 2013 10:51 pm

Hey All,

This is what I'm using to make GUI's in maya. my gui is made in qt, my code typed in maya python editor. The buttons are connected to functions in the python code.

Maya 2012, 2013
qt Designer
Python

I'm a proud newb. I'm stuck on two things

- I'm trying to get my Maya scene objects (cameras, geometry, lights, etc) to list into ListView Widget on my gui in maya. and the list should refresh
when i hit the refresh button (should execute List() function and populate the field. But I can't get anything for months now. I know the List() code is BAD,
these were ideas I've been troubleshooting. Anyone know a CLEAR, PROVEN way that not complicated?
Code: Select all
def List():
    cmds.paneLayout()
    cmds.textScrollList(numberOfRows=10, allowMultiSelection=True)
    cmds.showWindow()
    listObjects = cmds.ls(g=True, cameras=True, lights=True)
    print listObjects


-The other issue is my Error handler.
I want this error window to pop up when/if someone hits the "bake" command with nothing selected
Code: Select all
# Bake animation Error close command
def CloseError():
    close = cmds.deleteUI(window, window=True)
# Bake error window display code   
def BakeError():
    window = cmds.window(title="Animation Bake Error!", iconName="Animation Bake Error!", w = 350, h = 85, sizeable=False)
    cmds.columnLayout(w = 350, h = 85)
    cmds.separator(h=10)
    cmds.text(label="                     Nothing was selected for Baking                    ", align='center')
    cmds.separator(h=20)
    cmds.button(label="Close", w=300, command = 'CloseError()')
    cmds.showWindow(window)
   
# Bake animation of selected objects
   
def BakeAnim():   
    time = [cmds.playbackOptions(min=True,q=True), cmds.playbackOptions(max=True,q=True)]
    #print time simply checks numbers, deleteable
    print time
    cmds.bakeResults(t=(cmds.playbackOptions(min=True,q=True),cmds.playbackOptions(max=True,q=True)), simulation=True) 
     
#"" FIND A WAY TO MAKE THIS WORK IF NOTHING IS SELECTED ""
#    if cmds.bakeResults(q=True, simulation=False):
#        return BakeError()


When isolated, the code words fine, see for yourself
Code: Select all
import maya.cmds as cmds
import maya.mel as mel

def CloseError():
    close = cmds.deleteUI(window, window=True)
   
def List():
    listObjects = cmds.ls(g=True, cameras=True, lights=True)
    print listObjects

def BakeError():
    window = cmds.window(title="Animation Bake Error!", iconName="Animation Bake Error!", w = 350, h = 85, sizeable=False)
    cmds.columnLayout(w = 350, h = 85)
    cmds.separator(h=10)
    cmds.text(label="                     Nothing was selected for Baking                    ", align='center')
    cmds.separator(h=20)
    cmds.button(label="Close", w=300, command = 'CloseError()')
    cmds.showWindow(window)

BakeError()
marcofgodai
 
Posts: 3
Joined: Mon Jun 17, 2013 8:43 pm

Return to GUI

Who is online

Users browsing this forum: No registered users and 0 guests