Author Topic: accessing GUI values  (Read 11317 times)

bijuramavfx

  • Sr. Member
  • ****
  • Posts: 40
accessing GUI values
« on: August 14, 2012, 01:00:13 PM »
Hi there:

How do I access the UI parameters  that gets created in Create function call in postDialog function call

For example

I have declared rezpackage as an option in Create function but when I try to retrieve the value for this option I get keyerror ..?


def nbPrman_postDialog(cmd, values):
    #Accessing rezpackage
    rezpac = values['package']['rezpackage']

    # Make sure ribFile contains QB_FRAME_NUMBER
    ribFile = values['package']['ribFile']
    frame = os.path.basename(os.path.dirname(ribFile))
    values['package']['padding'] = len(frame)
    values['package']['ribFile'] = ribFile.replace('/%s' %frame, '/QB_FRAME_NUMBER')

    # Create real command line
    cmdline = 'prman -progress "%s"' %values['package']['ribFile']
    values['package']['cmdline'] = cmdline

    values['prototype'] = 'nbCmdrange'

def create_nbPrman():
    """Create nbPrman SimpleSubmit."""
    cmdjob = SimpleSubmit('nbPrman', hasRange=True, canChunk=False,
                          help='Front-end submission to nbPrman jobtype', category='3D',
                          postDialog=nbPrman_postDialog, controlChanged=default_controlChanged)

    cmdjob.add_optionGroup('Primary Parameters')
    cmdjob.add_option('rezpackage', 'string', mode = 'open', default = 'rman_shaders', choices = ['rman_shaders'])
    cmdjob.add_option('ribFile', 'file', 'Renderman .rib  file to render with Prman',
                      label='RIB File', mode='open',
                      mask='Renderman RIB File (*.rib)|*.rib|All files (*.*)|*.*', required=True,
                      startDirectory=PROD_PATH)

    default_nbOptions(cmdjob)

    return cmdjob

Thanks
/Biju

BrianK

  • Hero Member
  • *****
  • Posts: 107
Re: accessing GUI values
« Reply #1 on: August 14, 2012, 03:22:56 PM »
Hi Biju,

When you add the option, you're using "default = 'rman_shaders'".  This tells the UI to fill in the field with "rman_shaders" but assumes that is a default value.  In other words, that value is not needed unless changed.  If you were to change the value to something else, you will get it in the postdialog via values['package']['rezpackage'].  Being that this is a default value, the correct way to retrieve the value is via values['package'].get('rezpackage','some_default_value').

If you want the "rman_shaders" to always come through, regardless of whether or not the user changes it, use "value = 'rman_shaders'" instead of "default = 'rman_shaders'".  This tells the submission UI that a value is assigned to the field & must be passed through.

-Brian

bijuramavfx

  • Sr. Member
  • ****
  • Posts: 40
Re: accessing GUI values
« Reply #2 on: August 15, 2012, 05:19:53 PM »
Thanks Brian