Example #1
0
    def __init__(self,
                 title='File dialog',
                 message='Select files and folders',
                 multiple_selection=True,
                 selection_folder='.',
                 allow_file_selection=True,
                 allow_folder_selection=True,
                 confirm_name='OK',
                 cancel_name='Cancel',
                 callback=None,
                 **kwargs):
        super(FileSelectionDialog, self).__init__(title, message, confirm_name,
                                                  cancel_name, **kwargs)

        self.callback = callback
        self.style['width'] = '475px'
        self.fileFolderNavigator = gui.FileFolderNavigator(
            multiple_selection, selection_folder, allow_file_selection,
            allow_folder_selection)
        self.append_field(self.fileFolderNavigator, 'fileFolderNavigator')
Example #2
0
 def test_init(self):
     widget = gui.FileFolderNavigator(multiple_selection=True,
                                      selection_folder='/',
                                      allow_file_selection=True, 
                                      allow_folder_selection=True)
     assertValidHTML(widget.repr())
Example #3
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