def __main__(*args):
    global scriptDialog
    global settings
    global ProjectManagementOptions
    global DraftRequested
    global integration_dialog

    scriptDialog = DeadlineScriptDialog()
    scriptDialog.SetTitle("Submit Blender Job To Deadline")
    scriptDialog.SetIcon(scriptDialog.GetIcon('Blender'))

    scriptDialog.AddTabControl("Tabs", 0, 0)

    scriptDialog.AddTabPage("Job Options")
    scriptDialog.AddGrid()
    scriptDialog.AddControlToGrid("Separator1",
                                  "SeparatorControl",
                                  "Job Description",
                                  0,
                                  0,
                                  colSpan=2)

    scriptDialog.AddControlToGrid(
        "NameLabel", "LabelControl", "Job Name", 1, 0,
        "The name of your job. This is optional, and if left blank, it will default to 'Untitled'.",
        False)
    scriptDialog.AddControlToGrid("NameBox", "TextControl", "Untitled", 1, 1)

    scriptDialog.AddControlToGrid(
        "CommentLabel", "LabelControl", "Comment", 2, 0,
        "A simple description of your job. This is optional and can be left blank.",
        False)
    scriptDialog.AddControlToGrid("CommentBox", "TextControl", "", 2, 1)

    scriptDialog.AddControlToGrid(
        "DepartmentLabel", "LabelControl", "Department", 3, 0,
        "The department you belong to. This is optional and can be left blank.",
        False)
    scriptDialog.AddControlToGrid("DepartmentBox", "TextControl", "", 3, 1)
    scriptDialog.EndGrid()

    scriptDialog.AddGrid()
    scriptDialog.AddControlToGrid("Separator2",
                                  "SeparatorControl",
                                  "Job Options",
                                  0,
                                  0,
                                  colSpan=3)

    scriptDialog.AddControlToGrid(
        "PoolLabel", "LabelControl", "Pool", 1, 0,
        "The pool that your job will be submitted to.", False)
    scriptDialog.AddControlToGrid("PoolBox", "PoolComboControl", "none", 1, 1)

    scriptDialog.AddControlToGrid(
        "SecondaryPoolLabel", "LabelControl", "Secondary Pool", 2, 0,
        "The secondary pool lets you specify a Pool to use if the primary Pool does not have any available Slaves.",
        False)
    scriptDialog.AddControlToGrid("SecondaryPoolBox",
                                  "SecondaryPoolComboControl", "", 2, 1)

    scriptDialog.AddControlToGrid(
        "GroupLabel", "LabelControl", "Group", 3, 0,
        "The group that your job will be submitted to.", False)
    scriptDialog.AddControlToGrid("GroupBox", "GroupComboControl", "none", 3,
                                  1)

    scriptDialog.AddControlToGrid(
        "PriorityLabel", "LabelControl", "Priority", 4, 0,
        "A job can have a numeric priority ranging from 0 to 100, where 0 is the lowest priority and 100 is the highest priority.",
        False)
    scriptDialog.AddRangeControlToGrid(
        "PriorityBox", "RangeControl",
        RepositoryUtils.GetMaximumPriority() / 2, 0,
        RepositoryUtils.GetMaximumPriority(), 0, 1, 4, 1)

    scriptDialog.AddControlToGrid(
        "TaskTimeoutLabel", "LabelControl", "Task Timeout", 5, 0,
        "The number of minutes a slave has to render a task for this job before it requeues it. Specify 0 for no limit.",
        False)
    scriptDialog.AddRangeControlToGrid("TaskTimeoutBox", "RangeControl", 0, 0,
                                       1000000, 0, 1, 5, 1)
    scriptDialog.AddSelectionControlToGrid(
        "AutoTimeoutBox", "CheckBoxControl", False, "Enable Auto Task Timeout",
        5, 2,
        "If the Auto Task Timeout is properly configured in the Repository Options, then enabling this will allow a task timeout to be automatically calculated based on the render times of previous frames for the job. "
    )

    scriptDialog.AddControlToGrid(
        "ConcurrentTasksLabel", "LabelControl", "Concurrent Tasks", 6, 0,
        "The number of tasks that can render concurrently on a single slave. This is useful if the rendering application only uses one thread to render and your slaves have multiple CPUs.",
        False)
    scriptDialog.AddRangeControlToGrid("ConcurrentTasksBox", "RangeControl", 1,
                                       1, 16, 0, 1, 6, 1)
    scriptDialog.AddSelectionControlToGrid(
        "LimitConcurrentTasksBox", "CheckBoxControl", True,
        "Limit Tasks To Slave's Task Limit", 6, 2,
        "If you limit the tasks to a slave's task limit, then by default, the slave won't dequeue more tasks then it has CPUs. This task limit can be overridden for individual slaves by an administrator."
    )

    scriptDialog.AddControlToGrid(
        "MachineLimitLabel", "LabelControl", "Machine Limit", 7, 0,
        "Use the Machine Limit to specify the maximum number of machines that can render your job at one time. Specify 0 for no limit.",
        False)
    scriptDialog.AddRangeControlToGrid("MachineLimitBox", "RangeControl", 0, 0,
                                       1000000, 0, 1, 7, 1)
    scriptDialog.AddSelectionControlToGrid(
        "IsBlacklistBox", "CheckBoxControl", False,
        "Machine List Is A Blacklist", 7, 2,
        "You can force the job to render on specific machines by using a whitelist, or you can avoid specific machines by using a blacklist."
    )

    scriptDialog.AddControlToGrid(
        "MachineListLabel", "LabelControl", "Machine List", 8, 0,
        "The whitelisted or blacklisted list of machines.", False)
    scriptDialog.AddControlToGrid("MachineListBox",
                                  "MachineListControl",
                                  "",
                                  8,
                                  1,
                                  colSpan=2)

    scriptDialog.AddControlToGrid("LimitGroupLabel", "LabelControl", "Limits",
                                  9, 0, "The Limits that your job requires.",
                                  False)
    scriptDialog.AddControlToGrid("LimitGroupBox",
                                  "LimitGroupControl",
                                  "",
                                  9,
                                  1,
                                  colSpan=2)

    scriptDialog.AddControlToGrid(
        "DependencyLabel", "LabelControl", "Dependencies", 10, 0,
        "Specify existing jobs that this job will be dependent on. This job will not start until the specified dependencies finish rendering.",
        False)
    scriptDialog.AddControlToGrid("DependencyBox",
                                  "DependencyControl",
                                  "",
                                  10,
                                  1,
                                  colSpan=2)

    scriptDialog.AddControlToGrid(
        "OnJobCompleteLabel", "LabelControl", "On Job Complete", 11, 0,
        "If desired, you can automatically archive or delete the job when it completes.",
        False)
    scriptDialog.AddControlToGrid("OnJobCompleteBox", "OnJobCompleteControl",
                                  "Nothing", 11, 1)
    scriptDialog.AddSelectionControlToGrid(
        "SubmitSuspendedBox", "CheckBoxControl", False,
        "Submit Job As Suspended", 11, 2,
        "If enabled, the job will submit in the suspended state. This is useful if you don't want the job to start rendering right away. Just resume it from the Monitor when you want it to render."
    )
    scriptDialog.EndGrid()

    scriptDialog.AddGrid()
    scriptDialog.AddControlToGrid("Separator3",
                                  "SeparatorControl",
                                  "Blender Options",
                                  0,
                                  0,
                                  colSpan=3)

    scriptDialog.AddControlToGrid("SceneLabel", "LabelControl", "Blender File",
                                  1, 0, "The scene file to be rendered.",
                                  False)
    scriptDialog.AddSelectionControlToGrid(
        "SceneBox",
        "FileBrowserControl",
        "",
        "Blender Files (*.blend);;All Files (*)",
        1,
        1,
        colSpan=2)

    scriptDialog.AddControlToGrid(
        "OutputLabel", "LabelControl", "Output File (Optional)", 2, 0,
        "Override the output path in the scene. This is optional, and can be left blank.",
        False)
    scriptDialog.AddSelectionControlToGrid("OutputBox",
                                           "FileSaverControl",
                                           "",
                                           "All Files (*)",
                                           2,
                                           1,
                                           colSpan=2)

    scriptDialog.AddControlToGrid("FramesLabel", "LabelControl", "Frame List",
                                  3, 0, "The list of frames to render.", False)
    scriptDialog.AddControlToGrid("FramesBox",
                                  "TextControl",
                                  "",
                                  3,
                                  1,
                                  colSpan=2)

    scriptDialog.AddControlToGrid(
        "ChunkSizeLabel", "LabelControl", "Frames Per Task", 4, 0,
        "This is the number of frames that will be rendered at a time for each job task. ",
        False)
    scriptDialog.AddRangeControlToGrid("ChunkSizeBox",
                                       "RangeControl",
                                       1,
                                       1,
                                       1000000,
                                       0,
                                       1,
                                       4,
                                       1,
                                       expand=False)
    scriptDialog.AddSelectionControlToGrid(
        "SubmitSceneBox", "CheckBoxControl", False,
        "Submit Blender Scene File With The Job", 4, 2,
        "If this option is enabled, the scene file will be submitted with the job, and then copied locally to the slave machine during rendering."
    )

    scriptDialog.AddControlToGrid(
        "ThreadsLabel", "LabelControl", "Threads", 5, 0,
        "The number of threads to use for rendering.", False)
    scriptDialog.AddRangeControlToGrid("ThreadsBox",
                                       "RangeControl",
                                       0,
                                       0,
                                       256,
                                       0,
                                       1,
                                       5,
                                       1,
                                       expand=False)

    scriptDialog.AddControlToGrid(
        "BuildLabel", "LabelControl", "Build To Force", 6, 0,
        "You can force 32 or 64 bit rendering with this option.", False)
    scriptDialog.AddComboControlToGrid("BuildBox",
                                       "ComboControl",
                                       "None", ("None", "32bit", "64bit"),
                                       6,
                                       1,
                                       expand=False)
    scriptDialog.EndGrid()
    scriptDialog.EndTabPage()

    integration_dialog = IntegrationUI.IntegrationDialog()
    integration_dialog.AddIntegrationTabs(scriptDialog,
                                          "BlenderMonitor",
                                          DraftRequested,
                                          ProjectManagementOptions,
                                          failOnNoTabs=False)
    # Add Project Management and Draft Tabs

    scriptDialog.EndTabControl()

    scriptDialog.AddGrid()
    scriptDialog.AddHorizontalSpacerToGrid("HSpacer1", 0, 0)

    submitButton = scriptDialog.AddControlToGrid("SubmitButton",
                                                 "ButtonControl",
                                                 "Submit",
                                                 0,
                                                 1,
                                                 expand=False)
    submitButton.ValueModified.connect(SubmitButtonPressed)

    closeButton = scriptDialog.AddControlToGrid("CloseButton",
                                                "ButtonControl",
                                                "Close",
                                                0,
                                                2,
                                                expand=False)
    # Make sure all the project management connections are closed properly
    closeButton.ValueModified.connect(
        integration_dialog.CloseProjectManagementConnections)
    closeButton.ValueModified.connect(scriptDialog.closeEvent)

    scriptDialog.EndGrid()

    settings = ("DepartmentBox", "CategoryBox", "PoolBox", "SecondaryPoolBox",
                "GroupBox", "PriorityBox", "MachineLimitBox", "IsBlacklistBox",
                "MachineListBox", "LimitGroupBox", "SceneBox", "FramesBox",
                "ChunkSizeBox", "OutputBox", "ThreadsBox", "BuildBox",
                "SubmitSceneBox")
    scriptDialog.LoadSettings(GetSettingsFilename(), settings)
    scriptDialog.EnabledStickySaving(settings, GetSettingsFilename())

    appSubmission = False
    if len(args) > 0:
        appSubmission = True

        if args[0] == "":
            scriptDialog.ShowMessageBox(
                "The Blender scene must be saved before it can be submitted to Deadline.",
                "Error")
            return

        scriptDialog.SetValue("SceneBox", args[0])
        scriptDialog.SetValue("NameBox",
                              Path.GetFileNameWithoutExtension(args[0]))

        scriptDialog.SetValue("FramesBox", args[1])

        outputFile = args[2]
        paddingSize = FrameUtils.GetPaddingSizeFromFilename(outputFile)
        padding = ""
        while len(padding) < paddingSize:
            padding += "#"

        outputFile = FrameUtils.GetFilenameWithoutPadding(outputFile)
        directory = Path.GetDirectoryName(outputFile)
        prefix = Path.GetFileNameWithoutExtension(outputFile)
        extension = Path.GetExtension(outputFile)
        outputFile = Path.Combine(directory, prefix + padding + extension)
        scriptDialog.SetValue("OutputBox", outputFile)

        scriptDialog.SetValue("ThreadsBox", int(args[3]))

        platform = args[4]
        if platform.find("64") >= 0:
            scriptDialog.SetValue("BuildBox", "64bit")
        elif platform.find("32") >= 0 or platform.find("86") >= 0:
            scriptDialog.SetValue("BuildBox", "32bit")
        else:
            scriptDialog.SetValue("BuildBox", "None")

        # Keep the submission window above all other windows when submitting from another app.
        scriptDialog.MakeTopMost()

    scriptDialog.ShowDialog(appSubmission)
Example #2
0
def __main__(*args):
    global scriptDialog
    global settings
    global ProjectManagementOptions
    global DraftRequested
    global integration_dialog
    global OutputFiles

    parsedArgs = parse_args(args)

    DraftRequested = len(parsedArgs.output) > 0
    OutputFiles = parsedArgs.output

    scriptDialog = DeadlineScriptDialog()
    scriptDialog.SetTitle("Submit Fusion Job To Deadline")
    scriptDialog.SetIcon(scriptDialog.GetIcon('Fusion'))

    scriptDialog.AddTabControl("Tabs", 0, 0)

    scriptDialog.AddTabPage("Job Options")
    scriptDialog.AddGrid()
    scriptDialog.AddControlToGrid("Separator1",
                                  "SeparatorControl",
                                  "Job Description",
                                  0,
                                  0,
                                  colSpan=2)

    scriptDialog.AddControlToGrid(
        "NameLabel", "LabelControl", "Job Name", 1, 0,
        "The name of your job. This is optional, and if left blank, it will default to 'Untitled'.",
        False)
    scriptDialog.AddControlToGrid("NameBox", "TextControl", "Untitled", 1, 1)

    scriptDialog.AddControlToGrid(
        "CommentLabel", "LabelControl", "Comment", 2, 0,
        "A simple description of your job. This is optional and can be left blank.",
        False)
    scriptDialog.AddControlToGrid("CommentBox", "TextControl", "", 2, 1)

    scriptDialog.AddControlToGrid(
        "DepartmentLabel", "LabelControl", "Department", 3, 0,
        "The department you belong to. This is optional and can be left blank.",
        False)
    scriptDialog.AddControlToGrid("DepartmentBox", "TextControl", "", 3, 1)
    scriptDialog.EndGrid()

    scriptDialog.AddGrid()
    scriptDialog.AddControlToGrid("Separator2",
                                  "SeparatorControl",
                                  "Job Options",
                                  0,
                                  0,
                                  colSpan=3)

    scriptDialog.AddControlToGrid(
        "PoolLabel", "LabelControl", "Pool", 1, 0,
        "The pool that your job will be submitted to.", False)
    scriptDialog.AddControlToGrid("PoolBox", "PoolComboControl", "none", 1, 1)

    scriptDialog.AddControlToGrid(
        "SecondaryPoolLabel", "LabelControl", "Secondary Pool", 2, 0,
        "The secondary pool lets you specify a Pool to use if the primary Pool does not have any available Slaves.",
        False)
    scriptDialog.AddControlToGrid("SecondaryPoolBox",
                                  "SecondaryPoolComboControl", "", 2, 1)

    scriptDialog.AddControlToGrid(
        "GroupLabel", "LabelControl", "Group", 3, 0,
        "The group that your job will be submitted to.", False)
    scriptDialog.AddControlToGrid("GroupBox", "GroupComboControl", "none", 3,
                                  1)

    scriptDialog.AddControlToGrid(
        "PriorityLabel", "LabelControl", "Priority", 4, 0,
        "A job can have a numeric priority ranging from 0 to 100, where 0 is the lowest priority and 100 is the highest priority.",
        False)
    scriptDialog.AddRangeControlToGrid(
        "PriorityBox", "RangeControl",
        RepositoryUtils.GetMaximumPriority() / 2, 0,
        RepositoryUtils.GetMaximumPriority(), 0, 1, 4, 1)

    scriptDialog.AddControlToGrid(
        "TaskTimeoutLabel", "LabelControl", "Task Timeout", 5, 0,
        "The number of minutes a slave has to render a task for this job before it requeues it. Specify 0 for no limit.",
        False)
    scriptDialog.AddRangeControlToGrid("TaskTimeoutBox", "RangeControl", 0, 0,
                                       1000000, 0, 1, 5, 1)
    scriptDialog.AddSelectionControlToGrid(
        "AutoTimeoutBox", "CheckBoxControl", False, "Enable Auto Task Timeout",
        5, 2,
        "If the Auto Task Timeout is properly configured in the Repository Options, then enabling this will allow a task timeout to be automatically calculated based on the render times of previous frames for the job."
    )

    scriptDialog.AddControlToGrid(
        "ConcurrentTasksLabel", "LabelControl", "Concurrent Tasks", 6, 0,
        "The number of tasks that can render concurrently on a single slave. This is useful if the rendering application only uses one thread to render and your slaves have multiple CPUs.",
        False)
    scriptDialog.AddRangeControlToGrid("ConcurrentTasksBox", "RangeControl", 1,
                                       1, 16, 0, 1, 6, 1)
    scriptDialog.AddSelectionControlToGrid(
        "LimitConcurrentTasksBox", "CheckBoxControl", True,
        "Limit Tasks To Slave's Task Limit", 6, 2,
        "If you limit the tasks to a slave's task limit, then by default, the slave won't dequeue more tasks then it has CPUs. This task limit can be overridden for individual slaves by an administrator."
    )

    scriptDialog.AddControlToGrid("MachineLimitLabel", "LabelControl",
                                  "Machine Limit", 7, 0, "", False)
    scriptDialog.AddRangeControlToGrid("MachineLimitBox", "RangeControl", 0, 0,
                                       1000000, 0, 1, 7, 1)
    scriptDialog.AddSelectionControlToGrid("IsBlacklistBox", "CheckBoxControl",
                                           False,
                                           "Machine List Is A Blacklist", 7, 2,
                                           "")

    scriptDialog.AddControlToGrid(
        "MachineListLabel", "LabelControl", "Machine List", 8, 0,
        "Use the Machine Limit to specify the maximum number of machines that can render your job at one time. Specify 0 for no limit.",
        False)
    scriptDialog.AddControlToGrid("MachineListBox",
                                  "MachineListControl",
                                  "",
                                  8,
                                  1,
                                  colSpan=2)

    scriptDialog.AddControlToGrid("LimitGroupLabel", "LabelControl", "Limits",
                                  9, 0, "The Limits that your job requires.",
                                  False)
    scriptDialog.AddControlToGrid("LimitGroupBox",
                                  "LimitGroupControl",
                                  "",
                                  9,
                                  1,
                                  colSpan=2)

    scriptDialog.AddControlToGrid(
        "DependencyLabel", "LabelControl", "Dependencies", 10, 0,
        "Specify existing jobs that this job will be dependent on. This job will not start until the specified dependencies finish rendering.",
        False)
    scriptDialog.AddControlToGrid("DependencyBox",
                                  "DependencyControl",
                                  "",
                                  10,
                                  1,
                                  colSpan=2)

    scriptDialog.AddControlToGrid(
        "OnJobCompleteLabel", "LabelControl", "On Job Complete", 11, 0,
        "If desired, you can automatically archive or delete the job when it completes. ",
        False)
    scriptDialog.AddControlToGrid("OnJobCompleteBox", "OnJobCompleteControl",
                                  "Nothing", 11, 1)
    scriptDialog.AddSelectionControlToGrid(
        "SubmitSuspendedBox", "CheckBoxControl", False,
        "Submit Job As Suspended", 11, 2,
        "If enabled, the job will submit in the suspended state. This is useful if you don't want the job to start rendering right away. Just resume it from the Monitor when you want it to render. "
    )
    scriptDialog.EndGrid()

    scriptDialog.AddGrid()
    scriptDialog.AddControlToGrid("Separator3",
                                  "SeparatorControl",
                                  "Fusion Options",
                                  0,
                                  0,
                                  colSpan=3)

    scriptDialog.AddControlToGrid("SceneLabel", "LabelControl", "Fusion Comp",
                                  1, 0, "The comp file to be rendered.", False)
    scriptDialog.AddSelectionControlToGrid("SceneBox",
                                           "MultiFileBrowserControl",
                                           "",
                                           "Fusion Files (*.comp)",
                                           1,
                                           1,
                                           colSpan=2)

    scriptDialog.AddControlToGrid("FramesLabel", "LabelControl", "Frame List",
                                  2, 0, "The list of frames to render.", False)
    scriptDialog.AddControlToGrid("FramesBox", "TextControl", "", 2, 1)
    framesFromFileBox = scriptDialog.AddSelectionControlToGrid(
        "FramesFromFileBox", "CheckBoxControl", False,
        "Use Frame List In Comp", 2, 2,
        "Enable this option to pull the frame range from the comp file.")
    framesFromFileBox.ValueModified.connect(FramesFromFileBoxChanged)

    scriptDialog.AddControlToGrid(
        "ChunkSizeLabel", "LabelControl", "Frames Per Task", 3, 0,
        "This is the number of frames that will be rendered at a time for each job task.",
        False)
    scriptDialog.AddRangeControlToGrid("ChunkSizeBox", "RangeControl", 1, 1,
                                       1000000, 0, 1, 3, 1)
    scriptDialog.AddSelectionControlToGrid(
        "CheckOutputBox", "CheckBoxControl", False, "Check Output", 3, 2,
        "If checked, Deadline will check all savers to ensure they have saved their image file (not supported in command line mode)."
    )

    scriptDialog.AddControlToGrid(
        "ProxyLabel", "LabelControl", "Proxy", 4, 0,
        "The proxy level to use (not supported in command line mode).", False)
    scriptDialog.AddRangeControlToGrid("ProxyBox", "RangeControl", 1, 1,
                                       1000000, 0, 1, 4, 1)
    scriptDialog.AddSelectionControlToGrid(
        "HighQualityBox", "CheckBoxControl", False, "High Quality", 4, 2,
        "Whether or not to render with high quality (not supported in command line mode)."
    )

    scriptDialog.AddControlToGrid("VersionLabel", "LabelControl", "Version", 5,
                                  0, "The version of Fusion to render with.",
                                  False)
    scriptDialog.AddComboControlToGrid("VersionBox", "ComboControl", "7",
                                       ["5", "6", "7", "8", "9"], 5, 1)
    commandLineModeBox = scriptDialog.AddSelectionControlToGrid(
        "CommandLineModeBox", "CheckBoxControl", False, "Command Line Mode", 5,
        2,
        "Enable to render in command line mode using the FusionCmd plugin (this disables some features)."
    )
    commandLineModeBox.ValueModified.connect(CommandLineModeChanged)

    scriptDialog.AddControlToGrid("BuildLabel", "LabelControl", "Build", 6, 0,
                                  "", False)
    scriptDialog.AddComboControlToGrid("BuildBox", "ComboControl", "None",
                                       ("None", "32bit", "64bit"), 6, 1)
    scriptDialog.AddSelectionControlToGrid(
        "SubmitSceneBox", "CheckBoxControl", False, "Submit Comp File", 6, 2,
        "If this option is enabled, the flow/comp file will be submitted with the job, and then copied locally to the slave machine during rendering."
    )
    scriptDialog.EndGrid()

    scriptDialog.EndTabPage()

    integration_dialog = IntegrationUI.IntegrationDialog()
    integration_dialog.AddIntegrationTabs(scriptDialog,
                                          "FusionMonitor",
                                          DraftRequested,
                                          ProjectManagementOptions,
                                          failOnNoTabs=False)

    scriptDialog.EndTabControl()

    scriptDialog.AddGrid()
    scriptDialog.AddControlToGrid("ProgressLabel", "LabelControl", "", 0, 0)

    submitButton = scriptDialog.AddControlToGrid("SubmitButton",
                                                 "ButtonControl",
                                                 "Submit",
                                                 0,
                                                 1,
                                                 expand=False)
    submitButton.ValueModified.connect(SubmitButtonPressed)

    closeButton = scriptDialog.AddControlToGrid("CloseButton",
                                                "ButtonControl",
                                                "Close",
                                                0,
                                                2,
                                                expand=False)
    # Make sure all the project management connections are closed properly
    closeButton.ValueModified.connect(
        integration_dialog.CloseProjectManagementConnections)
    closeButton.ValueModified.connect(scriptDialog.closeEvent)

    scriptDialog.EndGrid()

    settings = ("DepartmentBox", "CategoryBox", "PoolBox", "SecondaryPoolBox",
                "GroupBox", "PriorityBox", "MachineLimitBox", "IsBlacklistBox",
                "MachineListBox", "LimitGroupBox", "SceneBox", "FramesBox",
                "FramesFromFileBox", "ChunkSizeBox", "VersionBox", "ProxyBox",
                "HighQualityBox", "CheckOutputBox", "SubmitSceneBox",
                "BuildBox", "CommandLineModeBox")

    scriptDialog.LoadSettings(GetSettingsFilename(), settings)
    scriptDialog.EnabledStickySaving(settings, GetSettingsFilename())

    if parsedArgs.sceneFile:
        scriptDialog.SetValue("SceneBox", ";".join(parsedArgs.sceneFile))

    if parsedArgs.frames:
        scriptDialog.SetValue("FramesBox", parsedArgs.frames)
        scriptDialog.SetValue("FramesFromFileBox", False)
    else:
        scriptDialog.SetValue("FramesFromFileBox", True)

    if parsedArgs.name:
        jobName = parsedArgs.name
        if len(parsedArgs.sceneFile) > 1:
            jobName += " - " + os.path.basename(parsedArgs.sceneFile[0])
        scriptDialog.SetValue("NameBox", jobName)
    elif len(parsedArgs.sceneFile) == 1:
        scriptDialog.SetValue("NameBox",
                              os.path.basename(parsedArgs.sceneFile[0]))

    if parsedArgs.fusion_version:
        scriptDialog.SetValue("VersionBox",
                              str(int(parsedArgs.fusion_version)))

    if parsedArgs.settings:
        ReadSettingsFile(parsedArgs.settings)

    FramesFromFileBoxChanged(None)
    CommandLineModeChanged(None)

    appSubmission = len(args) > 0
    scriptDialog.ShowDialog(appSubmission)
def __main__():
    global scriptDialog
    global settings
    global ProjectManagementOptions
    global DraftRequested
    global integration_dialog

    scriptDialog = DeadlineScriptDialog()
    scriptDialog.SetTitle("Submit Combustion Job To Deadline")
    scriptDialog.SetIcon(scriptDialog.GetIcon('Combustion'))

    scriptDialog.AddTabControl("Tabs", 0, 0)

    scriptDialog.AddTabPage("Job Options")
    scriptDialog.AddGrid()
    scriptDialog.AddControlToGrid("Separator1",
                                  "SeparatorControl",
                                  "Job Description",
                                  0,
                                  0,
                                  colSpan=2)

    scriptDialog.AddControlToGrid(
        "NameLabel", "LabelControl", "Job Name", 1, 0,
        "The name of your job. This is optional, and if left blank, it will default to 'Untitled'.",
        False)
    scriptDialog.AddControlToGrid("NameBox", "TextControl", "Untitled", 1, 1)

    scriptDialog.AddControlToGrid(
        "CommentLabel", "LabelControl", "Comment", 2, 0,
        "A simple description of your job. This is optional and can be left blank.",
        False)
    scriptDialog.AddControlToGrid("CommentBox", "TextControl", "", 2, 1)

    scriptDialog.AddControlToGrid(
        "DepartmentLabel", "LabelControl", "Department", 3, 0,
        "The department you belong to. This is optional and can be left blank.",
        False)
    scriptDialog.AddControlToGrid("DepartmentBox", "TextControl", "", 3, 1)
    scriptDialog.EndGrid()

    scriptDialog.AddGrid()
    scriptDialog.AddControlToGrid("Separator2",
                                  "SeparatorControl",
                                  "Job Options",
                                  0,
                                  0,
                                  colSpan=3)

    scriptDialog.AddControlToGrid(
        "PoolLabel", "LabelControl", "Pool", 1, 0,
        "The pool that your job will be submitted to.", False)
    scriptDialog.AddControlToGrid("PoolBox", "PoolComboControl", "none", 1, 1)

    scriptDialog.AddControlToGrid(
        "SecondaryPoolLabel", "LabelControl", "Secondary Pool", 2, 0,
        "The secondary pool lets you specify a Pool to use if the primary Pool does not have any available Slaves.",
        False)
    scriptDialog.AddControlToGrid("SecondaryPoolBox",
                                  "SecondaryPoolComboControl", "", 2, 1)

    scriptDialog.AddControlToGrid(
        "GroupLabel", "LabelControl", "Group", 3, 0,
        "The group that your job will be submitted to.", False)
    scriptDialog.AddControlToGrid("GroupBox", "GroupComboControl", "none", 3,
                                  1)

    scriptDialog.AddControlToGrid(
        "PriorityLabel", "LabelControl", "Priority", 4, 0,
        "A job can have a numeric priority ranging from 0 to 100, where 0 is the lowest priority and 100 is the highest priority.",
        False)
    scriptDialog.AddRangeControlToGrid(
        "PriorityBox", "RangeControl",
        RepositoryUtils.GetMaximumPriority() / 2, 0,
        RepositoryUtils.GetMaximumPriority(), 0, 1, 4, 1)

    scriptDialog.AddControlToGrid(
        "TaskTimeoutLabel", "LabelControl", "Task Timeout", 5, 0,
        "The number of minutes a slave has to render a task for this job before it requeues it. Specify 0 for no limit.",
        False)
    scriptDialog.AddRangeControlToGrid("TaskTimeoutBox", "RangeControl", 0, 0,
                                       1000000, 0, 1, 5, 1)
    scriptDialog.AddSelectionControlToGrid(
        "AutoTimeoutBox", "CheckBoxControl", False, "Enable Auto Task Timeout",
        5, 2,
        "If the Auto Task Timeout is properly configured in the Repository Options, then enabling this will allow a task timeout to be automatically calculated based on the render times of previous frames for the job. "
    )

    scriptDialog.AddControlToGrid(
        "ConcurrentTasksLabel", "LabelControl", "Concurrent Tasks", 6, 0,
        "The number of tasks that can render concurrently on a single slave. This is useful if the rendering application only uses one thread to render and your slaves have multiple CPUs.",
        False)
    scriptDialog.AddRangeControlToGrid("ConcurrentTasksBox", "RangeControl", 1,
                                       1, 16, 0, 1, 6, 1)
    scriptDialog.AddSelectionControlToGrid(
        "LimitConcurrentTasksBox", "CheckBoxControl", True,
        "Limit Tasks To Slave's Task Limit", 6, 2,
        "If you limit the tasks to a slave's task limit, then by default, the slave won't dequeue more tasks then it has CPUs. This task limit can be overridden for individual slaves by an administrator."
    )

    scriptDialog.AddControlToGrid(
        "MachineLimitLabel", "LabelControl", "Machine Limit", 7, 0,
        "Use the Machine Limit to specify the maximum number of machines that can render your job at one time. Specify 0 for no limit.",
        False)
    scriptDialog.AddRangeControlToGrid("MachineLimitBox", "RangeControl", 0, 0,
                                       1000000, 0, 1, 7, 1)
    scriptDialog.AddSelectionControlToGrid(
        "IsBlacklistBox", "CheckBoxControl", False,
        "Machine List Is A Blacklist", 7, 2,
        "You can force the job to render on specific machines by using a whitelist, or you can avoid specific machines by using a blacklist."
    )

    scriptDialog.AddControlToGrid(
        "MachineListLabel", "LabelControl", "Machine List", 8, 0,
        "The whitelisted or blacklisted list of machines.", False)
    scriptDialog.AddControlToGrid("MachineListBox",
                                  "MachineListControl",
                                  "",
                                  8,
                                  1,
                                  colSpan=2)

    scriptDialog.AddControlToGrid("LimitGroupLabel", "LabelControl", "Limits",
                                  9, 0, "The Limits that your job requires.",
                                  False)
    scriptDialog.AddControlToGrid("LimitGroupBox",
                                  "LimitGroupControl",
                                  "",
                                  9,
                                  1,
                                  colSpan=2)

    scriptDialog.AddControlToGrid(
        "DependencyLabel", "LabelControl", "Dependencies", 10, 0,
        "Specify existing jobs that this job will be dependent on. This job will not start until the specified dependencies finish rendering.",
        False)
    scriptDialog.AddControlToGrid("DependencyBox",
                                  "DependencyControl",
                                  "",
                                  10,
                                  1,
                                  colSpan=2)

    scriptDialog.AddControlToGrid(
        "OnJobCompleteLabel", "LabelControl", "On Job Complete", 11, 0,
        "If desired, you can automatically archive or delete the job when it completes.",
        False)
    scriptDialog.AddControlToGrid("OnJobCompleteBox", "OnJobCompleteControl",
                                  "Nothing", 11, 1)
    scriptDialog.AddSelectionControlToGrid(
        "SubmitSuspendedBox", "CheckBoxControl", False,
        "Submit Job As Suspended", 11, 2,
        "If enabled, the job will submit in the suspended state. This is useful if you don't want the job to start rendering right away. Just resume it from the Monitor when you want it to render."
    )
    scriptDialog.EndGrid()

    scriptDialog.AddGrid()
    scriptDialog.AddControlToGrid("Separator3",
                                  "SeparatorControl",
                                  "Combustion Options",
                                  0,
                                  0,
                                  colSpan=3)

    scriptDialog.AddControlToGrid("SceneLabel", "LabelControl",
                                  "Workspace File", 1, 0,
                                  "The workspace file to render.", False)
    sceneBox = scriptDialog.AddSelectionControlToGrid(
        "SceneBox",
        "FileBrowserControl",
        "",
        "Workspace Files (*.cws)",
        1,
        1,
        colSpan=2)
    sceneBox.ValueModified.connect(WorkspaceFileChanged)

    scriptDialog.AddControlToGrid(
        "OutputOperatorLabel", "LabelControl", "Output Operator", 2, 0,
        "Select the output operator in the workspace file to render. The render will fail if the operator cannot be found.",
        False)
    scriptDialog.AddComboControlToGrid("OutputOperatorBox", "ComboControl", "",
                                       (), 2, 1)

    scriptDialog.AddControlToGrid("VersionLabel", "LabelControl", "Version", 3,
                                  0,
                                  "The version of Combustion to render with.",
                                  False)
    scriptDialog.AddComboControlToGrid("VersionBox", "ComboControl", "2008",
                                       ("4", "2008"), 3, 1)
    scriptDialog.AddSelectionControlToGrid(
        "SubmitSceneBox", "CheckBoxControl", False, "Submit Workspace File", 3,
        2,
        "If this option is enabled, the workspace file will be submitted with the job, and then copied locally to the slave machine during rendering."
    )

    scriptDialog.AddControlToGrid("FramesLabel", "LabelControl", "Frame List",
                                  4, 0, "The list of frames to render.", False)
    scriptDialog.AddControlToGrid("FramesBox", "TextControl", "", 4, 1)
    scriptDialog.AddSelectionControlToGrid(
        "SkipExistingBox", "CheckBoxControl", False, "Skip Existing Frames", 4,
        2, "Skip over existing frames during rendering.")

    scriptDialog.AddControlToGrid(
        "ChunkSizeLabel", "LabelControl", "Frames Per Task", 5, 0,
        "This is the number of frames that will be rendered at a time for each job task. ",
        False)
    scriptDialog.AddRangeControlToGrid("ChunkSizeBox", "RangeControl", 1, 1,
                                       1000000, 0, 1, 5, 1)
    scriptDialog.AddSelectionControlToGrid("SingleCpuBox", "CheckBoxControl",
                                           False, "Use A Single CPU to Render",
                                           5, 2, "Limit rendering to one CPU.")
    scriptDialog.EndGrid()
    scriptDialog.EndTabPage()

    integration_dialog = IntegrationUI.IntegrationDialog()
    integration_dialog.AddIntegrationTabs(scriptDialog,
                                          "CombustionMonitor",
                                          DraftRequested,
                                          ProjectManagementOptions,
                                          failOnNoTabs=False)

    scriptDialog.EndTabControl()

    scriptDialog.AddGrid()
    scriptDialog.AddHorizontalSpacerToGrid("HSpacer1", 0, 0)

    submitButton = scriptDialog.AddControlToGrid("SubmitButton",
                                                 "ButtonControl",
                                                 "Submit",
                                                 0,
                                                 1,
                                                 expand=False)
    submitButton.ValueModified.connect(SubmitButtonPressed)

    closeButton = scriptDialog.AddControlToGrid("CloseButton",
                                                "ButtonControl",
                                                "Close",
                                                0,
                                                2,
                                                expand=False)
    # Make sure all the project management connections are closed properly
    closeButton.ValueModified.connect(
        integration_dialog.CloseProjectManagementConnections)
    closeButton.ValueModified.connect(scriptDialog.closeEvent)

    scriptDialog.EndGrid()

    settings = ("DepartmentBox", "CategoryBox", "PoolBox", "SecondaryPoolBox",
                "GroupBox", "PriorityBox", "MachineLimitBox", "IsBlacklistBox",
                "MachineListBox", "LimitGroupBox", "SceneBox", "FramesBox",
                "ChunkSizeBox", "UseDefaultsBox", "SkipExistingBox",
                "InputBox", "OutputBox", "SingleCpuBox", "SubmitSceneBox",
                "VersionBox")
    scriptDialog.LoadSettings(GetSettingsFilename(), settings)
    scriptDialog.EnabledStickySaving(settings, GetSettingsFilename())

    WorkspaceFileChanged(None)

    scriptDialog.ShowDialog(False)
def __main__():
    global scriptDialog
    global settings

    scriptDialog = DeadlineScriptDialog()
    scriptDialog.SetTitle("Script UI Example")

    scriptDialog.AddTabControl("Example Tab Control", 0, 0)

    scriptDialog.AddTabPage("Tab Page 1 : Deadline Controls")
    scriptDialog.AddGroupBox("GroupBox1", "Deadline Job Controls", True)
    scriptDialog.AddGrid()
    scriptDialog.AddControlToGrid("Separator1",
                                  "SeparatorControl",
                                  "Job Description",
                                  0,
                                  0,
                                  colSpan=2)

    scriptDialog.AddControlToGrid(
        "NameLabel", "LabelControl", "Job Name", 1, 0,
        "The name of your job. This is optional, and if left blank, it will default to 'Untitled'.",
        False)
    scriptDialog.AddControlToGrid("NameBox", "TextControl", "Untitled", 1, 1)

    scriptDialog.AddControlToGrid(
        "CommentLabel", "LabelControl", "Comment", 2, 0,
        "A simple description of your job. This is optional and can be left blank.",
        False)
    scriptDialog.AddControlToGrid("CommentBox", "TextControl", "", 2, 1)

    scriptDialog.AddControlToGrid(
        "DepartmentLabel", "LabelControl", "Department", 3, 0,
        "The department you belong to. This is optional and can be left blank.",
        False)
    scriptDialog.AddControlToGrid("DepartmentBox", "TextControl", "", 3, 1)
    scriptDialog.EndGrid()

    scriptDialog.AddGrid()
    scriptDialog.AddControlToGrid("Separator2",
                                  "SeparatorControl",
                                  "Job Options",
                                  0,
                                  0,
                                  colSpan=3)

    scriptDialog.AddControlToGrid(
        "PoolLabel", "LabelControl", "Pool", 1, 0,
        "The pool that your job will be submitted to.", False)
    scriptDialog.AddControlToGrid("PoolBox", "PoolComboControl", "none", 1, 1)

    scriptDialog.AddControlToGrid(
        "SecondaryPoolLabel", "LabelControl", "Secondary Pool", 2, 0,
        "The secondary pool lets you specify a Pool to use if the primary Pool does not have any available Slaves.",
        False)
    scriptDialog.AddControlToGrid("SecondaryPoolBox",
                                  "SecondaryPoolComboControl", "", 2, 1)

    scriptDialog.AddControlToGrid(
        "GroupLabel", "LabelControl", "Group", 3, 0,
        "The group that your job will be submitted to.", False)
    scriptDialog.AddControlToGrid("GroupBox", "GroupComboControl", "none", 3,
                                  1)

    scriptDialog.AddControlToGrid(
        "PriorityLabel", "LabelControl", "Priority", 4, 0,
        "A job can have a numeric priority ranging from 0 to 100, where 0 is the lowest priority and 100 is the highest priority.",
        False)
    scriptDialog.AddRangeControlToGrid(
        "PriorityBox", "RangeControl",
        RepositoryUtils.GetMaximumPriority() / 2, 0,
        RepositoryUtils.GetMaximumPriority(), 0, 1, 4, 1)

    scriptDialog.AddControlToGrid(
        "TaskTimeoutLabel", "LabelControl", "Task Timeout", 5, 0,
        "The number of minutes a slave has to render a task for this job before it requeues it. Specify 0 for no limit.",
        False)
    scriptDialog.AddRangeControlToGrid("TaskTimeoutBox", "RangeControl", 0, 0,
                                       1000000, 0, 1, 5, 1)
    scriptDialog.AddSelectionControlToGrid(
        "AutoTimeoutBox", "CheckBoxControl", False, "Enable Auto Task Timeout",
        5, 2,
        "If the Auto Task Timeout is properly configured in the Repository Options, then enabling this will allow a task timeout to be automatically calculated based on the render times of previous frames for the job. "
    )

    scriptDialog.AddControlToGrid(
        "ConcurrentTasksLabel", "LabelControl", "Concurrent Tasks", 6, 0,
        "The number of tasks that can render concurrently on a single slave. This is useful if the rendering application only uses one thread to render and your slaves have multiple CPUs.",
        False)
    scriptDialog.AddRangeControlToGrid("ConcurrentTasksBox", "RangeControl", 1,
                                       1, 16, 0, 1, 6, 1)
    scriptDialog.AddSelectionControlToGrid(
        "LimitConcurrentTasksBox", "CheckBoxControl", True,
        "Limit Tasks To Slave's Task Limit", 6, 2,
        "If you limit the tasks to a slave's task limit, then by default, the slave won't dequeue more tasks then it has CPUs. This task limit can be overridden for individual slaves by an administrator."
    )

    scriptDialog.AddControlToGrid(
        "MachineLimitLabel", "LabelControl", "Machine Limit", 7, 0,
        "Use the Machine Limit to specify the maximum number of machines that can render your job at one time. Specify 0 for no limit.",
        False)
    scriptDialog.AddRangeControlToGrid("MachineLimitBox", "RangeControl", 0, 0,
                                       1000000, 0, 1, 7, 1)
    scriptDialog.AddSelectionControlToGrid(
        "IsBlacklistBox", "CheckBoxControl", False,
        "Machine List Is A Blacklist", 7, 2,
        "You can force the job to render on specific machines by using a whitelist, or you can avoid specific machines by using a blacklist."
    )

    scriptDialog.AddControlToGrid(
        "MachineListLabel", "LabelControl", "Machine List", 8, 0,
        "The whitelisted or blacklisted list of machines.", False)
    scriptDialog.AddControlToGrid("MachineListBox",
                                  "MachineListControl",
                                  "",
                                  8,
                                  1,
                                  colSpan=2)

    scriptDialog.AddControlToGrid("LimitGroupLabel", "LabelControl", "Limits",
                                  9, 0, "The Limits that your job requires.",
                                  False)
    scriptDialog.AddControlToGrid("LimitGroupBox",
                                  "LimitGroupControl",
                                  "",
                                  9,
                                  1,
                                  colSpan=2)

    scriptDialog.AddControlToGrid(
        "DependencyLabel", "LabelControl", "Dependencies", 10, 0,
        "Specify existing jobs that this job will be dependent on. This job will not start until the specified dependencies finish rendering.",
        False)
    scriptDialog.AddControlToGrid("DependencyBox",
                                  "DependencyControl",
                                  "",
                                  10,
                                  1,
                                  colSpan=2)

    scriptDialog.AddControlToGrid(
        "OnJobCompleteLabel", "LabelControl", "On Job Complete", 11, 0,
        "If desired, you can automatically archive or delete the job when it completes.",
        False)
    scriptDialog.AddControlToGrid("OnJobCompleteBox", "OnJobCompleteControl",
                                  "Nothing", 11, 1)
    scriptDialog.AddSelectionControlToGrid(
        "SubmitSuspendedBox", "CheckBoxControl", False,
        "Submit Job As Suspended", 11, 2,
        "If enabled, the job will submit in the suspended state. This is useful if you don't want the job to start rendering right away. Just resume it from the Monitor when you want it to render."
    )
    scriptDialog.EndGrid()
    scriptDialog.EndGroupBox(False)
    scriptDialog.EndTabPage()

    scriptDialog.AddTabPage("Tab Page 2 : Simple Controls")
    scriptDialog.AddGroupBox("GroupBox2", "Other UI Controls", True)
    scriptDialog.AddGrid()

    scriptDialog.AddControlToGrid("TextLabel",
                                  "LabelControl",
                                  "Enter Text Here",
                                  0,
                                  0,
                                  expand=False)
    scriptDialog.AddControlToGrid("TextBox",
                                  "TextControl",
                                  "Some Text",
                                  0,
                                  1,
                                  colSpan=2)

    scriptDialog.AddControlToGrid("ReadOnlyTextLabel",
                                  "LabelControl",
                                  "Read This Text",
                                  1,
                                  0,
                                  expand=False)
    scriptDialog.AddControlToGrid("ReadOnlyTextBox",
                                  "ReadOnlyTextControl",
                                  "Some Read Only Text",
                                  1,
                                  1,
                                  colSpan=2)

    scriptDialog.AddControlToGrid("MultiLineTextLabel",
                                  "LabelControl",
                                  "Multi Line",
                                  2,
                                  0,
                                  expand=False)
    scriptDialog.AddControlToGrid("MultiLineTextBox",
                                  "MultiLineTextControl",
                                  "One Line\rAnother Line",
                                  2,
                                  1,
                                  "",
                                  colSpan=2)

    scriptDialog.AddControlToGrid("RangeLabel",
                                  "LabelControl",
                                  "Select A Number",
                                  3,
                                  0,
                                  expand=False)
    scriptDialog.AddRangeControlToGrid("RangeBox", "RangeControl", 50.0, 0.0,
                                       100.0, 1, 5.0, 3, 1)
    scriptDialog.AddSelectionControlToGrid("CheckBox", "CheckBoxControl",
                                           False, "This is a Check Box", 3, 2)

    scriptDialog.AddControlToGrid("SliderLabel",
                                  "LabelControl",
                                  "Select A Number",
                                  4,
                                  0,
                                  expand=False)
    scriptDialog.AddRangeControlToGrid("SliderBox",
                                       "SliderControl",
                                       50,
                                       0,
                                       100,
                                       0,
                                       1,
                                       4,
                                       1,
                                       colSpan=2)

    scriptDialog.AddControlToGrid("ComboLabel",
                                  "LabelControl",
                                  "Select An Item",
                                  5,
                                  0,
                                  expand=False)
    scriptDialog.AddComboControlToGrid(
        "ComboBox", "ComboControl", "2008",
        ("2007", "2008", "2009", "2010", "2011"), 5, 1)
    scriptDialog.AddControlToGrid(
        "LinkLabel", "LabelControl",
        "<a href=\"http://www.thinkboxsoftware.com\">www.thinkboxsoftware.com</a>",
        5, 2)

    scriptDialog.AddControlToGrid("ColorLabel",
                                  "LabelControl",
                                  "Select A Color",
                                  6,
                                  0,
                                  expand=False)
    scriptDialog.AddControlToGrid("ColorBox", "ColorControl",
                                  scriptDialog.CreateColorObject(255, 0, 0), 6,
                                  1)

    scriptDialog.AddControlToGrid("ProgressLabel",
                                  "LabelControl",
                                  "Progress",
                                  7,
                                  0,
                                  expand=False)
    scriptDialog.AddRangeControlToGrid("ProgressBox", "ProgressBarControl", 1,
                                       1, 100, 0, 0, 7, 1)
    progressButton = scriptDialog.AddControlToGrid("ProgressButton",
                                                   "ButtonControl",
                                                   "Increment", 7, 2)
    progressButton.ValueModified.connect(ProgressButtonPressed)
    scriptDialog.EndGrid()

    scriptDialog.AddGrid()
    scriptDialog.AddRadioControlToGrid("RadioOne", "RadioControl", True,
                                       "Radio One", "RadioGroup", 0, 0)
    scriptDialog.AddRadioControlToGrid("RadioTwo", "RadioControl", False,
                                       "Radio Two", "RadioGroup", 0, 1)
    scriptDialog.AddRadioControlToGrid("RadioThree", "RadioControl", False,
                                       "Radio Three", "RadioGroup", 0, 2)
    scriptDialog.AddRadioControlToGrid("RadioFour", "RadioControl", False,
                                       "Radio Four", "RadioGroup", 0, 3)
    scriptDialog.EndGrid()
    scriptDialog.EndGroupBox(False)
    scriptDialog.EndTabPage()

    scriptDialog.AddTabPage("Tab Page 3 : Browsers")
    scriptDialog.AddGrid()
    scriptDialog.AddControlToGrid("Separator3",
                                  "SeparatorControl",
                                  "Browsers",
                                  0,
                                  0,
                                  colSpan=2)

    scriptDialog.AddControlToGrid("FolderLabel",
                                  "LabelControl",
                                  "Select Folder",
                                  1,
                                  0,
                                  expand=False)
    scriptDialog.AddSelectionControlToGrid("FolderBox", "FolderBrowserControl",
                                           "", "", 1, 1)

    scriptDialog.AddControlToGrid("FileLabel",
                                  "LabelControl",
                                  "Select File",
                                  2,
                                  0,
                                  expand=False)
    # File Filter demonstrates how to control the file formats to be selected - Text or All Files
    scriptDialog.AddSelectionControlToGrid(
        "FileBox", "FileBrowserControl", "",
        "Text Files (*.txt);;All Files (*.*)", 2, 1)

    scriptDialog.AddControlToGrid("SaveFileLabel",
                                  "LabelControl",
                                  "Save File",
                                  3,
                                  0,
                                  expand=False)
    # File Filter demonstrates how to control the file formats to be selected - Text or All Files
    scriptDialog.AddSelectionControlToGrid(
        "SaveFileBox", "FileSaverControl", "",
        "Text Files (*.txt);;All Files (*.*)", 3, 1)

    scriptDialog.AddControlToGrid("MultiFileLabel",
                                  "LabelControl",
                                  "Multi File",
                                  4,
                                  0,
                                  expand=False)
    scriptDialog.AddSelectionControlToGrid("MultiFileBox",
                                           "MultiFileBrowserControl", "",
                                           "All Files (*.*)", 4, 1)

    scriptDialog.AddControlToGrid("MultiLineFolderLabel",
                                  "LabelControl",
                                  "Multi Line Folder",
                                  5,
                                  0,
                                  expand=False)
    scriptDialog.AddSelectionControlToGrid(
        "MultiLineFolderBox", "MultiLineMultiFolderBrowserControl", "", "", 5,
        1)

    scriptDialog.AddControlToGrid("MultiLineFileLabel",
                                  "LabelControl",
                                  "Multi Line File",
                                  6,
                                  0,
                                  expand=False)
    scriptDialog.AddSelectionControlToGrid("MultiLineFileBox",
                                           "MultiLineMultiFileBrowserControl",
                                           "", "All Files (*.*)", 6, 1)
    scriptDialog.EndGrid()

    scriptDialog.EndTabPage()
    scriptDialog.EndTabControl()

    scriptDialog.AddGrid()
    dialogButton = scriptDialog.AddControlToGrid("DialogButton",
                                                 "ButtonControl",
                                                 "Dialog",
                                                 0,
                                                 0,
                                                 expand=False)
    dialogButton.ValueModified.connect(DialogButtonPressed)
    popupButton = scriptDialog.AddControlToGrid("PopupButton",
                                                "ButtonControl",
                                                "Popup",
                                                0,
                                                1,
                                                expand=False)
    popupButton.ValueModified.connect(PopupButtonPressed)
    closeButton = scriptDialog.AddControlToGrid("CloseButton",
                                                "ButtonControl",
                                                "Close",
                                                0,
                                                2,
                                                expand=False)
    closeButton.ValueModified.connect(CloseButtonPressed)
    scriptDialog.AddHorizontalSpacerToGrid("DummySpacer1", 0, 3)
    scriptDialog.EndGrid()

    scriptDialog.ShowDialog(True)
Example #5
0
def __main__( *args ):
    global scriptDialog
    global settings
    global ProjectManagementOptions
    global DraftRequested
    global integration_dialog
    global jobOptions_dialog
    
    scriptDialog = DeadlineScriptDialog()

    scriptDialog.SetTitle( "Submit Unreal Engine Job To Deadline" )
    scriptDialog.SetIcon( scriptDialog.GetIcon( "UnrealEngine" ) )
    
    scriptDialog.AddTabControl( "Tabs", 0, 0 )
    
    scriptDialog.AddTabPage( "Job Options" )
    
    jobOptions_dialog = JobOptionsUI.JobOptionsDialog( parentAppName = "UnrealEngineMonitor" )
    
    scriptDialog.AddScriptControl( "JobOptionsDialog", jobOptions_dialog, "" )
    
    scriptDialog.AddGrid()
    scriptDialog.AddControlToGrid( "Separator1", "SeparatorControl", "Unreal Engine Options", 0, 0, colSpan=4 )

    scriptDialog.AddControlToGrid( "ProjectLabel", "LabelControl", "Project File", 1, 0, "The project to be rendered.", False )
    scriptDialog.AddSelectionControlToGrid( "ProjectBox", "FileBrowserControl", "", "Unreal Project Files (*.uproject);;All Files (*)", 1, 1, colSpan=3 )
    
    scriptDialog.AddControlToGrid( "MapLabel", "LabelControl", "Game Map", 2, 0, "The path to the map that will be loaded for the render.", False )
    scriptDialog.AddControlToGrid( "MapBox", "TextControl", "", 2, 1, colSpan=3 )
    
    scriptDialog.AddControlToGrid( "LevelSequenceLabel", "LabelControl", "Level Sequence", 3, 0, "The path to the level sequence that will be rendered out. eg. /Game/PathToSequence/SequenceName", False )
    scriptDialog.AddControlToGrid( "LevelSequenceBox", "TextControl", "", 3, 1, colSpan=3 )
    
    scriptDialog.AddControlToGrid( "FramesLabel", "LabelControl", "Frame List", 4, 0, "The list of frames to render.", False )
    scriptDialog.AddControlToGrid( "FramesBox", "TextControl", "", 4, 1, colSpan=3 )
    
    scriptDialog.AddControlToGrid( "ChunkSizeLabel", "LabelControl", "Frames Per Task", 5, 0, "This is the number of frames that will be rendered at a time for each job task.", False )
    scriptDialog.AddRangeControlToGrid( "ChunkSizeBox", "RangeControl", 1, 1, 1000000, 0, 1, 5, 1 )
    
    scriptDialog.AddControlToGrid( "VersionLabel", "LabelControl", "Version", 5, 2 , "The version of Unreal Engine to render with.", False)
    versionBox = scriptDialog.AddComboControlToGrid( "VersionBox", "ComboControl", "4", ( "4", ), 5, 3 )
    
    scriptDialog.EndGrid()
    scriptDialog.EndTabPage()
    
    scriptDialog.AddTabPage("Output Options")
    scriptDialog.AddGrid()
    scriptDialog.AddControlToGrid( "Separator2", "SeparatorControl", "Output Options", 0, 0, colSpan=4 )
    
    scriptDialog.AddControlToGrid( "OutputDirLabel", "LabelControl", "Output Directory", 1, 0,  "Destination folder for rendered images. Defaults to Project/Saved/Screenshots if left blank.", False )
    scriptDialog.AddSelectionControlToGrid( "OutputDirBox", "FolderBrowserControl", "", "", 1, 1, colSpan=3 )
    
    scriptDialog.AddControlToGrid( "OutputNameLabel", "LabelControl", "Output File Naming", 2, 0, "Sets the naming format for the output files. Defaults to project.{frame}. Available Tokens {fps}, {frame}, {width}, {height}, {world}, {quality}, {material}", False )
    scriptDialog.AddControlToGrid( "OutputNameBox", "TextControl", "", 2, 1, colSpan=3 )
    
    scriptDialog.AddControlToGrid( "OutputFormatLabel", "LabelControl", "Output Format", 3, 0, "The format for the output filename.", False)
    formatBox = scriptDialog.AddComboControlToGrid( "OutputFormatBox", "ComboControl", "PNG", ("JPG","BMP","PNG","AVI","CustomRenderPasses"), 3, 1 )
    formatBox.ValueModified.connect( OutputFormatModified )
    
    overrideResolutionBox = scriptDialog.AddSelectionControlToGrid( "OverrideResolutionBox", "CheckBoxControl", False, "Override Resolution", 4, 0, "Enable to override render resolution.", True )
    overrideResolutionBox.ValueModified.connect(OverrideResolutionChanged)
    
    scriptDialog.AddControlToGrid( "WidthLabel", "LabelControl", "Width", 5, 0, "Sets the output width in pixels." )
    scriptDialog.AddRangeControlToGrid( "WidthBox", "RangeControl", 1920, 1, 32768, 0, 1, 5, 1 )
    
    scriptDialog.AddControlToGrid( "HeightLabel", "LabelControl", "Height", 5, 2, "Sets the output height in pixels." )
    scriptDialog.AddRangeControlToGrid( "HeightBox", "RangeControl", 1080, 1, 32768, 0, 1, 5, 3 )
    
    scriptDialog.AddControlToGrid( "FrameRateLabel", "LabelControl", "Frame Rate", 6, 0, "Sets the frame rate of the output." )
    scriptDialog.AddRangeControlToGrid( "FrameRateBox", "RangeControl", 30, 1, 120, 0, 1, 6, 1 )
    
    scriptDialog.AddControlToGrid( "MovieQualityLabel", "LabelControl", "Render Quality", 6, 2, "Sets the compression quality. Expressed in a percentage." )
    scriptDialog.AddRangeControlToGrid( "MovieQualityBox", "RangeControl", 75, 1, 100, 0, 1, 6, 3 )
        
    scriptDialog.AddControlToGrid( "DelayBeforeLabel", "LabelControl", "Delay Before Warmup", 7, 0, "Number of frames to run the scene before playing the sequence. This will not play out in real-time." )
    scriptDialog.AddRangeControlToGrid( "DelayBeforeBox", "RangeControl", 0, 0, 32768, 0, 1, 7, 1 )
    
    scriptDialog.AddSelectionControlToGrid( "CinematicModeBox", "CheckBoxControl", True, "Cinematic Mode", 7, 2, "Hides Player Character and disables Player Character Movement. Also disables HUD.", True )   
    scriptDialog.AddSelectionControlToGrid( "HideMessagesBox", "CheckBoxControl", True, "Hide Onscreen Messages", 7, 3, "Hides on screen messages like \"Rebuild Lighting\" or \"Pring String\" outputs.", True )
    
    scriptDialog.AddSelectionControlToGrid( "EnableVSyncBox", "CheckBoxControl", True, "Enable VSync", 8, 0, "Enable VSync for batch rendering.", True )
    scriptDialog.AddSelectionControlToGrid( "DisableTextureStreamingBox", "CheckBoxControl", True, "Disable Texture Streaming", 8, 1, "Disable Texture streaming while rendering. Will take longer to render, but worth it for final renders.", True )
    
    scriptDialog.AddControlToGrid( "CustomRenderPassesLabel", "LabelControl", "Custom Render Passes", 9, 0, "" )
    
    renderPasses = ( "AmbientOcclusion", "BaseColor", "CustomDepth", "CustomDepthWorldUnits", "CustomStencil", "FinalImage", "MaterialAO", "Metallic", "Opacity", "PostTonemapHDRColor",
    "Roughness", "SceneColor", "SceneDepth", "SceneDepthWorldUnits", "SeparateTranslucencyA", "SeparateTranslucencyRGB", "ShadingModel", "Specular", "SubsurfaceColor", "WorldNormal" )

    scriptDialog.AddComboControlToGrid( "CustomRenderPassesBox", "MultiSelectListControl", "AmbientOcclusion", renderPasses, 9, 1, colSpan=3 )
    
    captureHDRBox = scriptDialog.AddSelectionControlToGrid( "CaptureHDRBox", "CheckBoxControl", True, "Capture Frames in HDR", 10, 0, "Renders with HDR in the .exr format.", True )  
    captureHDRBox.ValueModified.connect( CaptureHDRChanged )
    
    scriptDialog.AddControlToGrid( "HDRCompressionQualityLabel", "LabelControl", "HDR Compression Quality", 11, 0, "Compression Quality for HDR Frames (0 for no compression, 1 for default compression which can be slow)." )
    scriptDialog.AddRangeControlToGrid( "HDRCompressionQualityBox", "RangeControl", 0, 0, 1, 0, 1, 11, 1 )
    
    scriptDialog.AddControlToGrid( "CaptureGamutLabel", "LabelControl", "Capture Gamut", 11, 2, "" )
    scriptDialog.AddComboControlToGrid( "CaptureGamutBox", "ComboControl", "HCGM_Rec709", ( "HCGM_Rec709", "HCGM_P3DCI", "HCGM_Rec2020", "HCGM_ACES", "HCGM_ACEScg", "HCGM_MAX" ), 11, 3 )
    
    scriptDialog.AddControlToGrid( "PostProcessingLabel", "LabelControl", "Post Processing Material", 12, 0, "Custom Post Processing Material to use for rendering.", False )
    scriptDialog.AddControlToGrid( "PostProcessingBox", "TextControl", "", 12, 1, colSpan=3 )
    
    scriptDialog.EndGrid()
    scriptDialog.EndTabPage()
    
    integration_dialog = IntegrationUI.IntegrationDialog()
    integration_dialog.AddIntegrationTabs( scriptDialog, "UnrealEngineMonitor", DraftRequested, ProjectManagementOptions, failOnNoTabs=False )
    
    scriptDialog.EndTabControl()
    
    scriptDialog.AddGrid()
    scriptDialog.AddHorizontalSpacerToGrid( "HSpacer1", 0, 0 )
    submitButton = scriptDialog.AddControlToGrid( "SubmitButton", "ButtonControl", "Submit", 0, 1, expand=False )
    submitButton.ValueModified.connect(SubmitButtonPressed)
    closeButton = scriptDialog.AddControlToGrid( "CloseButton", "ButtonControl", "Close", 0, 2, expand=False )
    # Make sure all the project management connections are closed properly
    closeButton.ValueModified.connect(integration_dialog.CloseProjectManagementConnections)
    closeButton.ValueModified.connect(scriptDialog.closeEvent)
    closeButton.ValueModified.connect(jobOptions_dialog.closeEvent)
    scriptDialog.EndGrid()
    
    settings = ( "ProjectBox", "MapBox", "LevelSequenceBox", "FramesBox", "ChunkSizeBox", "VersionBox", "OutputDirBox",
    "OutputNameBox", "OutputFormatBox", "OverrideResolutionBox", "WidthBox", "HeightBox", "FrameRateBox", "MovieQualityBox",
    "DelayBeforeBox", "CinematicModeBox", "HideMessagesBox", "EnableVSyncBox", "DisableTextureStreamingBox", "CustomRenderPassesBox",
    "CaptureHDRBox", "HDRCompressionQualityBox", "CaptureGamutBox", "PostProcessingBox" )
    
    scriptDialog.LoadSettings( GetSettingsFilename(), settings )
    scriptDialog.EnabledStickySaving( settings, GetSettingsFilename() )
    
    OverrideResolutionChanged( None )
    OutputFormatModified( None )
    
    scriptDialog.ShowDialog( False )
Example #6
0
def __main__():
    global scriptDialog
    global settings

    dialogWidth = 600
    labelWidth = 150
    dialogHeight = 666
    controlWidth = 156

    tabWidth = dialogWidth - 16
    tabHeight = 616

    scriptDialog = DeadlineScriptDialog()
    scriptDialog.SetTitle("Submit TVPaint Job To Deadline")
    scriptDialog.SetIcon(
        Path.Combine(RepositoryUtils.GetRootDirectory(),
                     "plugins/TVPaint/TVPaint.ico"))

    scriptDialog.AddTabControl("Job Options Tabs", dialogWidth + 8, tabHeight)

    scriptDialog.AddTabPage("Job Options")
    scriptDialog.AddGrid()
    scriptDialog.AddControlToGrid("Separator1",
                                  "SeparatorControl",
                                  "Job Description",
                                  0,
                                  0,
                                  colSpan=2)

    scriptDialog.AddControlToGrid(
        "NameLabel", "LabelControl", "Job Name", 1, 0,
        "The name of your job. This is optional, and if left blank, it will default to 'Untitled'.",
        False)
    scriptDialog.AddControlToGrid("NameBox", "TextControl", "Untitled", 1, 1)

    scriptDialog.AddControlToGrid(
        "CommentLabel", "LabelControl", "Comment", 2, 0,
        "A simple description of your job. This is optional and can be left blank.",
        False)
    scriptDialog.AddControlToGrid("CommentBox", "TextControl", "", 2, 1)

    scriptDialog.AddControlToGrid(
        "DepartmentLabel", "LabelControl", "Department", 3, 0,
        "The department you belong to. This is optional and can be left blank.",
        False)
    scriptDialog.AddControlToGrid("DepartmentBox", "TextControl", "", 3, 1)
    scriptDialog.EndGrid()

    scriptDialog.AddGrid()
    scriptDialog.AddControlToGrid("Separator2",
                                  "SeparatorControl",
                                  "Job Options",
                                  0,
                                  0,
                                  colSpan=3)

    scriptDialog.AddControlToGrid(
        "PoolLabel", "LabelControl", "Pool", 1, 0,
        "The pool that your job will be submitted to.", False)
    scriptDialog.AddControlToGrid("PoolBox", "PoolComboControl", "none", 1, 1)

    scriptDialog.AddControlToGrid(
        "SecondaryPoolLabel", "LabelControl", "Secondary Pool", 2, 0,
        "The secondary pool lets you specify a Pool to use if the primary Pool does not have any available Slaves.",
        False)
    scriptDialog.AddControlToGrid("SecondaryPoolBox",
                                  "SecondaryPoolComboControl", "", 2, 1)

    scriptDialog.AddControlToGrid(
        "GroupLabel", "LabelControl", "Group", 3, 0,
        "The group that your job will be submitted to.", False)
    scriptDialog.AddControlToGrid("GroupBox", "GroupComboControl", "none", 3,
                                  1)

    scriptDialog.AddControlToGrid(
        "PriorityLabel", "LabelControl", "Priority", 4, 0,
        "A job can have a numeric priority ranging from 0 to 100, where 0 is the lowest priority and 100 is the highest priority.",
        False)
    scriptDialog.AddRangeControlToGrid(
        "PriorityBox", "RangeControl",
        RepositoryUtils.GetMaximumPriority() / 2, 0,
        RepositoryUtils.GetMaximumPriority(), 0, 1, 4, 1)

    scriptDialog.AddControlToGrid(
        "TaskTimeoutLabel", "LabelControl", "Task Timeout", 5, 0,
        "The number of minutes a slave has to render a task for this job before it requeues it. Specify 0 for no limit.",
        False)
    scriptDialog.AddRangeControlToGrid("TaskTimeoutBox", "RangeControl", 0, 0,
                                       1000000, 0, 1, 5, 1)
    scriptDialog.AddSelectionControlToGrid(
        "AutoTimeoutBox", "CheckBoxControl", False, "Enable Auto Task Timeout",
        5, 2,
        "If the Auto Task Timeout is properly configured in the Repository Options, then enabling this will allow a task timeout to be automatically calculated based on the render times of previous frames for the job. "
    )

    scriptDialog.AddControlToGrid(
        "ConcurrentTasksLabel", "LabelControl", "Concurrent Tasks", 6, 0,
        "The number of tasks that can render concurrently on a single slave. This is useful if the rendering application only uses one thread to render and your slaves have multiple CPUs.",
        False)
    scriptDialog.AddRangeControlToGrid("ConcurrentTasksBox", "RangeControl", 1,
                                       1, 16, 0, 1, 6, 1)
    scriptDialog.AddSelectionControlToGrid(
        "LimitConcurrentTasksBox", "CheckBoxControl", True,
        "Limit Tasks To Slave's Task Limit", 6, 2,
        "If you limit the tasks to a slave's task limit, then by default, the slave won't dequeue more tasks then it has CPUs. This task limit can be overridden for individual slaves by an administrator."
    )

    scriptDialog.AddControlToGrid("MachineLimitLabel", "LabelControl",
                                  "Machine Limit", 7, 0, "", False)
    scriptDialog.AddRangeControlToGrid("MachineLimitBox", "RangeControl", 0, 0,
                                       1000000, 0, 1, 7, 1)
    scriptDialog.AddSelectionControlToGrid("IsBlacklistBox", "CheckBoxControl",
                                           False,
                                           "Machine List Is A Blacklist", 7, 2,
                                           "")

    scriptDialog.AddControlToGrid(
        "MachineListLabel", "LabelControl", "Machine List", 8, 0,
        "Use the Machine Limit to specify the maximum number of machines that can render your job at one time. Specify 0 for no limit.",
        False)
    scriptDialog.AddControlToGrid("MachineListBox",
                                  "MachineListControl",
                                  "",
                                  8,
                                  1,
                                  colSpan=2)

    scriptDialog.AddControlToGrid("LimitGroupLabel", "LabelControl", "Limits",
                                  9, 0, "The Limits that your job requires.",
                                  False)
    scriptDialog.AddControlToGrid("LimitGroupBox",
                                  "LimitGroupControl",
                                  "",
                                  9,
                                  1,
                                  colSpan=2)

    scriptDialog.AddControlToGrid(
        "DependencyLabel", "LabelControl", "Dependencies", 10, 0,
        "Specify existing jobs that this job will be dependent on. This job will not start until the specified dependencies finish rendering. ",
        False)
    scriptDialog.AddControlToGrid("DependencyBox",
                                  "DependencyControl",
                                  "",
                                  10,
                                  1,
                                  colSpan=2)

    scriptDialog.AddControlToGrid(
        "OnJobCompleteLabel", "LabelControl", "On Job Complete", 11, 0,
        "If desired, you can automatically archive or delete the job when it completes. ",
        False)
    scriptDialog.AddControlToGrid("OnJobCompleteBox", "OnJobCompleteControl",
                                  "Nothing", 11, 1)
    scriptDialog.AddSelectionControlToGrid(
        "SubmitSuspendedBox", "CheckBoxControl", False,
        "Submit Job As Suspended", 11, 2,
        "If enabled, the job will submit in the suspended state. This is useful if you don't want the job to start rendering right away. Just resume it from the Monitor when you want it to render. "
    )
    scriptDialog.EndGrid()

    scriptDialog.AddGrid()
    scriptDialog.AddControlToGrid("Separator3",
                                  "SeparatorControl",
                                  "TVPaint Options",
                                  0,
                                  0,
                                  colSpan=6)

    scriptDialog.AddControlToGrid(
        "Job Mode", "LabelControl", "Job Mode", 1, 0,
        "The different TVPaint job modes supported by Deadline.", False)
    jobModeBox = scriptDialog.AddComboControlToGrid(
        "JobModeBox",
        "ComboControl",
        "Sequence/Animation", ("Sequence/Animation", "Single Image",
                               "Script Job", "Export Layers", "Single Layer"),
        1,
        1,
        colSpan=4)
    jobModeBox.ValueModified.connect(JobModeBoxChanged)

    scriptDialog.AddControlToGrid(
        "AlphaSaveModeLabel", "LabelControl", "Alpha Save Mode", 2, 0,
        "The different Alpha Save Mode's supported by TVPaint.", False)
    scriptDialog.AddComboControlToGrid(
        "AlphaSaveModeBox",
        "ComboControl",
        "NoPreMultiply",
        ("NoPreMultiply", "PreMultiply", "NoAlpha", "AlphaOnly"),
        2,
        1,
        colSpan=4)

    scriptDialog.AddControlToGrid("SceneLabel", "LabelControl", "TVPaint File",
                                  3, 0,
                                  "The TVPaint scene file to be rendered.",
                                  False)
    scriptDialog.AddSelectionControlToGrid(
        "SceneBox",
        "FileBrowserControl",
        "",
        "TVPaint Files (*.tvpp);;All Files (*)",
        3,
        1,
        colSpan=5)

    scriptDialog.AddControlToGrid("OutputLabel", "LabelControl", "Output File",
                                  4, 0, "The output path to render to.", False)
    outputBox = scriptDialog.AddSelectionControlToGrid(
        "OutputBox",
        "FileSaverControl",
        "",
        "QUICKTIME (*.mov);;AVI (*.avi);;BMP (*.bmp);;CINEON (*.cin);;DEEP (*.dip);;DPX (*.dpx);;FLI (*.fli);;GIF (*.gif);;ILBM (*.iff);;JPEG (*.jpg);;PCX (*.pcx);;PNG (*.png);;PSD (*.psd);;SGI (*.rgb);;SOFTIMAGE (*.pic);;SUN (*.ras);;TGA (*.tga);;TIFF (*.tiff);;VPB (*.vpb)",
        4,
        1,
        colSpan=5)
    outputBox.ValueModified.connect(OutputBoxChanged)

    scriptDialog.AddControlToGrid("ScriptLabel", "LabelControl", "Script File",
                                  5, 0, "The render script to use.", False)
    scriptDialog.AddSelectionControlToGrid(
        "ScriptBox",
        "FileBrowserControl",
        "",
        "George Scripts (*.grg);;All Files (*)",
        5,
        1,
        colSpan=5)

    scriptDialog.AddControlToGrid("LayerLabel", "LabelControl", "Layer Name",
                                  6, 0, "The layer to render.", False)
    scriptDialog.AddControlToGrid("LayerBox",
                                  "TextControl",
                                  "",
                                  6,
                                  1,
                                  colSpan=5)

    scriptDialog.AddControlToGrid("FramesLabel", "LabelControl", "Frame List",
                                  7, 0, "The list of frames to render.", False)
    scriptDialog.AddControlToGrid("FramesBox",
                                  "TextControl",
                                  "",
                                  7,
                                  1,
                                  colSpan=5)

    scriptDialog.AddControlToGrid(
        "ChunkSizeLabel", "LabelControl", "Frames Per Task", 8, 0,
        "This is the number of frames that will be rendered at a time for each job task. ",
        False)
    scriptDialog.AddRangeControlToGrid("ChunkSizeBox",
                                       "RangeControl",
                                       1,
                                       1,
                                       1000000,
                                       0,
                                       1,
                                       8,
                                       1,
                                       colSpan=4)

    scriptDialog.AddSelectionControlToGrid(
        "SubmitSceneBox", "CheckBoxControl", False,
        "Submit TVPaint Scene File With Job", 8, 5,
        "If this option is enabled, the scene file will be submitted with the job, and then copied locally to the slave machine during rendering.",
        "")

    scriptDialog.AddControlToGrid(
        "FrameNumberLabel", "LabelControl", "Frame Number", 9, 0,
        "This is the index number of the frame that will be rendered for the job task. ",
        False)
    scriptDialog.AddRangeControlToGrid("FrameNumberBox",
                                       "RangeControl",
                                       0,
                                       0,
                                       1000000,
                                       0,
                                       1,
                                       9,
                                       1,
                                       colSpan=4)
    scriptDialog.AddSelectionControlToGrid(
        "UseCameraBox", "CheckBoxControl", False, "Use Scene Camera", 9, 5,
        "If this option is enabled, TVPaint only renders what's in the camera's frame.",
        "")

    scriptDialog.AddControlToGrid(
        "BuildLabel", "LabelControl", "Build To Force", 10, 0,
        "You can force 32 or 64 bit rendering with this option.", False)
    scriptDialog.AddComboControlToGrid("BuildBox",
                                       "ComboControl",
                                       "None", ("None", "32bit", "64bit"),
                                       10,
                                       1,
                                       colSpan=3)
    scriptDialog.AddControlToGrid("VersionLabel", "LabelControl", "Version",
                                  10, 4,
                                  "The version of TVPaint to render with.",
                                  False)
    versionBox = scriptDialog.AddComboControlToGrid("VersionBox",
                                                    "ComboControl", "11",
                                                    ("11", ), 10, 5)
    scriptDialog.EndGrid()

    scriptDialog.EndTabPage()

    scriptDialog.AddTabPage("Integration")
    scriptDialog.AddGrid()
    scriptDialog.AddControlToGrid("Separator5",
                                  "SeparatorControl",
                                  "Project Management",
                                  0,
                                  0,
                                  colSpan=4)

    scriptDialog.AddControlToGrid("IntegrationLabel", "LabelControl",
                                  "Project Management", 1, 0, "", False)
    IntegrationTypeBox = scriptDialog.AddComboControlToGrid(
        "IntegrationTypeBox",
        "ComboControl",
        "Shotgun",
        IntegrationOptions,
        1,
        1,
        expand=False)
    IntegrationTypeBox.ValueModified.connect(IntegrationTypeBoxChanged)
    connectButton = scriptDialog.AddControlToGrid("IntegrationConnectButton",
                                                  "ButtonControl",
                                                  "Connect...",
                                                  1,
                                                  2,
                                                  expand=False)
    connectButton.ValueModified.connect(ConnectButtonPressed)
    createVersionBox = scriptDialog.AddSelectionControlToGrid(
        "CreateVersionBox", "CheckBoxControl", False, "Create new version", 1,
        3,
        "If enabled, Deadline will connect to Shotgun/FTrack and create a new version for this job."
    )
    createVersionBox.ValueModified.connect(SubmitShotgunChanged)
    scriptDialog.SetEnabled("CreateVersionBox", False)

    scriptDialog.AddControlToGrid("IntegrationVersionLabel", "LabelControl",
                                  "Version", 2, 0,
                                  "The Shotgun/FTrack version name.", False)
    scriptDialog.AddControlToGrid("IntegrationVersionBox",
                                  "TextControl",
                                  "",
                                  2,
                                  1,
                                  colSpan=3)

    scriptDialog.AddControlToGrid("IntegrationDescriptionLabel",
                                  "LabelControl", "Description", 3, 0,
                                  "The Shotgun/FTrack version description.",
                                  False)
    scriptDialog.AddControlToGrid("IntegrationDescriptionBox",
                                  "TextControl",
                                  "",
                                  3,
                                  1,
                                  colSpan=3)

    scriptDialog.AddControlToGrid(
        "IntegrationEntityInfoLabel", "LabelControl", "Selected Entity", 4, 0,
        "Information about the Shotgun/FTrack entity that the version will be created for.",
        False)
    entityInfoBox = scriptDialog.AddControlToGrid("IntegrationEntityInfoBox",
                                                  "MultiLineTextControl",
                                                  "",
                                                  4,
                                                  1,
                                                  colSpan=3)
    entityInfoBox.ReadOnly = True

    scriptDialog.AddControlToGrid(
        "IntegrationDraftOptionsLabel", "LabelControl", "Draft Options", 5, 0,
        "Information about the Shotgun/FTrack entity that the version will be created for.",
        False)
    scriptDialog.AddSelectionControlToGrid(
        "IntegrationUploadMovieBox", "CheckBoxControl", False,
        "Create/Upload Movie", 5, 1,
        "If this option is enabled, a draft job will be created to upload a movie to shotgun."
    )
    scriptDialog.AddSelectionControlToGrid(
        "IntegrationUploadFilmStripBox", "CheckBoxControl", False,
        "Create/Upload Film Strip", 5, 2,
        "If this option is enabled, a draft job will be created to upload a filmstrip to shotgun."
    )
    scriptDialog.EndGrid()

    # Add Draft UI
    AddDraftUI(scriptDialog)

    SubmitShotgunChanged(None)
    SubmitDraftChanged(None)
    scriptDialog.EndTabPage()

    scriptDialog.EndTabControl()

    scriptDialog.AddGrid()
    scriptDialog.AddHorizontalSpacerToGrid("HSpacer1", 0, 0)
    submitButton = scriptDialog.AddControlToGrid("SubmitButton",
                                                 "ButtonControl",
                                                 "Submit",
                                                 0,
                                                 1,
                                                 expand=False)
    submitButton.ValueModified.connect(SubmitButtonPressed)
    closeButton = scriptDialog.AddControlToGrid("CloseButton",
                                                "ButtonControl",
                                                "Close",
                                                0,
                                                2,
                                                expand=False)
    closeButton.ValueModified.connect(scriptDialog.closeEvent)
    scriptDialog.EndGrid()

    settings = ("DepartmentBox", "CategoryBox", "PoolBox", "SecondaryPoolBox",
                "GroupBox", "PriorityBox", "MachineLimitBox", "IsBlacklistBox",
                "MachineListBox", "LimitGroupBox", "SceneBox", "FramesBox",
                "FrameNumberBox", "ChunkSizeBox", "VersionBox",
                "SubmitSceneBox", "UseCameraBox", "OutputBox", "BuildBox",
                "JobModeBox", "AlphaSaveModeBox", "SubmitScriptBox",
                "ScriptBox")
    scriptDialog.LoadSettings(GetSettingsFilename(), settings)
    scriptDialog.EnabledStickySaving(settings, GetSettingsFilename())

    LoadIntegrationSettings()
    updateDisplay()
    scriptDialog.SetValue("CreateVersionBox", False)

    OutputBoxChanged(None)
    JobModeBoxChanged(None)

    scriptDialog.ShowDialog(False)
def __main__(*args):
    global scriptDialog
    global settings

    scriptDialog = DeadlineScriptDialog()

    scriptDialog.SetTitle("Submit CSi SAP2000 Job To Deadline")
    scriptDialog.SetIcon(scriptDialog.GetIcon('CSiSAP2000'))

    scriptDialog.AddTabControl("Tabs", 0, 0)

    scriptDialog.AddTabPage("Job Options")
    scriptDialog.AddGrid()
    scriptDialog.AddControlToGrid("Separator1",
                                  "SeparatorControl",
                                  "Job Description",
                                  0,
                                  0,
                                  colSpan=3)

    scriptDialog.AddControlToGrid(
        "NameLabel", "LabelControl", "Job Name", 1, 0,
        "The name of your job. This is optional, and if left blank, it will default to 'No Job Name'.",
        False)
    scriptDialog.AddControlToGrid("NameBox",
                                  "TextControl",
                                  "No Job Name",
                                  1,
                                  1,
                                  colSpan=2)

    scriptDialog.AddControlToGrid(
        "CommentLabel", "LabelControl", "Comment", 2, 0,
        "A simple description of your job. This is optional and can be left blank.",
        False)
    scriptDialog.AddControlToGrid("CommentBox",
                                  "TextControl",
                                  "",
                                  2,
                                  1,
                                  colSpan=2)

    scriptDialog.AddControlToGrid(
        "DepartmentLabel", "LabelControl", "Department", 3, 0,
        "The department you belong to. This is optional and can be left blank.",
        False)
    scriptDialog.AddControlToGrid("DepartmentBox",
                                  "TextControl",
                                  "",
                                  3,
                                  1,
                                  colSpan=2)
    scriptDialog.EndGrid()

    scriptDialog.AddGrid()
    scriptDialog.AddControlToGrid("Separator2",
                                  "SeparatorControl",
                                  "Job Options",
                                  0,
                                  0,
                                  colSpan=3)

    scriptDialog.AddControlToGrid(
        "PoolLabel", "LabelControl", "Pool", 1, 0,
        "The pool that your job will be submitted to.", False)
    scriptDialog.AddControlToGrid("PoolBox", "PoolComboControl", "none", 1, 1)

    scriptDialog.AddControlToGrid(
        "SecondaryPoolLabel", "LabelControl", "Secondary Pool", 2, 0,
        "The secondary pool lets you specify a Pool to use if the primary Pool does not have any available Slaves.",
        False)
    scriptDialog.AddControlToGrid("SecondaryPoolBox",
                                  "SecondaryPoolComboControl", "", 2, 1)

    scriptDialog.AddControlToGrid(
        "GroupLabel", "LabelControl", "Group", 3, 0,
        "The group that your job will be submitted to.", False)
    scriptDialog.AddControlToGrid("GroupBox", "GroupComboControl", "none", 3,
                                  1)

    scriptDialog.AddControlToGrid(
        "PriorityLabel", "LabelControl", "Priority", 4, 0,
        "A job can have a numeric priority ranging from 0 to 100, where 0 is the lowest priority and 100 is the highest priority.",
        False)
    scriptDialog.AddRangeControlToGrid(
        "PriorityBox", "RangeControl",
        RepositoryUtils.GetMaximumPriority() / 2, 0,
        RepositoryUtils.GetMaximumPriority(), 0, 1, 4, 1)

    scriptDialog.AddControlToGrid(
        "TaskTimeoutLabel", "LabelControl", "Task Timeout", 5, 0,
        "The number of minutes a slave has to process a task for this job before it requeues it. Specify 0 for no limit.",
        False)
    scriptDialog.AddRangeControlToGrid("TaskTimeoutBox", "RangeControl", 0, 0,
                                       1000000, 0, 1, 5, 1)
    scriptDialog.AddSelectionControlToGrid(
        "AutoTimeoutBox", "CheckBoxControl", False, "Enable Auto Task Timeout",
        5, 2,
        "If the Auto Task Timeout is properly configured in the Repository Options, then enabling this will allow a task timeout to be automatically calculated based on the process times of previous processed files for the job. "
    )

    scriptDialog.AddControlToGrid(
        "ConcurrentTasksLabel", "LabelControl", "Concurrent Tasks", 6, 0,
        "The number of tasks that can process concurrently on a single slave. This is useful if the processing application only uses one thread to process and your slaves have multiple CPUs.",
        False)
    scriptDialog.AddRangeControlToGrid("ConcurrentTasksBox", "RangeControl", 1,
                                       1, 16, 0, 1, 6, 1)
    scriptDialog.AddSelectionControlToGrid(
        "LimitConcurrentTasksBox", "CheckBoxControl", True,
        "Limit Tasks To Slave's Task Limit", 6, 2,
        "If you limit the tasks to a slave's task limit, then by default, the slave won't dequeue more tasks then it has CPUs. This task limit can be overridden for individual slaves by an administrator."
    )

    scriptDialog.AddControlToGrid(
        "MachineLimitLabel", "LabelControl", "Machine Limit", 7, 0,
        "Use the Machine Limit to specify the maximum number of machines that can render your job at one time. Specify 0 for no limit.",
        False)
    scriptDialog.AddRangeControlToGrid("MachineLimitBox", "RangeControl", 0, 0,
                                       1000000, 0, 1, 7, 1)
    scriptDialog.AddSelectionControlToGrid(
        "IsBlacklistBox", "CheckBoxControl", False,
        "Machine List Is A Blacklist", 7, 2,
        "You can force the job to process on specific machines by using a whitelist, or you can avoid specific machines by using a blacklist."
    )

    scriptDialog.AddControlToGrid(
        "MachineListLabel", "LabelControl", "Machine List", 8, 0,
        "The whitelisted or blacklisted list of machines.", False)
    scriptDialog.AddControlToGrid("MachineListBox",
                                  "MachineListControl",
                                  "",
                                  8,
                                  1,
                                  colSpan=2)

    scriptDialog.AddControlToGrid("LimitGroupLabel", "LabelControl", "Limits",
                                  9, 0, "The Limits that your job requires.",
                                  False)
    scriptDialog.AddControlToGrid("LimitGroupBox",
                                  "LimitGroupControl",
                                  "",
                                  9,
                                  1,
                                  colSpan=2)

    scriptDialog.AddControlToGrid(
        "DependencyLabel", "LabelControl", "Dependencies", 10, 0,
        "Specify existing jobs that this job will be dependent on. This job will not start until the specified dependencies finish processing.",
        False)
    scriptDialog.AddControlToGrid("DependencyBox",
                                  "DependencyControl",
                                  "",
                                  10,
                                  1,
                                  colSpan=2)

    scriptDialog.AddControlToGrid(
        "OnJobCompleteLabel", "LabelControl", "On Job Complete", 11, 0,
        "If desired, you can automatically archive or delete the job when it completes.",
        False)
    scriptDialog.AddControlToGrid("OnJobCompleteBox", "OnJobCompleteControl",
                                  "Nothing", 11, 1)
    scriptDialog.AddSelectionControlToGrid(
        "SubmitSuspendedBox", "CheckBoxControl", False,
        "Submit Job As Suspended", 11, 2,
        "If enabled, the job will submit in the suspended state. This is useful if you don't want the job to start processing right away. Just resume it from the Monitor when you want it to process."
    )
    scriptDialog.EndGrid()

    scriptDialog.AddGrid()
    scriptDialog.AddControlToGrid("Separator3",
                                  "SeparatorControl",
                                  "CSi SAP2000 File Options",
                                  0,
                                  0,
                                  colSpan=3)

    scriptDialog.AddControlToGrid(
        "SceneLabel", "LabelControl", "CSi SAP2000 Data File(s)", 1, 0,
        "The CSi SAP2000 Data File to be processed.", False)
    scriptDialog.AddSelectionControlToGrid(
        "SceneBox",
        "MultiFileBrowserControl",
        "",
        "CSi SAP2000 Files (*.SDB);;Microsoft Access Files (*.MDB);;Microsoft Excel Files (*.XLS);;CSi SAP2000 Text Files (*.$2K *.S2K)",
        1,
        1,
        colSpan=2)

    OverrideOutput = scriptDialog.AddSelectionControlToGrid(
        "OverrideOutput", "CheckBoxControl", False,
        "Override Output Directory", 2, 0,
        "If this option is enabled, an output directory can be used to re-direct all processed files to.",
        False)
    OverrideOutput.ValueModified.connect(OverrideOutputPressed)
    scriptDialog.AddSelectionControlToGrid("OutputDirectoryBox",
                                           "FolderBrowserControl",
                                           "",
                                           "",
                                           2,
                                           1,
                                           colSpan=2)
    scriptDialog.SetEnabled("OutputDirectoryBox", False)

    scriptDialog.AddControlToGrid(
        "BuildLabel", "LabelControl", "Build To Force", 3, 0,
        "You can force 32 or 64 bit processing with this option.", False)
    scriptDialog.AddComboControlToGrid("BuildBox", "ComboControl", "None",
                                       ("None", "32bit", "64bit"), 3, 1)
    scriptDialog.AddSelectionControlToGrid(
        "SubmitSceneBox", "CheckBoxControl", False,
        "Submit Data File With Job", 3, 2,
        "If this option is enabled, the SAP2000 file will be submitted with the job, and then copied locally to the slave machine during processing."
    )
    scriptDialog.AddControlToGrid(
        "VersionLabel", "LabelControl", "Version", 4, 0,
        "The version of CSi SAP2000 to render with.", False)
    scriptDialog.AddComboControlToGrid("VersionBox", "ComboControl", "17",
                                       ("14", "15", "16", "17"), 4, 1)

    scriptDialog.EndGrid()
    scriptDialog.EndTabPage()

    scriptDialog.AddTabPage("Advanced Options")
    scriptDialog.AddGrid()
    scriptDialog.AddControlToGrid("Separator4",
                                  "SeparatorControl",
                                  "Process/Solver Options",
                                  0,
                                  0,
                                  colSpan=3)

    scriptDialog.AddControlToGrid(
        "ProcessLabel", "LabelControl", "Process Selection", 1, 0,
        "Choose to execute inside of the existing SAP2000 application process or as a separate process.",
        False)
    ProcessType = scriptDialog.AddComboControlToGrid(
        "ProcessType", "ComboControl", "GUI Process",
        ("GUI Process", "Separate Process"), 1, 1)
    ProcessType.ValueModified.connect(ProcessTypeChanged)

    scriptDialog.AddControlToGrid(
        "SolverLabel", "LabelControl", "Solver Selection", 2, 0,
        "Select the Solver to perform the analysis on the data file.", False)
    SolverType = scriptDialog.AddComboControlToGrid(
        "SolverType", "ComboControl", "Standard Solver",
        ("Standard Solver", "Advanced Solver"), 2, 1)
    SolverType.ValueModified.connect(SolverTypeChanged)
    scriptDialog.EndGrid()

    scriptDialog.AddGrid()
    scriptDialog.AddControlToGrid("Separator5",
                                  "SeparatorControl",
                                  "Design Options",
                                  0,
                                  0,
                                  colSpan=3)

    scriptDialog.AddControlToGrid(
        "DesignLabel",
        "LabelControl",
        "Automatically perform design after data file has been opened & analysis results are available.",
        1,
        0,
        colSpan=3)

    scriptDialog.AddSelectionControlToGrid(
        "DesignSteelFrame", "CheckBoxControl", False, "Steel Frame Design", 2,
        0, "Perform steel frame design after the analysis has completed.")
    scriptDialog.AddSelectionControlToGrid(
        "DesignConcreteFrame", "CheckBoxControl", False,
        "Concrete Frame Design", 2, 1,
        "Perform concrete frame design after the analysis has completed.")

    scriptDialog.AddSelectionControlToGrid(
        "DesignAluminiumFrame", "CheckBoxControl", False,
        "Aluminium Frame Design", 3, 0,
        "Perform aluminium frame design after the analysis has completed.")
    scriptDialog.AddSelectionControlToGrid(
        "DesignColdFormedFrame", "CheckBoxControl", False,
        "Cold Formed Frame Design", 3, 1,
        "Peform cold formed frame design after analysis has completed.")
    scriptDialog.EndGrid()

    scriptDialog.AddGrid()
    scriptDialog.AddControlToGrid("Separator6",
                                  "SeparatorControl",
                                  "Deletion Options",
                                  0,
                                  0,
                                  colSpan=3)

    scriptDialog.AddControlToGrid(
        "DeletionLabel", "LabelControl", "Temp File Deletion", 1, 0,
        "Choose a deletion option to cleanup the analysis/log/out files if required.",
        False)
    DeletionType = scriptDialog.AddComboControlToGrid(
        "DeletionType", "ComboControl", "keep everything",
        ("keep everything", "delete all files (not *.mdb)",
         "delete analysis files only", "delete log/out files only"), 1, 1)
    DeletionType.ValueModified.connect(DeletionTypeChanged)
    scriptDialog.EndGrid()

    scriptDialog.AddGrid()
    scriptDialog.AddControlToGrid("Separator7",
                                  "SeparatorControl",
                                  "Additional Options",
                                  0,
                                  0,
                                  colSpan=3)

    scriptDialog.AddSelectionControlToGrid(
        "IncludeDataFileBox", "CheckBoxControl", True, "Include Data File", 1,
        0,
        "If enabled, the output zip file will contain the data file OR if outputting to a directory path, the data file will be included."
    )
    scriptDialog.AddSelectionControlToGrid(
        "CompressOutputBox", "CheckBoxControl", True, "Compress (ZIP) Output",
        2, 0, "Automatically compress the output to a single zip file.")

    scriptDialog.AddControlToGrid(
        "CommandLineLabel", "LabelControl", "Command Line Args", 3, 0,
        "Additional command line flags/options can be added here if required.",
        False)
    scriptDialog.AddControlToGrid("CommandLineArgs",
                                  "TextControl",
                                  "",
                                  3,
                                  1,
                                  colSpan=2)
    scriptDialog.EndGrid()
    scriptDialog.EndTabPage()

    scriptDialog.EndTabControl()

    scriptDialog.AddGrid()
    scriptDialog.AddHorizontalSpacerToGrid("HSpacer1", 0, 0)

    submitButton = scriptDialog.AddControlToGrid("SubmitButton",
                                                 "ButtonControl",
                                                 "Submit",
                                                 0,
                                                 1,
                                                 expand=False)
    submitButton.ValueModified.connect(SubmitButtonPressed)

    closeButton = scriptDialog.AddControlToGrid("CloseButton",
                                                "ButtonControl",
                                                "Close",
                                                0,
                                                2,
                                                expand=False)
    closeButton.ValueModified.connect(CloseButtonPressed)

    scriptDialog.EndGrid()

    settings = ("DepartmentBox", "CategoryBox", "PoolBox", "SecondaryPoolBox",
                "GroupBox", "PriorityBox", "MachineLimitBox", "IsBlacklistBox",
                "MachineListBox", "LimitGroupBox", "SceneBox", "ChunkSizeBox",
                "OutputBox", "BuildBox", "SubmitSceneBox", "ProcessType",
                "SolverType", "DesignSteelFrame", "DesignConcreteFrame",
                "DesignAluminiumFrame", "DesignColdFormedFrame",
                "DeletionType", "IncludeDataFileBox", "CompressOutputBox",
                "CommandLineArgs", "VersionBox")
    scriptDialog.LoadSettings(GetSettingsFilename(), settings)

    scriptDialog.Shown.connect(InitializeDialog)

    scriptDialog.ShowDialog(True)