def __init__(self, filename, dest_folder): self.filename = filename self.dest_folder = dest_folder self.window = gtk.Window(gtk.WindowType.TOPLEVEL) self.window.set_title('Select Options') self.window.set_border_width(10) self.window.set_default_size(150, 100) vbox = gtk.VBox() entry_box, hours_spinner, mins_spinner, secs_spinner = UIUtils.get_time_spinners( mins=15) button_box = gtk.HButtonBox() cancel_button = gtk.Button(stock=gtk.STOCK_CANCEL) cancel_button.connect('clicked', lambda w: self.window.destroy()) button_box.pack_start(cancel_button, True, True, 0) ok_button = gtk.Button(stock=gtk.STOCK_OK) ok_button.connect( 'clicked', lambda w: self.split_file(hours_spinner.get_value_as_int(), mins_spinner.get_value_as_int(), secs_spinner.get_value_as_int())) button_box.pack_start(ok_button, True, True, 0) button_box.set_layout(gtk.ButtonBoxStyle.EDGE) vbox.pack_start( gtk.Label( 'Please enter a length for the split segments (hour:min:sec):' ), True, True, 0) vbox.pack_start(entry_box, True, True, 0) vbox.pack_end(button_box, True, True, 0) self.window.add(vbox) self.window.show_all()
def _update_add_inputs(self, vbox): #remove previous children map(lambda child: vbox.remove(child), vbox.get_children()) self.inputs_dict['type_inputs'] = [] #get new combo value sel_opt = self.inputs_dict['filter_type'][1]() options = DBConstants.COMBO_OPTIONS[ DBConstants.COMBO_GROUPS.SEG_FILTER_TYPES] #add new children, based on new filter type if sel_opt == options.SPEAKER: treeview = self._build_codes_treeview( DBConstants.COMBO_GROUPS.SPEAKER_CODES, 'Select Speaker Codes:') vbox.pack_start(treeview, True, True, 0) self.inputs_dict['type_inputs'].append( (lambda: len( self._get_treeview_combo_opts( treeview, DBConstants.COMBO_GROUPS.SPEAKER_CODES)) > 0, lambda: self._get_treeview_combo_opts( treeview, DBConstants.COMBO_GROUPS.SPEAKER_CODES))) elif sel_opt == options.TIME: #table = gtk.Table(2, 2) grid = gtk.Grid() criteria_label = gtk.Label('Criteria:') #criteria_label.set_alignment(xalign=1.0, yalign=0.5) #table.attach(criteria_label, 0, 1, 0, 1) grid.attach(criteria_label, 0, 0, 1, 1) criteria_combo = UIUtils.build_options_combo( DBConstants.COMBO_GROUPS.SEG_FILTER_TIME) #table.attach(criteria_combo, 1, 2, 0, 1) grid.attach(criteria_combo, 1, 0, 1, 1) self.inputs_dict['type_inputs'].append( (lambda: criteria_combo.get_active() > 0, lambda: criteria_combo.get_model()[criteria_combo.get_active()][1])) time_label = gtk.Label('Time (h:m:s):') #time_label.set_alignment(xalign=1.0, yalign=0.5) #table.attach(time_label, 0, 1, 1, 2) grid.attach(time_label, 0, 1, 1, 1) time_inputs_box, hours_spinner, mins_spinner, secs_spinner = UIUtils.get_time_spinners( ) self.inputs_dict['type_inputs'].append( (lambda: hours_spinner.get_value_as_int() > 0 or mins_spinner. get_value_as_int() > 0 or secs_spinner.get_value_as_int() > 0, lambda: hours_spinner.get_value_as_int( ) * 60 * 60 + mins_spinner.get_value_as_int( ) * 60 + secs_spinner.get_value_as_int())) #table.attach(time_inputs_box, 1, 2, 1, 2) grid.attach(time_inputs_box, 1, 1, 1, 1) vbox.pack_start(grid, True, True, 0) elif sel_opt == options.SPEAKER_TYPE: treeview = self._build_codes_treeview( DBConstants.COMBO_GROUPS.SPEAKER_TYPES, 'Select Speaker Types:') vbox.pack_start(treeview, True, True, 0) self.inputs_dict['type_inputs'].append( (lambda: len( self._get_treeview_combo_opts( treeview, DBConstants.COMBO_GROUPS.SPEAKER_TYPES)) > 0, lambda: self._get_treeview_combo_opts( treeview, DBConstants.COMBO_GROUPS.SPEAKER_TYPES))) elif sel_opt == options.TARGET_LISTENER: treeview = self._build_codes_treeview( DBConstants.COMBO_GROUPS.TARGET_LISTENERS, 'Select Target Listeners:') vbox.pack_start(treeview, True, True, 0) self.inputs_dict['type_inputs'].append((lambda: len( self._get_treeview_combo_opts( treeview, DBConstants.COMBO_GROUPS.TARGET_LISTENERS) ) > 0, lambda: self._get_treeview_combo_opts( treeview, DBConstants.COMBO_GROUPS.TARGET_LISTENERS))) elif sel_opt == options.GRAMMATICALITY: treeview = self._build_codes_treeview( DBConstants.COMBO_GROUPS.GRAMMATICALITY, 'Select Grammaticality/Completeness options:') vbox.pack_start(treeview, True, True, 0) self.inputs_dict['type_inputs'].append((lambda: len( self._get_treeview_combo_opts( treeview, DBConstants.COMBO_GROUPS.GRAMMATICALITY) ) > 0, lambda: self._get_treeview_combo_opts( treeview, DBConstants.COMBO_GROUPS.GRAMMATICALITY))) elif sel_opt == options.UTTERANCE_TYPE: treeview = self._build_codes_treeview( DBConstants.COMBO_GROUPS.UTTERANCE_TYPES, 'Select Utterance Types:') vbox.pack_start(treeview, True, True, 0) self.inputs_dict['type_inputs'].append((lambda: len( self._get_treeview_combo_opts( treeview, DBConstants.COMBO_GROUPS.UTTERANCE_TYPES) ) > 0, lambda: self._get_treeview_combo_opts( treeview, DBConstants.COMBO_GROUPS.UTTERANCE_TYPES))) vbox.show_all()