def _build_gui(file_path): """ Build the widgets at the top of the window. :param file_path: The initial file path to parse. :type file_path: basestring or None :returns: 3DEqualizer UI request id. """ # Get the clipboard value and test if it's a valid .mmcamera file, # if so use it as the default. If not, use the current 3DE file # path as a directory to search. cwd_path = os.getcwd() proj_path = tde4.getProjectPath() if SUPPORT_CLIPBOARD is True: file_path = tde4.getClipboardString() file_data = None if file_path: file_data = _parse_data(file_path) has_vaild_data = _file_data_has_valid_data(file_data) if has_vaild_data is not True: file_path = proj_path or cwd_path window_requester = tde4.createCustomRequester() file_pattern = '*' + EXT tde4.addFileWidget( window_requester, FILE_BROWSER_WIDGET, FILE_BROWSER_LABEL, file_pattern, file_path, ) tde4.setWidgetCallbackFunction( window_requester, FILE_BROWSER_WIDGET, '_build_widgets' ) pgroup_id, cam_id, lens_id = _query_selection_state() has_vaild_data = _file_data_has_valid_data(file_data) if has_vaild_data is not True or not pgroup_id or not cam_id or not lens_id: _build_widgets(window_requester, FILE_BROWSER_WIDGET, 0) else: _build_widgets_with_data(window_requester, pgroup_id, cam_id, lens_id, file_data) return window_requester
def buildUI(): # calculate Output file # we will get the path of the first camera - changed # to path to file .3DE wo extension ''' firstCam = tde4.getIndexCamera(0) firstCamPath = tde4.getCameraPath(firstCam).replace('\\', '/') ''' if tde4.getProjectPath() == None: print "Can't get the Project Path" outputFile = "Can't get the Project Path" else: # the same as the file 3DE wo the extension (asume in the 4 last chars) outputFile = tde4.getProjectPath().replace('/', '\\')[:-4] # open requester... req = tde4.createCustomRequester() tde4.addFileWidget(req, "file_browser", "Browse...", "*", outputFile) # tde4.addTextFieldWidget(req, "filePath", "Optuput file", outputFile) labels = nukeVersions.keys() labels.sort() labels.reverse() print labels #tde4.addOptionMenuWidget(req, "nukeVersion", "Nuke Version", *labels) #tde4.addToggleWidget(req, "openNuke", "Open nuke after Export", 0) # To Export tde4.addSeparatorWidget(req, "sep2") # export all cameras tde4.addToggleWidget(req, "exportAllCameras", "Export all Cameras", 1) tde4.setWidgetCallbackFunction(req, "exportAllCameras", "callBackExportAll") tde4.addSeparatorWidget(req, "sepAllCameras") # cameras to select for cameraIndex in range(tde4.getNoCameras()): cameraTmp = tde4.getIndexCamera(cameraIndex) if not tools.validCamera(cameraTmp): buildUINotSupported(req, cameraIndex, cameraTmp) else: buildUICamera(req, cameraIndex, cameraTmp) return req
def buildUICamera(req, cameraIndex, cameraTmp): imageHeightOuttmp, imageWidthOuttmp = getOutSize(req, cameraIndex, cameraTmp) nametmp = "exportCamera" + str(cameraIndex) texttmp = "Export Camera " + str(tde4.getCameraName(cameraTmp)) tde4.addToggleWidget(req, nametmp, texttmp, 1) tde4.setWidgetCallbackFunction(req, nametmp, "callBackExportCamera") firstFrame = tde4.getCameraSequenceAttr(cameraTmp)[0] strRes = camWidgetFormat.format(imageWidth=str(imageWidthOuttmp), sep=resSpliter, imageHeight=str(imageHeightOuttmp), firstFrame=firstFrame) camResWidgetName = camWidgetPrefix + str(cameraIndex) log.debug('camResWidgetName (creation): ' + camResWidgetName) tde4.addTextFieldWidget(req, camResWidgetName, camResWidgetText, strRes) tde4.addSeparatorWidget(req, "sep" + str(cameraIndex))
value_option_menu_default_initial_frame = 1 else: # Using 3DE4 initial frame value_option_menu_default_initial_frame = 2 try: tde4.setWidgetCallbackFunction we_have_set_widget_callback_function = True except: we_have_set_widget_callback_function = False # For older releases we cannot do the smart guessing... if we_have_set_widget_callback_function: widget_default_initial_frame = tde4.addOptionMenuWidget(nuke_node_req,"option_menu_default_initial_frame","Startframe is based on","Nuke Read Node Default","3DE4 Initial Frame","User-defined") tde4.setWidgetValue(nuke_node_req,"option_menu_default_initial_frame",str(value_option_menu_default_initial_frame)) tde4.setWidgetCallbackFunction(nuke_node_req,"option_menu_default_initial_frame","set_initial_frame_widget") # Without / before smart-guessing we mimick Nuke's Read Node default behaviour. tde4.addTextFieldWidget(nuke_node_req,"text_initial_frame_nuke","Startframe in Nuke",str(tde4.getCameraSequenceAttr(id_cam)[0])) # After creating all widgets we invoke the Callback once explicitly in order to initialize the text widget. if we_have_set_widget_callback_function: set_initial_frame_widget(widget_default_initial_frame,None,None) # post requester ret = tde4.postCustomRequester(nuke_node_req,'Export nuke distortion node for camera ' + tde4.getCameraName(id_cam)+' ',700,0,'Ok','Cancel ') if ret != 1: raise CancelException('Cancelled') # At this point we know that user has pressed "Ok". Check path and suffix nuke_path = tde4.getWidgetValue(nuke_node_req,'file_nuke_path') if not nuke_path: raise Exception('No path specified')
value_option_menu_default_initial_frame = 1 else: # Using 3DE4 initial frame value_option_menu_default_initial_frame = 2 try: tde4.setWidgetCallbackFunction we_have_set_widget_callback_function = True except: we_have_set_widget_callback_function = False # For older releases we cannot do the smart guessing... if we_have_set_widget_callback_function: widget_default_initial_frame = tde4.addOptionMenuWidget(nuke_node_req,"option_menu_default_initial_frame","Startframe is based on","Nuke Read Node Default","3DE4 Initial Frame","User-defined") tde4.setWidgetValue(nuke_node_req,"option_menu_default_initial_frame",str(value_option_menu_default_initial_frame)) tde4.setWidgetCallbackFunction(nuke_node_req,"option_menu_default_initial_frame","set_initial_frame_widget") # Without / before smart-guessing we mimick Nuke's Read Node default behaviour. tde4.addTextFieldWidget(nuke_node_req,"text_initial_frame_nuke","Startframe in Nuke",str(tde4.getCameraSequenceAttr(id_cam)[0])) # After creating all widgets we invoke the Callback once explicitly in order to initialize the text widget. if we_have_set_widget_callback_function: set_initial_frame_widget(widget_default_initial_frame,None,None) # post requester ret = tde4.postCustomRequester(nuke_node_req,'Export nuke distortion node for camera ' + tde4.getCameraName(id_cam)+' ',700,0,'Ok','Cancel ') if ret != 1: raise CancelException('Cancelled') # At this point we know that user has pressed "Ok". Check path and suffix nuke_path = tde4.getWidgetValue(nuke_node_req,'file_nuke_path') if not nuke_path: raise Exception('No path specified')