def __init__(self, title, field_content, record_specs,field_specs,show_refs,initial_media_dir,
                        pp_home_dir,pp_profile_dir,initial_tab,callback):

        self.callback=callback
        self.frame_width=800   # frame for 2 columns
        self.col_width=400     # width of a column
        self.field_width= 200  # width of data field, label must fit in col_width-field_width- 15
        self.fields_height=300
        self.rows_in_col=15
        self.tab_height=100
        self.okcancel_height=100


        super(WebEditItem, self).__init__('<b>'+title+'</b>','',width=self.frame_width+700,height=self.fields_height+self.tab_height+self.okcancel_height,
                                          confirm_name='OK',cancel_name='Cancel')

        self.field_content = field_content   # dictionary - the track parameters to be edited and returned
                                                                 # key is field name e.g. omx-window
        self.record_specs= record_specs  # list of field names and seps/tabs in the order that they appear
        self.field_specs=field_specs          # dictionary of specs referenced by field name
        
        self.show_refs=show_refs            # used for droppdown of list of shows
        self.show_refs.append('')
        
        self.initial_media_dir=initial_media_dir
        self.pp_home_dir=pp_home_dir
        self.pp_profile_dir=pp_profile_dir
        self.initial_tab=initial_tab


        # create a Tabbed Editor
        self.tabview= TabView(self.frame_width,self.fields_height,30)


        # tabs are created dynamically from pp_definitions.py
        # get fields for this record using the record type in the loaded record
        record_fields=self.record_specs[self.field_content['type']]

        # init results of building the form
        self.tab_row=1 # row on form
        self.field_objs=[]  # list of field objects in record fields order, not for sep or tab
        self.field_index=0 # index to self.field_objs incremented after each field except tab and sep
                                        # can be used as an index to self.field_objs and self.button_objs
        self.button_objs=[]   # list of button objects in record field order , not for sep or tab =None for non-buttons
        
        self.col_row=0
        self.current_col=None
        self.col_1=None
        # populate the dialog box using the record fields to determine the order
        for field in record_fields:
            # get list of values where required
            values=[]
            if self.field_specs[field]['shape']in("option-menu",'spinbox'):
                # print 'should be field name', field
                # print 'should be shape',self.field_specs[field]['shape']
                if field in ('sub-show','start-show'):
                    values=self.show_refs                    
                else:
                    values=self.field_specs[field]['values']
            else:
                values=[]
            # make the entry
            obj,button=self.make_entry(field,self.field_specs[field],values)
            if obj is not  None:
                self.field_objs.append(obj)
                self.button_objs.append(button)
                self.field_index +=1

        #construct the tabview
        self.tabview.construct_tabview()
        
        # frame for tabbed editor
        self.root_frame = gui.HBox(width=self.tabview.get_width() + 100, height=self.fields_height+self.tab_height) #1
        self.root_frame.append(self.tabview,key='switch')
        self.append_field(self.root_frame,'cont')

        #adjust width of dialog box
        self.style['width']=gui.to_pix(self.tabview.get_width() + 100)
         
        return None
Exemplo n.º 2
0
    def __init__(self, title, field_content, record_specs,field_specs,show_refs,initial_media_dir,
                        pp_home_dir,initial_tab,callback):

        self.callback=callback
        self.frame_width=450
        self.frame_height=400
        self.field_width= 250
        self.ffn_width=400
        self.ffn_height=300

        super(WebEditItem, self).__init__('<b>'+title+'</b>','',width=self.ffn_width+700,height=600,autohide_ok=False)

        self.field_content = field_content   # dictionary - the track parameters to be edited and returned
                                                                 # key is field name e.g. omx-window
        self.record_specs= record_specs  # list of field names and seps/tabs in the order that they appear
        self.field_specs=field_specs          # dictionary of specs referenced by field name
        
        self.show_refs=show_refs            # used for droppdown of list of shows
        self.show_refs.append('')
        
        self.initial_media_dir=initial_media_dir
        self.pp_home_dir=pp_home_dir
        self.initial_tab=initial_tab

        # Create a File Folder Navigator in a frame
        self.ffn = gui.FileFolderNavigator(False,self.initial_media_dir,True,False)#width=self.ffn_width, height=self.ffn_height

        # with some buttons
        self.ffn_select=gui.Button('Select',width=100,height=30)
        self.ffn_cancel=gui.Button('Cancel',width=100,height=30)
        self.ffn_select.set_on_click_listener(self,'on_fileselection_dialog_select')
        self.ffn_cancel.set_on_click_listener(self,'on_fileselection_dialog_cancel')
        self.ffn_button_frame=gui.HBox(width=self.ffn_width+60,height=30)
        self.ffn_button_frame.append(self.ffn_cancel)
        self.ffn_button_frame.append(self.ffn_select)

        # and error label for ffn
        self.ffn_error=gui.Label('',width=self.ffn_width,height=20)

        # frame for ffn and buttons
        self.ffn_frame=gui.VBox(width=self.ffn_width+60, height=self.ffn_height+90) #10
        self.ffn_frame.append(self.ffn,key='ffn')
        self.ffn_frame.append(self.ffn_error,key='ffn_error')
        self.ffn_frame.append(self.ffn_button_frame,key='ffn_buttons')

  

        # create a Tabbed Editor
        self.tabview= TabView(self.frame_width,self.frame_height,30)


        # tabs are created dynamically from pp_definitions.py
        # get fields for this record using the record type in the loaded record
        record_fields=self.record_specs[self.field_content['type']]

        # init results of building the form
        self.tab_row=1 # row on form
        self.field_objs=[]  # list of field objects in record fields order, not for sep or tab
        self.field_index=0 # index to self.field_objs incremented after each field except tab and sep
                                        # can be used as an index to self.field_objs and self.button_objs
        self.button_objs=[]   # list of button objects in record field order , not for sep or tab =None for non-buttons
        
        # populate the dialog box using the record fields to determine the order
        for field in record_fields:
            # get list of values where required
            values=[]
            if self.field_specs[field]['shape']in("option-menu",'spinbox'):
                # print 'should be field name', field
                # print 'should be shape',self.field_specs[field]['shape']
                if field in ('sub-show','start-show'):
                    values=self.show_refs                    
                else:
                    values=self.field_specs[field]['values']
            else:
                values=[]
            # make the entry
            obj,button=self.make_entry(field,self.field_specs[field],values)
            if obj is not  None:
                self.field_objs.append(obj)
                self.button_objs.append(button)
                self.field_index +=1

        #construct the tabview
        self.tabview.construct_tabview()
        
        # frame for file navigator and tabbed editor
        # conent of frame is switched between ffn and tabview
        self.root = gui.HBox(width=self.tabview.get_width() + 100, height=self.frame_height+ 100) #1
        self.root.append(self.tabview,key='switch')
        self.add_field('cont',self.root)

        #adjust width of diaolg box
        self.style['width']=gui.to_pix(self.tabview.get_width() + 200)
        
        self.set_on_confirm_dialog_listener(self,'confirm')      
        return None