Jump to content

houdini pytho pyqt4 button event


Recommended Posts

 

When I create a button event in Houdini pyqt4, I want to create another event from that selected button.

 

example

 

 

.

.

.

 

 

def btn1_clicked(self):

 

        camList = []

        

        globj = hou.node('/obj/')

                

        

        for child in globj.children():

            nameOrder = list(child.type().namespaceOrder())

        

            

            if 'gl_Camera_' in nameOrder:

                camList.append(child.path()+'/fx_renderCam')

            

            elif 'cam' in nameOrder:

                camList.append(child.path())

                

        camCount = len(camList)

        

        

        if camCount == 0:

            choiceCamPath = 'None'

            

            

            sh_render = hou.node('/out').createNode('gl_Mantra_','RENDER_shadow')

            sh_render.moveToGoodPosition()

            #sh_render.setColor(hou.color((1,2,3)))

            sh_mat = hou.node('/mat').createNode('shadowmatte')

            sh_mat.moveToGoodPosition()

            

            

            sh_render.parm('camera').set('None')

            hou.ui.displayMessage('no cam.')

            

            

        elif camCount > 1:

            camList.append('Cancel')

            choiceCam = hou.ui.displayMessage('choice cam.', buttons=camList , severity=hou.severityType.Message, close_choice=camCount) <-  If 'cancel' is clicked, the node is not created at the out level and the message window is turned off.

            

            choiceCamPath = camList[choiceCam]

            

       #     if buttons==camCount:

        #       self.close()

               

               

               

            else:                        

                sh_render = hou.node('/out').createNode('gl_Mantra_','RENDER_shadow')

                sh_render.moveToGoodPosition()

                #sh_render.setColor(hou.color((1,2,3)))

                sh_mat = hou.node('/mat').createNode('shadowmatte')

                sh_mat.moveToGoodPosition()

            

            

            

            

                sh_render.parm('camera').set(choiceCamPath)

        


This is part of the script to automatically create the shadow mat I am creating.

 


Thank you for your help.

Link to comment
Share on other sites

Please display your code using the insert code, would be much easier to read. 

The hou.ui.displayMessage function returns the id for the button clicked (i.e 0 for the 1st button, 1 for the second...) so I assume you can do something like this :

mybuttons = ["cam1", "cam2", "cam3", "cancel"]

returned_button = hou.ui.displayMessage("my message", buttons = mybuttons, close_choice = (len(my_buttons) -1))

if returned_button == (len(mybuttons) - 1):  #don't forget to subtract one of your list length to get the right index, otherwise you'll get the wrong one
    do something
    do something else
    

 

Cheers,

Edited by DonRomano
Link to comment
Share on other sites

17 minutes ago, DonRomano said:

Please display your code using the insert code, would be much easier to read. 

The hou.ui.displayMessage function returns the id for the button clicked (i.e 0 for the 1st button, 1 for the second...) so I assume you can do something like this :


mybuttons = ["cam1", "cam2", "cam3", "cancel"]

returned_button = hou.ui.displayMessage("my message", buttons = mybuttons, close_choice = (len(my_buttons) -1))

if returned_button == (len(mybuttons) - 1):  #don't forget to subtract one of your list length to get the right index, otherwise you'll get the wrong one
    do something
    do something else
    

 

Cheers,

Thank you for your support!!!!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...