def get_frame_rate_section(self): section_span = SpanWdg() section_span.add('Frame Rate: ') frame_rate_select = SelectWdg('frame_rate_select') frame_rate_select.set_id('frame_rate_code') frame_rate_select.add_style('width', '153px') frame_rate_select.add_style('display', 'inline-block') frame_rate_select.add_empty_option() frame_rate_search = Search('twog/frame_rate') frame_rates = frame_rate_search.get_sobjects() for frame_rate in frame_rates: frame_rate_select.append_option(frame_rate.get_value('name'), frame_rate.get_code()) try: frame_rate_select.set_value(self.frame_rate_code) except AttributeError: pass section_span.add(frame_rate_select) return section_span
def get_display(self): div_wdg = DivWdg() current_code_div = DivWdg() component_code = self.file_flow_sobject.get('component_code') component_sobject = get_sobject_by_code('twog/component', component_code) current_code_div.add('Current Component set to {0} ({1})'.format(component_sobject.get('name'), component_code)) order_sobject = get_order_sobject_from_component_sobject(component_sobject) component_sobjects_for_order = get_component_sobjects_from_order_code(order_sobject.get_code()) component_select_wdg = SelectWdg() component_select_wdg.set_id('component_select') component_select_wdg.add_style('width: 165px;') component_select_wdg.add_empty_option() for component in component_sobjects_for_order: component_select_wdg.append_option(component.get('name'), component.get_code()) div_wdg.add(current_code_div) div_wdg.add(component_select_wdg) return div_wdg
def get_display(my): widget = DivWdg() table = Table() table.add_attr('class','my_preferences_wdg') prefs = my.login_obj.get('twog_preferences').split(',') for pref in prefs: if pref not in [None,'']: kv = pref.split('=') key = kv[0] val = kv[1] table.add_row() desc = table.add_cell(my.key_dict[key]) desc.add_attr('nowrap','nowrap') this_sel = SelectWdg(key) this_sel.add_attr('id',key) this_sel.add_style('width: 100px;') this_sel.append_option('True','true') this_sel.append_option('False','false') this_sel.set_value(val) table.add_cell(this_sel) table.add_row() t2 = Table() t2.add_row() t2.add_cell() tc = t2.add_cell('<input type="button" name="Save My Preferences" value="Save My Preferences"/>') tc.add_attr('width', '50px') tc.add_behavior(my.get_save_preferences()) t2.add_cell() table.add_cell(t2) widget.add(table) return widget
def get_task_status_select_wdg(task_sobject): """ Given a sthpw/task sobject, return a SelectWdg with all its potential status options. This is done by looking up what those options are through the parent Pipeline. :param task_sobject: sthpw/task sobject :return: SelectWdg """ task_status_select = SelectWdg('task_status_select') task_status_select.set_id('task_status_select') task_status_select.add_style('width: 165px;') task_status_select.add_empty_option() task_pipe_code = task_sobject.get_value('pipeline_code') # if the current task has no pipeline, then search for # any task pipeline if not task_pipe_code: # just use the default task_pipe_code = 'task' pipeline = Pipeline.get_by_code(task_pipe_code) if not pipeline: pipeline = Pipeline.get_by_code('task') for status in pipeline.get_process_names(): task_status_select.append_option(status, status) if task_sobject.get('status'): task_status_select.set_value(task_sobject.get('status')) return task_status_select
def configure_category(my, title, category, options, options_type = {}): div = DivWdg() title_wdg = DivWdg() div.add(title_wdg) #from tactic.ui.widget.swap_display_wdg import SwapDisplayWdg #swap = SwapDisplayWdg() #div.add(swap) title_wdg.add("<b>%s</b>" % title) table = Table() div.add(table) #table.add_color("color", "color") table.add_style("color: #000") table.add_style("margin: 20px") for option in options: table.add_row() display_title = Common.get_display_title(option) td = table.add_cell("%s: " % display_title) td.add_style("width: 150px") option_type = options_type.get(option) validation_scheme = "" #add selectWdg for those options whose type is bool if option_type == 'bool': text = SelectWdg(name="%s/%s" % (category, option)) text.set_option('values','true|false') text.set_option('empty','true') text.add_style("margin-left: 0px") elif option.endswith('password'): text = PasswordInputWdg(name="%s/%s" % (category, option)) # dealing with options whose type is number else: if option_type == 'number': validation_scheme = 'INTEGER' else: validation_scheme = "" text = TextInputWdg(name="%s/%s" % (category, option), validation_scheme=validation_scheme, read_only="false") value = Config.get_value(category, option) if value: text.set_value(value) table.add_cell(text) return div
def get_file_in_package_status_select(): task_status_select = SelectWdg('file_status_select') task_status_select.set_id('file_status_select') task_status_select.add_style('width: 165px;') task_status_select.add_empty_option() pipeline = Pipeline.get_by_code('twog_Delivery') for status in pipeline.get_process_names(): task_status_select.append_option(status, status) return task_status_select
def get_season_select_wdg(width=300): season_select_wdg = SelectWdg('season_code') season_select_wdg.set_id('season_code') season_select_wdg.add_style('width', '{0}px'.format(width)) season_search = Search('twog/season') seasons = season_search.get_sobjects() for season in seasons: season_select_wdg.append_option(season.get_value('name'), season.get_code()) return season_select_wdg
def get_title_select_wdg(width=300): title_select_wdg = SelectWdg('title_code') title_select_wdg.set_id('title_code') title_select_wdg.add_style('width', '{0}px'.format(width)) title_select_wdg.add_empty_option() title_search = Search('twog/title') titles = title_search.get_sobjects() for title in titles: title_select_wdg.append_option(title.get_value('name'), title.get_code()) return title_select_wdg
def get_action_wdg(my): filter_div = DivWdg() select = SelectWdg("filter_action") select.add_empty_option("-- search action --") select.add_style("text-align: right") select.set_option("labels", "Retrieve Search|Save Search") select.set_option("values", "retrieve|save") select.add_event("onchange", "spt.dg_table.search_action_cbk(this)") filter_div.add(select) return filter_div
def get_display(self): # add a view action view_div = DivWdg() view_select = SelectWdg("action|view_action") view_select.add_style("text-align: right") view_select.add_empty_option("-- view --") view_select.set_option("values", "copy_url|add_my_view|edit|save|rename|delete|custom_property|custom_script") view_select.set_option("labels", "X Copy URL to this View|Add to My Views|Edit as Draft|Save Project View As|X Rename View|X Delete View|Add Custom Property|Add Custom Script") view_div.add_style("float: right") view_div.add(view_select) view_select.add_event("onchange", "spt.dg_table.view_action_cbk(this,'%s')" % self.table_id) return view_div
def get_bay_select(self): bay_sel = SelectWdg('bay_select') bay_sel.set_id('bay') bay_sel.add_style('width', '135px') bay_sel.add_empty_option() for i in range(1, 13): bay_sel.append_option('Bay %s' % i, 'Bay %s' % i) try: bay_sel.set_value(self.bay) except AttributeError: pass return bay_sel
def get_style_select(self): style_sel = SelectWdg('style_select') style_sel.set_id('style') style_sel.add_style('width: 135px;') style_sel.add_empty_option() for style in ('Technical', 'Spot QC', 'Mastering'): style_sel.append_option(style, style) try: style_sel.set_value(self.style_sel) except AttributeError: pass return style_sel
def get_status_select(self): status_sel = SelectWdg('status_select') status_sel.set_id('status') status_sel.add_style('width', '135px') status_sel.add_empty_option() statuses = ('Approved', 'In Progress', 'Rejected') for status in statuses: status_sel.append_option(status, status) if hasattr(self, 'status'): status_sel.set_value(self.status) return status_sel
def get_language_select_wdg(): language_select_wdg = SelectWdg('language_code') language_select_wdg.set_id('language_code') language_select_wdg.add_style('display', 'inline-block') language_select_wdg.add_empty_option() language_search = Search('twog/language') languages = language_search.get_sobjects() languages = sorted(languages, key=lambda x: x.get_value('name')) for language in languages: language_select_wdg.append_option(language.get_value('name'), language.get_code()) return language_select_wdg
def get_type_select_wdg(self, name, width=80): """ :name: String, set as the name and ID for the select widget. Should correspond to a column on the MetaData sobject :width: int, the desired width of the widget in pixels :return: SelectWdg """ select_wdg = SelectWdg(name) select_wdg.set_id(name) select_wdg.add_style('width', '{0}px'.format(width)) select_wdg.add_empty_option() types = ( ('(5.1) L', '5_1_l'), ('(5.1) R', '5_1_r'), ('(5.1) C', '5_1_c'), ('(5.1) Lfe', '5_1_lfe'), ('(5.1) Ls', '5_1_ls'), ('(5.1) Rs', '5_1_rs'), ('(7.1) L', '7_1_l'), ('(7.1) R', '7_1_r'), ('(7.1) C', '7_1_c'), ('(7.1) Lfe', '7_1_lfe'), ('(7.1) Ls', '7_1_ls'), ('(7.1) Rs', '7_1_rs'), ('(7.1) SBL', '7_1_sbl'), ('(7.1) SBR', '7_1_sbr'), ('(Stereo) Lt', 'stereo_lt'), ('(Stereo) Rt', 'stereo_rt'), ('(Stereo) Lt, Rt', 'stereo_lt_rt'), ('(Stereo) L', 'stereo_l'), ('(Stereo) R', 'stereo_r'), ('(Stereo) L, R', 'stereo_l_r'), ('Mono', 'mono') ) for audio_type in types: type_label = audio_type[0] type_value = audio_type[1] select_wdg.append_option(type_label, type_value) # If the report was loaded from a save, and if the value is set, load it in the widget if hasattr(self, name): select_wdg.set_value(getattr(self, name)) return select_wdg
def get_client_select(self): client_sel = SelectWdg('client_select') client_sel.set_id('client_code') client_sel.add_style('width', '135px') client_sel.add_empty_option() client_search = Search('twog/client') clients = client_search.get_sobjects() for client in clients: client_sel.append_option(client.get_value('name'), client.get_code()) if hasattr(self, 'client_code'): client_sel.set_value(self.client_code) return client_sel
def get_machine_select(self): machine_sel = SelectWdg('machine_select') machine_sel.set_id('machine_code') machine_sel.add_style('width', '135px') machine_sel.add_empty_option() machine_search = Search('twog/machine') machines = machine_search.get_sobjects() for machine in machines: machine_sel.append_option(machine.get_value('name'), machine.get_code()) if self.prequal_eval_sobject: machine_sel.set_value(self.prequal_eval_sobject.get_value('machine_code')) return machine_sel
def get_display(self): # add a view action view_div = DivWdg() view_select = SelectWdg("action|table") view_select.add_style("text-align: right") view_select.add_empty_option("-- items --") view_select.set_option("values", "add|edit|retire|delete|export_all|export_selected") view_select.set_option("labels", "Add New Item|X Edit Selected|Retire Selected|Delete Selected|X CSV Export (all)|X CSV Export (selected)") view_div.add_style("float: right") view_div.add(view_select) #view_select.add_event("onchange", "spt.dg_table.retire_selected_cbk('%s')" % self.target_id) view_select.add_event("onchange", "spt.dg_table.table_action_cbk(this,'%s')" % self.table_id ) return view_div
def get_format_select_wdg(self): format_sel = SelectWdg('format_select') format_sel.set_id('format') format_sel.add_style('width', '153px') format_sel.add_style('display', 'inline-block') format_sel.add_empty_option() for file_format in ('Electronic/File', 'File - ProRes', 'File - MXF', 'File - MPEG', 'File - WAV', 'DBC', 'D5', 'HDCAM SR', 'NTSC', 'PAL'): format_sel.append_option(file_format, file_format) try: format_sel.set_value(self.format_data) except AttributeError: pass return format_sel
def get_file_select_wdg_from_file_list(files, width=400): """ Given a list of file sobjects, return a SelectWdg using the file paths and codes :param files: List of file sobjects :param width: Width of the SelectWdg :return: SelectWdg """ file_select_wdg = SelectWdg('file_select') file_select_wdg.set_id('file_select') file_select_wdg.add_style('width', '{0}px'.format(width)) file_select_wdg.add_empty_option() for file_sobject in files: file_select_wdg.append_option(file_sobject.get('file_path'), file_sobject.get_code()) return file_select_wdg
def get_video_aspect_ratio_select_wdg(self): video_aspect_ratio_sel = SelectWdg('video_aspect_ratio_select') video_aspect_ratio_sel.set_id('video_aspect_ratio') video_aspect_ratio_sel.add_style('width', '300px') video_aspect_ratio_sel.add_style('display', 'inline-block') video_aspect_ratio_sel.add_empty_option() video_aspect_ratios_search = Search('twog/aspect_ratio') video_aspect_ratios = video_aspect_ratios_search.get_sobjects() for video_aspect_ratio in video_aspect_ratios: video_aspect_ratio_sel.append_option(video_aspect_ratio.get('name'), video_aspect_ratio.get('name')) if hasattr(self, 'video_aspect_ratio'): video_aspect_ratio_sel.set_value(self.video_aspect_ratio) return video_aspect_ratio_sel
def get_pipeline_select_wdg(pipeline_code, search_type): pipeline_sel = SelectWdg('pipeline_select') pipeline_sel.set_id('pipeline_select') pipeline_sel.add_style('width', '135px') pipeline_sel.add_empty_option() pipeline_search = Search('sthpw/pipeline') pipeline_search.add_filter('search_type', search_type) pipelines = pipeline_search.get_sobjects() for pipeline in pipelines: pipeline_sel.append_option(pipeline.get_value('name'), pipeline.get_code()) if pipeline_code: pipeline_sel.set_value(pipeline_code) return pipeline_sel
def get_machine_select(self): machine_sel = SelectWdg('machine_select') machine_sel.set_id('machine_code') machine_sel.add_style('width', '135px') machine_sel.add_empty_option() machine_search = Search('twog/machine') machines = machine_search.get_sobjects() for machine in machines: machine_sel.append_option(machine.get_value('name'), machine.get_code()) try: machine_sel.set_value(self.machine_code) except AttributeError: pass return machine_sel
def get_client_select(self): client_sel = SelectWdg('client_select') client_sel.set_id('client_code') client_sel.add_style('width', '135px') client_sel.add_empty_option() client_search = Search('twog/client') clients = client_search.get_sobjects() for client in clients: client_sel.append_option(client.get_value('name'), client.get_code()) try: client_sel.set_value(self.prequal_eval_sobject.get('client_code')) except AttributeError: pass return client_sel
def get_select_wdg(name, options, is_checked, saved_value=None): select_wdg = SelectWdg(name) select_wdg.set_id(name) select_wdg.add_empty_option() for option_set in options: label = option_set[0] value = option_set[1] select_wdg.append_option(label, value) if not is_checked: select_wdg.add_style('font-weight', 'bold') if saved_value: select_wdg.set_value(saved_value) return select_wdg
def get_label_select_wdg(self): label_select_wdg = SelectWdg('label') label_select_wdg.set_id('label') label_select_wdg.add_style('width', '300px') label_select_wdg.add_style('display', 'inline-block') label_select_wdg.add_empty_option() label_options = ('Good', 'Fair', 'Poor') for label in label_options: label_select_wdg.append_option(label, label) if hasattr(self, 'label'): # Double check that 'label' is within the given options (sometimes it isn't for some reason which causes # an error) if self.label in label_options: label_select_wdg.set_value(self.label) return label_select_wdg
def get_language_select(self): language_select = SelectWdg('language_select') language_select.set_id('language_code') language_select.add_style('width', '300px') language_select.add_style('display', 'inline-block') language_select.add_empty_option() language_search = Search('twog/language') languages = language_search.get_sobjects() languages = sorted(languages, key=lambda x: x.get_value('name')) for language in languages: language_select.append_option(language.get_value('name'), language.get_code()) if hasattr(self, 'language_code'): language_select.set_value(self.language_code) return language_select
def get_standard_section(self): section_span = SpanWdg() section_span.add('Standard: ') standard_select = SelectWdg('standard_select') standard_select.set_id('standard') standard_select.add_style('width', '153px') standard_select.add_style('display', 'inline-block') standard_select.add_empty_option() for standard in ('625', '525', '720', '1080 (4:4:4)', '1080', 'PAL', 'NTSC'): standard_select.append_option(standard, standard) if self.prequal_eval_sobject: standard_select.set_value(self.prequal_eval_sobject.get_value('standard')) section_span.add(standard_select) return section_span
def get_video_aspect_ratio_select_wdg(self): video_aspect_ratio_sel = SelectWdg('video_aspect_ratio_select') video_aspect_ratio_sel.set_id('video_aspect_ratio') video_aspect_ratio_sel.add_style('width', '300px') video_aspect_ratio_sel.add_style('display', 'inline-block') video_aspect_ratio_sel.add_empty_option() for video_aspect_ratio in ('16x9 1.33', '16x9 1.33 Pan & Scan', '16x9 1.78 Anamorphic', '16x9 1.78 Full Frame', '16x9 1.85 Letterbox', '16x9 1.85 Matted', '16x9 1.85 Matted Anamorphic', '16x9 2.00 Letterbox', '16x9 2.10 Letterbox', '16x9 2.20 Letterbox', '16x9 2.35 Anamorphic', '16x9 2.35 Letterbox', '16x9 2.40 Letterbox', '16x9 2.55 Letterbox', '4x3 1.33 Full Frame', '4x3 1.78 Letterbox', '4x3 1.85 Letterbox', '4x3 2.35 Letterbox', '4x3 2.40 Letterbox'): video_aspect_ratio_sel.append_option(video_aspect_ratio, video_aspect_ratio) if self.prequal_eval_sobject: video_aspect_ratio_sel.set_value(self.prequal_eval_sobject.get_value('video_aspect_ratio')) return video_aspect_ratio_sel
def get_file_classification_select_wdg(width=200, selected=None): """ Get a SelectWdg with the three options available for a file's classification (source, intermediate, and deliverable). If 'selected' argument is passed, set the SelectWdg's value to that. :param width: Width of the widget in pixels (optional) :param selected: String ('source', 'intermediate', 'deliverable', or None) :return: SelectWdg """ classification_select_wdg = SelectWdg('file_classification_select') classification_select_wdg.set_id('file_classification_select') classification_select_wdg.add_style('width', '{0}px'.format(width)) classification_select_wdg.append_option('Source', 'source') classification_select_wdg.append_option('Intermediate', 'intermediate') classification_select_wdg.append_option('Deliverable', 'deliverable') if selected: classification_select_wdg.set_value(selected) return classification_select_wdg
def get_pipeline_select_wdg(search_type, width=300): """ Given a search type, return a select widget with the pipelines available for that search type :param search_type: Search type as a string :param width: Width of the widget in pixels :return: SelectWdg """ pipeline_select_wdg = SelectWdg('pipeline_code') pipeline_select_wdg.set_id('pipeline_code') pipeline_select_wdg.add_style('width', '{0}px'.format(width)) pipeline_select_wdg.add_empty_option() pipeline_search = Search('sthpw/pipeline') pipeline_search.add_filter('search_type', search_type) pipelines = pipeline_search.get_sobjects() for pipeline in pipelines: pipeline_select_wdg.append_option(pipeline.get_value('name'), pipeline.get_code()) return pipeline_select_wdg
def get_file_type_wdg(my): '''drop down which selects which file type to export to''' # add a filter div = DivWdg() filter_div = FloatDivWdg(HtmlElement.b("File Type:"), width="15em") div.add(filter_div) select = SelectWdg() select.set_name("file_type") select.set_id("file_type") app = WebContainer.get_web().get_selected_app() if app == 'Maya': select.set_option("values", "mayaAscii|mayaBinary|obj|collada") select.set_option("labels", "Maya Ascii (.ma)|Maya Binary (.mb)|Wavefront .obj|Collada (.dae)") elif app == 'Houdini': select.set_option("values", "otl") select.set_option("labels", "Houdini Digital Asset(.otl)") elif app == 'XSI': select.set_option("values", "emdl|dotXSI|obj") select.set_option("labels", "3D Model (.emdl)|SoftImage dotXSI (.xsi)|Wavefront .obj") else: select.set_option("values", "mayaAscii|mayaBinary|obj|collada") select.set_option("labels", "Maya Ascii (.ma)|Maya Binary (.mb)|Wavefront .obj|Collada (.dae)") select.add_style("font-size: 0.8em") select.add_style("margin-top: 5px") select.add_style("margin-right: 10px") select.set_persistence() div.add(select) return div
def get_standard_section(self): section_span = SpanWdg() section_span.add('Standard: ') standard_select = SelectWdg('standard_select') standard_select.set_id('standard') standard_select.add_style('width', '153px') standard_select.add_style('display', 'inline-block') standard_select.add_empty_option() for standard in ('625', '525', '720', '1080 (4:4:4)', '1080', 'PAL', 'NTSC', '3840', '4160'): standard_select.append_option(standard, standard) try: standard_select.set_value(self.standard) except AttributeError: pass section_span.add(standard_select) return section_span
def get_display(my): # add a view action view_div = DivWdg() view_select = SelectWdg("action|view_action") view_select.add_style("text-align: right") view_select.add_empty_option("-- view --") view_select.set_option( "values", "copy_url|add_my_view|edit|save|rename|delete|custom_property|custom_script" ) view_select.set_option( "labels", "X Copy URL to this View|Add to My Views|Edit as Draft|Save Project View As|X Rename View|X Delete View|Add Custom Property|Add Custom Script" ) view_div.add_style("float: right") view_div.add(view_select) view_select.add_event( "onchange", "spt.dg_table.view_action_cbk(this,'%s')" % my.table_id) return view_div
def get_type_select_wdg(self, name, width=80): """ :name: String, set as the name and ID for the select widget. Should correspond to a column on the MetaData sobject :width: int, the desired width of the widget in pixels :return: SelectWdg """ select_wdg = SelectWdg(name) select_wdg.set_id(name) select_wdg.add_style('width', '{0}px'.format(width)) select_wdg.add_empty_option() types = (('(5.1) L', '5_1_l'), ('(5.1) R', '5_1_r'), ('(5.1) C', '5_1_c'), ('(5.1) Lfe', '5_1_lfe'), ('(5.1) Ls', '5_1_ls'), ('(5.1) Rs', '5_1_rs'), ('(7.1) L', '7_1_l'), ('(7.1) R', '7_1_r'), ('(7.1) C', '7_1_c'), ('(7.1) Lfe', '7_1_lfe'), ('(7.1) Ls', '7_1_ls'), ('(7.1) Rs', '7_1_rs'), ('(7.1) SBL', '7_1_sbl'), ('(7.1) SBR', '7_1_sbr'), ('(Stereo) Lt', 'stereo_lt'), ('(Stereo) Rt', 'stereo_rt'), ('(Stereo) Lt, Rt', 'stereo_lt_rt'), ('(Stereo) L', 'stereo_l'), ('(Stereo) R', 'stereo_r'), ('(Stereo) L, R', 'stereo_l_r'), ('Mono', 'mono')) for audio_type in types: type_label = audio_type[0] type_value = audio_type[1] select_wdg.append_option(type_label, type_value) # If the report was loaded from a save, and if the value is set, load it in the widget if hasattr(self, name): select_wdg.set_value(getattr(self, name)) return select_wdg
def get_package_select_wdg(self): """ Get a SelectWdg that contains all the possible packages that the component can switch to. :return: SelectWdg """ # Set up a basic select widget with an empty object package_select_wdg = SelectWdg('reassign_package_select') package_select_wdg.set_id('reassign_package_select') package_select_wdg.add_style('width', '300px') package_select_wdg.add_empty_option() # Get the packages packages = self.get_packages() # Add the package names as the labels and the codes as the values for package in packages: package_select_wdg.append_option(package.get_value('name'), package.get_code()) # Return the SelectWdg return package_select_wdg
def get_frame_rate_section(self): section_span = SpanWdg() section_span.add('Frame Rate: ') frame_rate_select = SelectWdg('frame_rate_select') frame_rate_select.set_id('frame_rate_code') frame_rate_select.add_style('width', '153px') frame_rate_select.add_style('display', 'inline-block') frame_rate_select.add_empty_option() frame_rate_search = Search('twog/frame_rate') frame_rates = frame_rate_search.get_sobjects() for frame_rate in frame_rates: frame_rate_select.append_option(frame_rate.get_value('name'), frame_rate.get_code()) if self.prequal_eval_sobject: frame_rate_select.set_value(self.prequal_eval_sobject.get_value('frame_rate_code')) section_span.add(frame_rate_select) return section_span
def get_title_select_wdg(): """ Get a SelectWdg that contains all the possible titles that the component can switch to. :return: SelectWdg """ # Set up a basic select widget with an empty object title_select_wdg = SelectWdg('title_select') title_select_wdg.set_id('title_select') title_select_wdg.add_style('width', '300px') title_select_wdg.add_empty_option() # Get the titles titles_search = Search('twog/title') titles = titles_search.get_sobjects() # Add the title names as the labels and the codes as the values for title in titles: title_select_wdg.append_option(title.get_value('name'), title.get_code()) # Return the SelectWdg return title_select_wdg
def get_true_false_select_wdg(self, name, width=80): """ Set up a select widget with True and False values, with the labels being Yes and No. Most of the MetaData report is made up of such select widgets. :name: String, set as the name and ID for the select widget. Should correspond to a column on the MetaData sobject :width: int, the desired width of the widget in pixels :return: SelectWdg """ select_wdg = SelectWdg(name) select_wdg.set_id(name) select_wdg.add_style('width', '{0}px'.format(width)) select_wdg.add_empty_option() select_wdg.append_option('Yes', True) select_wdg.append_option('No', False) # If the report was loaded from a save, and if the value is set, load it in the widget if hasattr(self, name): select_wdg.set_value(getattr(self, name)) return select_wdg
def get_file_type_wdg(my): '''drop down which selects which file type to export to''' # add a filter div = DivWdg() filter_div = FloatDivWdg(HtmlElement.b("File Type:"), width="15em") div.add(filter_div) select = SelectWdg() select.set_name("file_type") select.set_id("file_type") app = WebContainer.get_web().get_selected_app() if app == 'Maya': select.set_option("values", "mayaAscii|mayaBinary|obj|collada") select.set_option( "labels", "Maya Ascii (.ma)|Maya Binary (.mb)|Wavefront .obj|Collada (.dae)" ) elif app == 'Houdini': select.set_option("values", "otl") select.set_option("labels", "Houdini Digital Asset(.otl)") elif app == 'XSI': select.set_option("values", "emdl|dotXSI|obj") select.set_option( "labels", "3D Model (.emdl)|SoftImage dotXSI (.xsi)|Wavefront .obj") else: select.set_option("values", "mayaAscii|mayaBinary|obj|collada") select.set_option( "labels", "Maya Ascii (.ma)|Maya Binary (.mb)|Wavefront .obj|Collada (.dae)" ) select.add_style("font-size: 0.8em") select.add_style("margin-top: 5px") select.add_style("margin-right: 10px") select.set_persistence() div.add(select) return div
def get_display(self): parser = self.kwargs.get("parser") self.search_key = self.kwargs.get("search_key") sobject = Search.get_by_search_key(self.search_key) if sobject.get_base_search_type() == "sthpw/snapshot": snapshot = sobject elif sobject.get_base_search_type() == "sthpw/file": # if it is a file object snapshot = sobject.get_parent() else: snapshots = Snapshot.get_by_sobject(sobject, is_latest=True) snapshot = snapshots[0] # Extension determine UI class for preview thumb_path = snapshot.get_web_path_by_type("icon") web_src = snapshot.get_web_path_by_type("web") from pyasm.biz import File file_type = "main" lib_path = snapshot.get_lib_path_by_type(file_type) src = snapshot.get_web_path_by_type(file_type) if not web_src: web_src = src parts = os.path.splitext(src) ext = parts[1] ext = ext.lstrip(".") ext = ext.lower() #parent = snapshot.get_parent() top = self.top self.set_as_panel(top) if ext == "pdf": iframe = HtmlElement.iframe() iframe.set_attr('src', src) iframe.add_style("width: 100%") iframe.add_style("height: 800px") top.add(iframe) return top from tactic.ui.container import ResizableTableWdg table = ResizableTableWdg() top.add(table) tr = table.add_row() # These bvrs allow for smooth switching if switching between files # like in the RepoBrowserWdg tr.add_style("height: 200px") load_height_bvr = { 'type': 'load', 'cbjs_action': ''' var last_height = spt.container.get_value("last_img_height"); if (last_height) { bvr.src_el.setStyle("height", last_height); } ''' } tr.add_behavior(load_height_bvr) unload_height_bvr = { 'type': 'unload', 'cbjs_action': ''' var last_height = bvr.src_el.getStyle("height"); spt.container.set_value("last_img_height", last_height); ''' } tr.add_behavior(unload_height_bvr) table.add_style("width: 100%") table.add_style("text-align", "center") from tactic.ui.widget import EmbedWdg td = table.add_cell() td.add_color( "background", "background", ) td.add_style("vertical-align: middle") td.add_style("height: inherit") td.add_style("overflow-x: auto") if ext in ['txt', 'html', 'ini']: content_div = DivWdg() f = open(lib_path, 'r') content = f.read(10000) f.close() if not content: text = "No Content" else: size = os.path.getsize(lib_path) from pyasm.common import FormatValue value = FormatValue().get_format_value(size, "KB") content_div.add("Showing first 10K of %s<hr/>" % value) text = TextAreaWdg() text.add(content) text.add_style("width: 100%") text.add_style("height: 100%") text.add_style("padding: 10px") text.add_style("border: none") text.add_attr("readonly", "true") content_div.add(text) td.add(content_div) content_div.add_style("color", "#000") content_div.add_style("width", "auto") content_div.add_style("margin", "20px") content_div.add_style("height", "100%") elif ext in File.IMAGE_EXT or ext == "gif": if lib_path.find("#") != -1: img = DivWdg() file_range = snapshot.get_file_range() file_range_div = DivWdg() file_range_div.add("File Range: %s" % file_range.get_display()) img.add(file_range_div) file_range_div.add_style("font-size: 1.4em") file_range_div.add_style("margin: 15px 0px") """ left_chevron = IconWdg("Previous", "BS_CHEVRON_LEFT") file_range_div.add(left_chevron) right_chevron = IconWdg("Next", "BS_CHEVRON_RIGHT") file_range_div.add(right_chevron) """ expanded_paths = snapshot.get_expanded_web_paths() lib_paths = snapshot.get_expanded_lib_paths() lib_path = lib_paths[0] items_div = DivWdg() img.add(items_div) items_div.add_style("width: auto") for path in expanded_paths: item = HtmlElement.img(src=path) items_div.add(item) item.add_style("max-height: 300px") item.add_style("height: auto") item.add_style("width: 32%") item.add_style("margin: 2px") item.add_style("display: inline-block") #item.add_class("spt_resizable") img.add_style("margin: 20px") img.add_style("max-height: 400px") img.add_style("overflow-y: auto") img.add_style("overflow-hidden: auto") img.add_style("text-align: left") else: if ext == "gif": img = HtmlElement.img(src=src) else: img = HtmlElement.img(src=web_src) img.add_style("height: inherit") img.add_style("width: auto") td.add(img) elif ext in File.VIDEO_EXT: embed_wdg = EmbedWdg(src=src, thumb_path=thumb_path, preload="auto", controls=True) td.add(embed_wdg) embed_wdg.add_style("margin: auto auto") embed_wdg.add_class("spt_resizable") embed_wdg.add_behavior(load_height_bvr) embed_wdg.add_behavior(unload_height_bvr) else: thumb_table = DivWdg() td.add(thumb_table) thumb_table.add_behavior({ 'type': 'click_up', 'src': src, 'cbjs_action': ''' window.open(bvr.src); ''' }) thumb_table.add_class("hand") thumb_table.add_style("width: 200px") thumb_table.add_style("height: 125px") thumb_table.add_style("padding: 5px") thumb_table.add_style("margin-left: 20px") thumb_table.add_style("display: inline-block") thumb_table.add_style("vertical-align: top") thumb_table.add_style("overflow-y: hidden") from tactic.ui.panel import ThumbWdg2 thumb = ThumbWdg2() thumb_table.add(thumb) thumb.set_sobject(snapshot) table.add_row() td = table.add_cell() from tactic.ui.checkin import PathMetadataWdg from tactic.ui.checkin import SnapshotMetadataWdg from pyasm.widget import SelectWdg select = SelectWdg(name="parser") select.add_style("width: 125px") select.add_style("margin-top: 0px") select.add_style("margin-right: 10px") select.add_empty_option("-- Metadata --") td.add(select) select.add_style("float: right") select.set_option("values", ["IPTC", "EXIF", "XMP", "ImageMagick", "PIL"]) select.add_behavior({ 'type': 'change', 'cbjs_action': ''' var parser = bvr.src_el.value; spt.panel.refresh_element(bvr.src_el, {parser: parser}) ''' }) if parser: select.set_value(parser) title_div = DivWdg() td.add(title_div) title_div.add("<div style='font-size: 16px'>File Metadata</div>") title_div.add("<div>Metadata extracted directly from the file</div>") title_div.add("<hr/>") title_div.add_style("text-align: left") title_div.add_style("margin: 0px 10px") metadata_div = DivWdg() td.add(metadata_div) metadata_div.add_style("max-height: 400px") metadata_div.add_style("overflow-y: auto") metadata_div.add_style("overflow-x: hidden") metadata_div.add_style("margin: 20px 0px 20px 10px") metadata_div.add_style("text-align: left") use_tactic_tags = self.kwargs.get("use_tactic_tags") server_src = lib_path # get it dynamically by path metadata_wdg = PathMetadataWdg(path=server_src, parser=parser, use_tactic_tags=use_tactic_tags, search_key=self.search_key) metadata_div.add(metadata_wdg) top.add("<br/>") return top
def get_display(my): web = WebContainer.get_web() top = my.top top.add_class("spt_ace_editor_top") script = my.kwargs.get("custom_script") if script: language = script.get_value("language") else: language = my.kwargs.get("language") if not language: language = 'javascript' code = my.kwargs.get("code") if not code: code = "" show_options = my.kwargs.get("show_options") if show_options in ['false', False]: show_options = False else: show_options = True options_div = DivWdg() top.add(options_div) if not show_options: options_div.add_style("display: none") options_div.add_color("background", "background3") options_div.add_border() options_div.add_style("text-align: center") options_div.add_style("padding: 2px") select = SelectWdg("language") select.add_style("width: 100px") select.add_style("display: inline") options_div.add(select) select.add_class("spt_language") select.set_option("values", "javascript|server_js|python|expression|xml") select.add_behavior( { 'type': 'change', 'editor_id': my.get_editor_id(), 'cbjs_action': ''' spt.ace_editor.set_editor(bvr.editor_id); var value = bvr.src_el.value; spt.ace_editor.set_language(value); //register_change(bvr); ''' } ) select = SelectWdg("font_size") select.add_style("width: 100px") select.add_style("display: inline") options_div.add(select) select.set_option("labels", "8 pt|9 pt|10 pt|11 pt|12 pt|14 pt|16 pt") select.set_option("values", "8 pt|9pt|10pt|11pt|12pt|14pt|16pt") select.set_value("10pt") select.add_behavior( { 'type': 'click_up', 'editor_id': my.get_editor_id(), 'cbjs_action': ''' spt.ace_editor.set_editor(bvr.editor_id); var editor = spt.ace_editor.editor; var editor_id = spt.ace_editor.editor_id; var value = bvr.src_el.value; $(editor_id).setStyle("font-size", value) //editor.resize(); ''' } ) select = SelectWdg("keybinding") select.add_style("width: 100px") #options_div.add(select) select.set_option("labels", "Ace|Vim|Emacs") select.set_option("values", "ace|vim|emacs") select.set_value("10pt") select.add_behavior( { 'type': 'change', 'editor_id': my.get_editor_id(), 'cbjs_action': ''' spt.ace_editor.set_editor(bvr.editor_id); var editor = spt.ace_editor.editor; var editor_id = spt.ace_editor.editor_id; var vim = require("ace/keyboard/keybinding/vim").Vim; editor.setKeyboardHandler(vim) ''' } ) editor_div = DivWdg() top.add(editor_div) if code: load_div = DivWdg() top.add(load_div) readonly = my.kwargs.get("readonly") if readonly in ['true', True]: readonly = True else: readonly = False load_div.add_behavior( { 'type': 'load', 'code': code, 'language': language, 'editor_id': my.get_editor_id(), 'readonly': readonly, 'cbjs_action': ''' spt.ace_editor.set_editor(bvr.editor_id); var func = function() { var editor = spt.ace_editor.editor; var document = editor.getSession().getDocument(); if (bvr.code) { spt.ace_editor.set_value(bvr.code); } spt.ace_editor.set_language(bvr.language); editor.setReadOnly(bvr.readonly); var session = editor.getSession(); //session.setUseWrapMode(true); //session.setWrapLimitRange(120, 120); }; var editor = spt.ace_editor.editor; if (!editor) { setTimeout( func, 1000); } else { func(); } ''' } ) # theme select = SelectWdg("theme") select.add_style("width: 100px") select.add_style("display: inline") options_div.add(select) select.set_option("labels", "Eclipse|Twilight|TextMate|Vibrant Ink|Merbivore|Clouds") select.set_option("values", "eclipse|twilight|textmate|vibrant_ink|merbivore|clouds") select.set_value("twilight") select.add_behavior( { 'type': 'change', 'editor_id': my.get_editor_id(), 'cbjs_action': ''' spt.ace_editor.set_editor(bvr.editor_id); var editor = spt.ace_editor.editor; var editor_id = spt.ace_editor.editor_id; value = bvr.src_el.value; editor.setTheme("ace/theme/" + value); ''' } ) editor_div = DivWdg() top.add(editor_div) my.text_area.add_style("margin-top: -1px") my.text_area.add_style("margin-bottom: 0px") my.text_area.add_color("background", "background") my.text_area.add_style("font-family: courier new") my.text_area.add_border() editor_div.add(my.text_area) my.text_area.add_style("position: relative") #text_area.add_style("margin: 20px") size = web.get_form_value("size") if size: width, height = size.split(",") else: width = my.kwargs.get("width") if not width: width = "650px" height = my.kwargs.get("height") if not height: height = "450px" my.text_area.add_style("width: %s" % width) my.text_area.add_style("height: %s" % height) bottom_div = DivWdg() top.add(bottom_div) bottom_div.add_color("background", "background3") bottom_div.add_border() bottom_div.add_style("text-align: center") bottom_div.add_style("padding: 2px") bottom_div.add_style("height: 20px") bottom_title = "Script Editor" bottom_div.add(bottom_title) icon = IconWdg("Resize Editor", IconWdg.RESIZE_CORNER) bottom_div.add(icon) icon.add_style("float: right") icon.add_style("margin-right: -4px") icon.add_style("cursor: se-resize") icon.add_behavior( { 'type': 'drag', "cb_set_prefix": 'spt.ace_editor.drag_resize', } ) #hidden = HiddenWdg("size") hidden = TextWdg("size") bottom_div.add(hidden) hidden.add_style("width: 85px") hidden.add_style("text-align: center") hidden.add_style("float: right") hidden.add_class("spt_size") hidden.set_value("%s,%s" % (width, height)) theme = top.get_theme() if theme == 'dark': theme = 'twilight' else: theme = 'eclipse' print "theme: ", theme top.add_behavior( { 'type': 'load', 'unique_id': my.unique_id, 'theme': theme, 'cbjs_action': ''' if (typeof(ace) == 'undefined') { // fist time loading spt.ace_editor = {} spt.ace_editor.editor = null; spt.ace_editor.editor_id = bvr.unique_id; spt.ace_editor.theme = bvr.theme; spt.ace_editor.set_editor = function(editor_id) { spt.ace_editor.editor_id = editor_id; spt.ace_editor.editor = $(editor_id).editor; } spt.ace_editor.set_editor_top = function(top_el) { if (!top_el.hasClass("spt_ace_editor")) { top_el = top_el.getElement(".spt_ace_editor"); } var editor_id = top_el.getAttribute("id"); spt.ace_editor.set_editor(editor_id); } spt.ace_editor.get_editor = function() { return spt.ace_editor.editor; } spt.ace_editor.clear_selection = function() { var editor = spt.ace_editor.editor; editor.clearSelection(); } spt.ace_editor.get_selection = function() { var editor = spt.ace_editor.editor; //return editor.getSelection(); return editor.getCopyText(); } spt.ace_editor.get_value = function() { var editor = spt.ace_editor.editor; var document = editor.getSession().getDocument() var value = document.getValue(); return value; } spt.ace_editor.set_value = function(value) { var editor = spt.ace_editor.editor; var document = editor.getSession().getDocument() document.setValue(value); editor.gotoLine(2); editor.resize(); editor.focus(); } spt.ace_editor.goto_line = function(number) { var editor = spt.ace_editor.editor; var document = editor.getSession().getDocument() editor.gotoLine(2); editor.resize(); editor.focus(); } spt.ace_editor.insert = function(value) { var editor = spt.ace_editor.editor; var position = editor.getCursorPosition(); var doc = editor.getSession().getDocument() doc.insertInLine(position, value); } spt.ace_editor.insert_lines = function(values) { var editor = spt.ace_editor.editor; var position = editor.getCursorPosition(); var doc = editor.getSession().getDocument() doc.insertLines(position.row, values); } spt.ace_editor.get_document = function() { var document = spt.ace_editor.editor.getSession().getDocument() return document; } spt.ace_editor.set_language = function(value) { if (!value) { value = 'javascript'; } var editor = spt.ace_editor.editor; var top = $(spt.ace_editor.editor_id).getParent(".spt_ace_editor_top"); var lang_el = top.getElement(".spt_language"); for ( var i = 0; i < lang_el.options.length; i++ ) { if ( lang_el.options[i].value == value ) { lang_el.options[i].selected = true; break; } } var session = editor.getSession(); var mode; if (value == 'python') { mode = require("ace/mode/python").Mode; } else if (value == 'xml') { mode = require("ace/mode/xml").Mode; } else if (value == 'expression') { mode = require("ace/mode/xml").Mode; } else { mode = require("ace/mode/javascript").Mode; } session.setMode( new mode() ); } spt.ace_editor.drag_start_x; spt.ace_editor.drag_start_y; spt.ace_editor.drag_size; spt.ace_editor.drag_editor_el; spt.ace_editor.drag_size_el; spt.ace_editor.drag_resize_setup = function(evt, bvr, mouse_411) { var editor = spt.ace_editor.editor; var editor_id = spt.ace_editor.editor_id; spt.ace_editor.drag_start_x = mouse_411.curr_x; spt.ace_editor.drag_start_y = mouse_411.curr_y; var editor_el = $(editor_id); spt.ace_editor.drag_editor_el = editor_el; spt.ace_editor.drag_size = editor_el.getSize(); var top = bvr.src_el.getParent(".spt_ace_editor_top"); spt.ace_editor.drag_size_el = top.getElement(".spt_size"); } spt.ace_editor.drag_resize_motion = function(evt, bvr, mouse_411) { var diff_x = parseFloat(mouse_411.curr_x - spt.ace_editor.drag_start_x); var diff_y = parseFloat(mouse_411.curr_y - spt.ace_editor.drag_start_y); var size = spt.ace_editor.drag_size; var editor_el = spt.ace_editor.drag_editor_el; var width = size.x + diff_x if (width < 300) { width = 300; } var height = size.y + diff_y if (height < 200) { height = 200; } editor_el.setStyle("width", width); editor_el.setStyle("height", height); spt.ace_editor.drag_size_el.value = width + "," + height; var editor = spt.ace_editor.editor; editor.resize(); } var js_files = [ "ace/ace-0.2.0/src/ace.js", //"ace/ace-0.2.0/src/ace-uncompressed.js", ]; var ace_setup = function() { var editor = ace.edit(bvr.unique_id); spt.ace_editor.editor = editor; // put the editor into the dom spt.ace_editor.editor_id = bvr.unique_id; $(bvr.unique_id).editor = editor; editor.setTheme("ace/theme/" + spt.ace_editor.theme); var JavaScriptMode = require("ace/mode/javascript").Mode; editor.getSession().setMode(new JavaScriptMode()) } spt.dom.load_js(js_files, function() { ace; require; define; var core_js_files = [ "ace/ace-0.2.0/src/mode-javascript.js", "ace/ace-0.2.0/src/mode-xml.js", "ace/ace-0.2.0/src/mode-python.js", "ace/ace-0.2.0/src/theme-twilight.js", "ace/ace-0.2.0/src/theme-textmate.js", "ace/ace-0.2.0/src/theme-vibrant_ink.js", "ace/ace-0.2.0/src/theme-merbivore.js", "ace/ace-0.2.0/src/theme-clouds.js", "ace/ace-0.2.0/src/theme-eclipse.js" ]; //var supp_js_files = []; spt.dom.load_js(core_js_files, ace_setup); //spt.dom.load_js(supp_js_files); }); } else { var editor = ace.edit(bvr.unique_id); editor.setTheme("ace/theme/" + bvr.theme); var JavaScriptMode = require("ace/mode/javascript").Mode; editor.getSession().setMode(new JavaScriptMode()) spt.ace_editor.editor_id = bvr.unique_id; spt.ace_editor.editor = editor; $(bvr.unique_id).editor = editor; } ''' } ) return top