def _create_config(self): if self._validate(): #extract the output objects from the treeview model outputs = [] model = self.outputs_treeview.get_model() row = 0 while row < len(model): outputs.append(model[row][4]) row += 1 name = self.name_entry.get_text() desc = self.desc_entry.get_text() overview = self.output_overview.get_active() db = BLLDatabase() created = None #if editing, delete previous config from DB if self.edit_config: created = self.edit_config.created self.edit_config.db_delete( db ) #this will also delete any associated outputs and entries in output_configs_to_outputs self.edit_config = None config = OutputConfig(name, desc, outputs, created, overview) config.db_insert(db) db.close() self.window.destroy() self.action_callback(config) else: UIUtils.show_message_dialog( 'Please make sure that all of the fields have been filled out.', gtk.MessageType.WARNING)
def __init__(self): self.window = gtk.Window(gtk.WindowType.TOPLEVEL) self.window.set_title('Reliability App') self.window.connect('destroy', lambda x: gtk.main_quit()) self.window.set_border_width(10) self.window.set_default_size(210, 150) box = gtk.VBox(False, 5) create_button = UIUtils.create_button('Create Check', UIUtils.BUTTON_ICONS.CREATE) create_button.connect('clicked', lambda widget, data=None: CreateWindow()) box.pack_start(create_button, False, False, 0) create_button.show() load_button = UIUtils.create_button('Load Check', UIUtils.BUTTON_ICONS.RUN) load_button.connect('clicked', lambda widget, data=None: LoadWindow()) box.pack_start(load_button, False, False, 0) load_button.show() exit_button = UIUtils.create_button('Exit', UIUtils.BUTTON_ICONS.EXIT) exit_button.connect('clicked', lambda widget: gtk.main_quit()) box.pack_start(exit_button, False, False, 0) exit_button.show() self.window.add(box) box.show() self.window.show()
def _ok(self): filters = self._get_filters() if self._validate_filters(filters): self.window.destroy() self.callback(filters) else: UIUtils.show_message_dialog('Please make sure that all combo boxes are set, with the exception of the last "conjunction" box.')
def __init__(self): self.window = gtk.Window(gtk.WindowType.TOPLEVEL) self.window.set_title('TRS Splitter') self.window.connect('destroy', lambda w: gtk.main_quit()) self.window.set_border_width(10) self.window.set_default_size(150, 100) box = gtk.VBox(False, 5) split_button = UIUtils.create_button('Split File', UIUtils.BUTTON_ICONS.SPLIT) split_button.connect('clicked', lambda w: self.split_file()) box.pack_start(split_button, False, False, 0) split_button.show() merge_button = UIUtils.create_button('Merge Files', UIUtils.BUTTON_ICONS.MERGE) merge_button.connect('clicked', lambda w: self.merge_files()) box.pack_start(merge_button, False, False, 0) merge_button.show() exit_button = UIUtils.create_button('Exit', UIUtils.BUTTON_ICONS.EXIT) exit_button.connect('clicked', lambda w: gtk.main_quit()) box.pack_start(exit_button, False, False, 0) exit_button.show() self.window.add(box) box.show() self.window.show()
def _finish(self): if self._validate_cur_test(): self.save_input(mark_last_run=True, mark_as_completed=True) filename, check_results = UIUtils.save_file( filters=[UIUtils.CSV_FILE_FILTER], open_now_opt=True, save_last_location=True) if filename: exporter = ReliabilityExporter(self.check, filename) if exporter.export(): if check_results: subprocess.Popen([ '%s' % DBConstants.SETTINGS.SPREADSHEET_PATH, filename ]) else: UIUtils.show_message_dialog( 'Results exported successfully.') self._exit(False) #we have already saved above else: UIUtils.show_message_dialog( 'An error occurred while exporting the results. These results are still saved in the database, and can be exported at a later time, pending the correction of this problem. Please bother the programmer until this happens.' )
def _remove_output(self): model, it = self.outputs_treeview.get_selection().get_selected() if it: if UIUtils.show_confirm_dialog( 'Are you sure you want to delete this output?'): model.remove(it) else: UIUtils.show_message_dialog('Please select a row.', gtk.MessageType.WARNING)
def _build_treeview(self): list_store = gtk.ListStore( gobject.TYPE_INT, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, ) db = BLLDatabase() check2s_list = Check2.db_select(db) for check2 in check2s_list: created = UIUtils.get_db_timestamp_str(check2.created) modified = '-' #don't display modification date if it is the same as creation date if check2.modified != None and check2.modified != check2.created: modified = UIUtils.get_db_timestamp_str(check2.modified) completed = '-' if check2.completed != None: completed = UIUtils.get_db_timestamp_str(check2.completed) list_store.append([ check2.db_id, check2.csv_filename, check2.wav_foldername, completed, created, modified, ]) db.close() treeview = gtk.TreeView(list_store) #create the hidden id column col = gtk.TreeViewColumn('ID', gtk.CellRendererText(), text=0) col.set_visible(False) treeview.append_column(col) #create the rest of the columns column_names = [ 'CSV File', 'WAV Folder', 'Completed', 'Created', 'Modified' ] for i in range(len(column_names)): col = gtk.TreeViewColumn(column_names[i], gtk.CellRendererText(), text=(i + 1)) col.set_resizable(True) col.set_min_width( UIUtils.calc_treeview_col_min_width(column_names[i])) treeview.append_column(col) return treeview
def _edit_output(self): model, it = self.outputs_treeview.get_selection().get_selected() if it: OutputWindow( lambda edited_output: self._edit_output_callback( edited_output, it), model.get(it, 4)[0]) else: UIUtils.show_message_dialog('Please select a row.', gtk.MessageType.WARNING)
def __init__(self, app_name, app_type, app_icon_filename=None): self.app_type = app_type BackendUtils.setup_logging( 'logs/%s.log' % (app_name) ) if app_type == App.APP_TYPES.GUI: # this sets some project-wide GTK settings and # sets the app-specific window icon UIUtils.setup_gtk(app_icon_filename)
def _edit_config(self, treeview): model, it = treeview.get_selection().get_selected() if it: config = model.get(it, 4)[0] ConfigWindow( lambda edited_config: self._edit_callback( treeview.get_model(), edited_config, it), config) else: UIUtils.show_message_dialog('Please select a row.', gtk.MessageTYpe.WARNING)
def save_and_export(self): if self._check_completion(): checkbuttons = [] include_trans_check = gtk.CheckButton('Include Transcription') checkbuttons.append(include_trans_check) open_now_check = gtk.CheckButton('Open Immediately') open_now_check.set_active(True) checkbuttons.append(open_now_check) filename, results = UIUtils.show_file_dialog_with_checks( 'Save File', [UIUtils.CSV_FILE_FILTER, UIUtils.ALL_FILE_FILTER], gtk.FileChooserAction.SAVE, gtk.STOCK_SAVE, checkbuttons, save_last_location=True) if filename: progress_dialog = ProgressDialog( title='Saving...', phases=[ 'Saving records to DB', 'Matching DB records to rows', 'Writing rows to file' ]) progress_dialog.show() self.save(True, progress_dialog) progress_dialog.next_phase() if not filename.lower().endswith('.csv'): filename += '.csv' exporter = Reliability2Exporter(filename, self.check2) exporter.export( results[0], progress_update_fcn=progress_dialog.set_fraction, progress_next_fcn=progress_dialog.next_phase) exporter.close() progress_dialog.ensure_finish() self.handler_man.block_handler(self.window, 'destroy') self.window.destroy() #note: there is no need for a corresponding self.handler_man.unblock_handler() call, since the object the handler is operating upon (the window) is destroyed) #show immediately, if requested if results[1]: subprocess.Popen([ '%s' % DBConstants.SETTINGS.SPREADSHEET_PATH, filename ]) else: UIUtils.show_message_dialog( 'Results exported successfully!')
def _add_filter(self, existing_filter=None): hbox = gtk.HBox(spacing=5) #remove non-visible columns from the column dropdown's list filtered_headers = [''] filtered_vals = [-1] for i in range(len(self.col_headers)): if self.col_headers[i] != '' and self.col_headers[i] != '# segments' and self.col_headers[i] != 'id': filtered_headers.append(self.col_headers[i]) filtered_vals.append(i - 1) col_combo = UIUtils.build_simple_combo( (str, int), filtered_headers, filtered_vals, ) col_combo.set_active(self._find_combo_index(col_combo, existing_filter.col_index, 1) if existing_filter else 0) ops_combo = UIUtils.build_simple_combo( (str, int), FilterWindow.Filter.OPS, range(len(FilterWindow.Filter.OPS)), ) ops_combo.set_active(self._find_combo_index(ops_combo, existing_filter.op, 0) if existing_filter else 0) val_entry = gtk.Entry() val_entry.set_width_chars(10) val_entry.connect('activate', lambda w: self._ok()) #connect the 'enter' button press (make it equivalent to clicking ok) val_entry.set_text(existing_filter.val if existing_filter else '') conjuncts_combo = UIUtils.build_simple_combo( (str, int), FilterWindow.Filter.CONJUNCTS, range(len(FilterWindow.Filter.CONJUNCTS)), ) conjuncts_combo.set_active(self._find_combo_index(conjuncts_combo, existing_filter.conjunct, 0) if existing_filter else 0) conjuncts_combo.connect('changed', lambda w: self._conjunct_changed(w, hbox)) del_button = gtk.Button(stock=gtk.STOCK_REMOVE) del_button.connect('clicked', lambda w: self._remove_filter(hbox)) hbox.pack_start(col_combo, False, False, 0) hbox.pack_start(ops_combo, False, False, 0) hbox.pack_start(val_entry, False, False, 0) hbox.pack_start(conjuncts_combo, False, False, 0) hbox.pack_start(del_button, False, False, 0) self.filters_vbox.pack_start(hbox, False, False, 0) self.add_button.hide() hbox.show_all()
def __init__(self): self.window = gtk.Window(gtk.WindowType.TOPLEVEL) self.window.set_title('Statistics Application') self.window.set_border_width(10) self.window.set_default_size(600, 450) self.window.connect('destroy', lambda x: gtk.main_quit()) vbox = gtk.VBox() treeview = self._build_treeview() scrolled_win = gtk.ScrolledWindow() scrolled_win.set_policy(gtk.PolicyType.AUTOMATIC, gtk.PolicyType.AUTOMATIC) scrolled_win.add(treeview) vbox.pack_start(scrolled_win, True, True, 0) button_box = gtk.HButtonBox() button_box.set_layout(gtk.ButtonBoxStyle.EDGE) create_button = UIUtils.create_button('Create Configuration', UIUtils.BUTTON_ICONS.CREATE) create_button.connect( 'clicked', lambda w: ConfigWindow(lambda new_config: self._add_callback( treeview.get_model(), new_config))) button_box.pack_start(create_button, True, True, 0) edit_button = UIUtils.create_button('Edit Configuration', UIUtils.BUTTON_ICONS.EDIT) edit_button.connect('clicked', lambda w: self._edit_config(treeview)) button_box.pack_start(edit_button, True, True, 0) run_button = UIUtils.create_button('Run Configuration', UIUtils.BUTTON_ICONS.RUN) run_button.connect('clicked', lambda w: self._run_config(treeview)) button_box.pack_start(run_button, True, True, 0) delete_button = UIUtils.create_button('Delete', UIUtils.BUTTON_ICONS.DELETE) delete_button.connect('clicked', lambda w: self._delete_config(treeview)) button_box.pack_start(delete_button, True, True, 0) exit_button = UIUtils.create_button('Exit', UIUtils.BUTTON_ICONS.EXIT) exit_button.connect('clicked', lambda w: gtk.main_quit()) button_box.pack_start(exit_button, True, True, 0) vbox.pack_end(button_box, False, False, 0) self.window.add(vbox) self.window.show_all()
def _build_window(self): vbox = gtk.VBox() #table = gtk.Table(2,3, False) grid = gtk.Grid() src_label = gtk.Label('Source:') #table.attach(src_label, 0, 1, 0, 1, gtk.EXPAND, gtk.EXPAND) grid.attach(src_label, 0, 0, 1, 1) src_entry = gtk.Entry() src_entry.set_width_chars(50) #table.attach(src_entry, 1, 2, 0, 1, gtk.EXPAND, gtk.EXPAND) grid.attach(src_entry, 1, 0, 1, 1) src_browse_button = gtk.Button('Browse') #table.attach(src_browse_button, 2, 3, 0, 1, gtk.EXPAND, gtk.EXPAND) grid.attach(src_browse_button, 2, 0, 1, 1) if self.filter_type == FilterWindow.FILTER_TYPES.FILE: src_browse_button.connect('clicked', lambda w: UIUtils.browse_file('Select file', src_entry, [UIUtils.CSV_FILE_FILTER, UIUtils.ALL_FILE_FILTER])) elif self.filter_type == FilterWindow.FILTER_TYPES.FOLDER: src_browse_button.connect('clicked', lambda w: UIUtils.browse_folder('Select folder', src_entry)) #[UIUtils.CSV_FILE_FILTER, UIUtils.ALL_FILE_FILTER])) dest_label = gtk.Label('Destination:') #table.attach(dest_label, 0, 1, 1, 2, gtk.EXPAND, gtk.EXPAND) grid.attach(dest_label, 0, 1, 1, 1) dest_entry = gtk.Entry() dest_entry.set_width_chars(50) #table.attach(dest_entry, 1, 2, 1, 2, gtk.EXPAND, gtk.EXPAND) grid.attach(dest_entry, 1, 1, 1, 1) dest_browse_button = gtk.Button('Browse') #table.attach(dest_browse_button, 2, 3, 1, 2, gtk.EXPAND, gtk.EXPAND) grid.attach(dest_browse_button, 2, 1, 1, 1) dest_browse_button.connect('clicked', lambda w: UIUtils.browse_folder('Select folder', dest_entry))#, [UIUtils.CSV_FILE_FILTER, UIUtils.ALL_FILE_FILTER])) vbox.pack_start(grid, True, True, 0) button_box = gtk.HButtonBox() button_box.set_layout(gtk.ButtonBoxStyle.EDGE) cancel_button = gtk.Button(stock=gtk.STOCK_CANCEL, label='Cancel') cancel_button.connect('clicked', lambda w: self.window.destroy()) button_box.add(cancel_button) ok_button = gtk.Button(stock=gtk.STOCK_OK, label='Ok') ok_button.connect('clicked', lambda w: self._process(src_entry.get_text(), dest_entry.get_text())) button_box.add(ok_button) vbox.pack_start(button_box, True, True, 0) self.window.add(vbox)
def _export(self, treeview, col_headers, db): write_filename, open_now = UIUtils.save_file(filters=[UIUtils.CSV_FILE_FILTER, UIUtils.ALL_FILE_FILTER], open_now_opt=True) if write_filename: #if they didn't click cancel #lag_time_cutoff = float( UIUtils.show_entry_dialog(None, 'Lag time cutoff for counts: ', default_text='2', validate_regex=r'^-?\d+(\.\d+)?$', invalid_msg='Please enter a number.') ) lag_time_cutoff = 2.0 if write_filename and lag_time_cutoff != None: #if user did not click cancel (note: lag time cutoff could be 0) if not write_filename.lower().endswith('.csv'): write_filename += '.csv' try: csv_file = open(write_filename, 'wb') writer = csv.writer(csv_file, quoting=csv.QUOTE_ALL) cols = treeview.get_columns() visible_col_indices = filter(lambda i: cols[i].get_visible(), range(len(cols))) filtered_headers = [col_headers[i] for i in visible_col_indices] writer.writerow(filtered_headers) progress_dialog = ProgressDialog(title='Exporting to file', phases=['Exporting...']) progress_dialog.show() num_rows = len(treeview.get_model()) row_index = 1 #this is awkward, but there is no way to pull all the rows out of the model in one shot, so we have to use a non-indexed for loop and manually track the index for row in treeview.get_model(): filtered_row = [row[i] for i in visible_col_indices] writer.writerow(filtered_row) progress_dialog.set_fraction(float(row_index) / float(num_rows)) row_index += 1 # export_stats = self._get_export_stats(lag_time_cutoff, db, col_headers) # if export_stats: # for row in export_stats: # writer.writerow(row) progress_dialog.ensure_finish() csv_file.close() if open_now: subprocess.Popen(['%s' % DBConstants.SETTINGS.SPREADSHEET_PATH, write_filename]) else: UIUtils.show_message_dialog('Data exported successfully.') #UIUtils.show_message_dialog('Data export completed.') except Exception as err: UIUtils.show_message_dialog('Unable to export data - please make sure the destination file is not already open in another program.') raise err
def _load(self, treeview): (model, it) = treeview.get_selection().get_selected() db_id = model.get_value(it, 0) if it else None if db_id != None: db = BLLDatabase() check = Check.db_select(db, [db_id])[0] db.close() self.window.destroy() TestWindow(check) else: UIUtils.show_no_sel_dialog()
def _create_output(self, filters_frame, options_frame): if options_frame.validate() and self._validate(): name = self.name_entry.get_text() desc = self.desc_entry.get_text() filters = filters_frame.get_filters() calc = options_frame.get_output_calc() chained = options_frame.get_seg_linkage() output = Output(name, desc, filters, calc, chained) self.action_callback(output) self.window.destroy() else: UIUtils.show_empty_form_dialog()
def load_check(self, treeview): model, sel_paths = treeview.get_selection().get_selected_rows() if sel_paths: it = model.get_iter(sel_paths[0]) check2_id = model.get_value(it, 0) db = BLLDatabase() check2 = Check2.db_select(db, ids=[check2_id])[0] db.close() TestWindow(check2) self.window.destroy() else: UIUtils.show_no_sel_dialog()
def _delete_config(self, treeview): model, it = treeview.get_selection().get_selected() if it: if UIUtils.show_confirm_dialog( 'Are you sure you want to delete this configuration?'): config = model.get(it, 4)[0] model.remove(it) if config.db_id != None: db = BLLDatabase() config.db_delete(db) db.close() else: UIUtils.show_no_sel_dialog()
def _process(self, src, dest): in_files = None out_files = None if src and os.path.exists(src): src = src.replace('\\', '/') if self.filter_type == FilterWindow.FILTER_TYPES.FILE: if not src.endswith('.csv'): src += '.csv' elif self.filter_type == FilterWindow.FILTER_TYPES.FOLDER: if src.endswith('/'): src = src[:-1] if os.path.isdir(src): in_files = map(lambda name: name.replace('\\', '/'), glob.glob('%s/*.csv' % (src))) else: in_files = [src] else: UIUtils.show_message_dialog('Source path does not exist!') return if dest and os.path.exists(dest): dest = dest.replace('\\', '/') if dest.endswith('/'): dest = dest[:-1] out_files = map(lambda name: '%s/%s-noNaps.csv' % (dest, os.path.basename(name)[:-4]), in_files) else: UIUtils.show_message_dialog('Destination path does not exist!') return self.window.destroy() prog_diag = ProgressDialog( title='Processing...', phases=['Please Wait'] ) prog_diag.show() db = BLLDatabase() for i in range(len(in_files)): Naptime.filter_file(db, in_files[i], out_files[i]) prog_diag.set_fraction(float(i + 1) / float(len(in_files))) db.close() prog_diag.ensure_finish()
def _get_test_grid(self, db): grid = gtk.Grid() self.progress = gtk.ProgressBar() self.progress.set_orientation(gtk.Orientation.HORIZONTAL) self.progress.set_fraction(self.order_num + 1 / float(self._get_num_clips(db))) #self.progress.set_vexpand(False) #self.progress.set_vexpand_set(True) grid.attach(self.progress, 0, 0, 5, 1) #self.label = gtk.Label('Clip %d of %d' % (self.order_num + 1, self._get_num_clips(db))) #UIUtils.set_font_size(self.label, 25, bold=True) #self.label.set_hexpand(True) #self.label.set_hexpand_set(True) #grid.attach(self.label, 0, 0, 5, 1) question_label = gtk.Label( 'How much does this sentence sound like a question?') UIUtils.set_font_size(question_label, 30, bold=True) grid.attach(question_label, 0, 1, 5, 1) self.playing_icon = gtk.Image() self.playing_icon.set_vexpand(True) self.playing_icon.set_vexpand_set(True) self._toggle_playing_icon(False) grid.attach(self.playing_icon, 0, 2, 5, 1) self.scale_buttons = [] button_grid = gtk.Grid() button_grid.set_column_homogeneous(True) label_low = gtk.Label('Not Very Much like a Question') label_low.set_alignment(0, 0) UIUtils.set_font_size(label_low, 20, bold=True) button_grid.attach(label_low, 0, 0, 2, 1) label_high = gtk.Label('Very Much like a Question') label_high.set_alignment(1, 0) UIUtils.set_font_size(label_high, 20, bold=True) button_grid.attach(label_high, self.props.num_options - 2, 0, 2, 1) for i in range(self.props.num_options): button = gtk.Button('\n' + str(i + 1) + '\n') UIUtils.set_font_size(button, 15, bold=True) button.connect('button-release-event', lambda w, e: self._next(db, int(w.get_label()))) button.set_vexpand(False) button.set_vexpand_set(False) self.scale_buttons.append(button) button.set_hexpand(True) button.set_hexpand_set(True) button_grid.attach(button, i, 1, 1, 1) grid.attach(button_grid, 0, 3, 5, 1) return grid
def _build_toolbar(self, db, treeview, col_headers): toolbar = gtk.Toolbar() clear_img_path = UIUtils.get_icon_path(UIUtils.BUTTON_ICONS.CLEAR, UIUtils.BUTTON_ICON_SIZES.PX16) #clear_pixbuf = gtk.gdk.pixbuf_new_from_file(clear_img_path) clear_pixbuf = GdkPixbuf.Pixbuf.new_from_file(clear_img_path) search_entry = gtk.Entry() search_entry.set_sensitive(False) search_entry.set_text(FilterWindow.get_filters_desc(self.filters, col_headers)) filter_button = UIUtils.create_button('Filters', UIUtils.BUTTON_ICONS.FILTER, UIUtils.BUTTON_ICON_SIZES.PX16) filter_button.connect('clicked', lambda w: self._update_filters(db, treeview.get_model(), col_headers, search_entry)) play_button = UIUtils.create_button('Play', UIUtils.BUTTON_ICONS.PLAY, UIUtils.BUTTON_ICON_SIZES.PX16) play_button.connect('clicked', lambda w: self._play_selected_row(col_headers, treeview)) praat_button = UIUtils.create_button('Praat', UIUtils.BUTTON_ICONS.PRAAT, UIUtils.BUTTON_ICON_SIZES.PX16) praat_button.connect('clicked', lambda w: self._open_in_praat(col_headers, treeview)) export_button = UIUtils.create_button('Export', UIUtils.BUTTON_ICONS.EXPORT, UIUtils.BUTTON_ICON_SIZES.PX16) export_button.connect('clicked', lambda w: self._export(treeview, col_headers, db)) context_label = gtk.Label('Context') context_adj = gtk.Adjustment(value=0, lower=0, upper=99, step_increment=1) self.context_spinner = gtk.SpinButton() self.context_spinner.set_adjustment(context_adj) self.context_spinner.set_numeric(True) spacer = gtk.SeparatorToolItem() spacer.set_draw(False) #don't draw a vertical line spacer.set_expand(True) filter_label = gtk.Label('Filter state:') for widget in [filter_label, search_entry, filter_button, praat_button, play_button, self.context_spinner, context_label]: tool_item = gtk.ToolItem() tool_item.add(widget) if widget == search_entry: tool_item.set_expand(True) toolbar.insert(tool_item, -1) toolbar.insert(spacer, -1) tool_item = gtk.ToolItem() tool_item.add(export_button) toolbar.insert(tool_item, -1) return toolbar
def _build_wo_context_frame(self): cur_test = self.check.tests[self.check.test_index] frame = gtk.Frame(label='Without Context') #table = gtk.Table(1, 3, False) grid = gtk.Grid() self.wo_form.play_button = UIUtils.create_button( '', UIUtils.BUTTON_ICONS.PLAY, UIUtils.BUTTON_ICON_SIZES.PX32) self.wo_form.handler_man.add_handler(self.wo_form.play_button, 'clicked', lambda w: self.play_seg(0)) #table.attach(self.wo_form.play_button, 0, 1, 0, 1, gtk.EXPAND, gtk.EXPAND) grid.attach(self.wo_form.play_button, 0, 0, 1, 1) syllables_label = gtk.Label('Syllables:') syllables_adj = gtk.Adjustment(value=0, lower=0, upper=1000, step_incr=1, page_incr=5) self.wo_form.syllables_spinner = gtk.SpinButton(syllables_adj) #table.attach(syllables_label, 1, 2, 0, 1, gtk.EXPAND, gtk.EXPAND) grid.attach(syllables_label, 1, 0, 1, 1) #table.attach(self.wo_form.syllables_spinner, 2, 3, 0, 1, gtk.EXPAND, gtk.EXPAND) grid.attach(self.wo_form.syllables_spinner, 2, 0, 1, 1) frame.add(grid) return frame
def _build_button_box(self): box = gtk.HButtonBox() box.set_layout(gtk.ButtonBoxStyle.EDGE) self.button_form.back_button = gtk.Button(stock=gtk.STOCK_GO_BACK) self.button_form.handler_man.add_handler(self.button_form.back_button, 'clicked', lambda w: self._back()) self.button_form.save_button = UIUtils.create_button( 'Save & Exit', UIUtils.BUTTON_ICONS.SAVE, UIUtils.BUTTON_ICON_SIZES.PX32) self.button_form.handler_man.add_handler(self.button_form.save_button, 'clicked', lambda w: self._exit()) self.button_form.forward_button = gtk.Button( stock=gtk.STOCK_GO_FORWARD) self.button_form.handler_man.add_handler( self.button_form.forward_button, 'clicked', lambda w: self._forward()) self._update_step_buttons() box.pack_start(self.button_form.back_button, False, False, 0) box.pack_start(self.button_form.save_button, False, False, 0) box.pack_end(self.button_form.forward_button, False, False, 0) return box
def open_file(self): filename = UIUtils.open_file('Select trs file', [UIUtils.TRS_FILE_FILTER, UIUtils.ALL_FILE_FILTER]) if filename: progress_dialog = ProgressDialog('Processing File...', ['Parsing trs file...', 'Validating data...', 'Building UI...']) progress_dialog.show() VerificationWindow(filename, progress_dialog)
def _build_treeview(self): list_store = self._build_list_store() treeview = gtk.TreeView(list_store) #create hidden id column col = gtk.TreeViewColumn('ID', gtk.CellRendererText(), text=0) col.set_visible(False) treeview.append_column(col) #create the rest of the columns column_names = [ 'Name', 'Created', 'Completed', 'Last Run', 'Input Filename', 'WAV Filename', 'Default Context padding (sec)', 'Pick Segs Randomly', 'Filters' ] for i in range(len(column_names)): col = gtk.TreeViewColumn(column_names[i], gtk.CellRendererText(), text=(i + 1)) col.set_resizable(True) col.set_min_width( UIUtils.calc_treeview_col_min_width(column_names[i])) treeview.append_column(col) return treeview
def _build_list_store(self): list_store = gtk.ListStore( gobject.TYPE_STRING, #name gobject.TYPE_STRING, #description gobject.TYPE_STRING, #created timestamp gobject.TYPE_STRING, #output names gobject.TYPE_PYOBJECT, #hidden object ) db = BLLDatabase() configs = OutputConfig.db_select(db) for cur_config in configs: output_names = self._get_output_names_str(cur_config.outputs) created_str = UIUtils.get_db_timestamp_str( cur_config.created) if cur_config.created else '-' list_store.append([ cur_config.name, cur_config.desc, created_str, output_names, cur_config, ]) db.close() return list_store
def _build_button_box(self): button_box = gtk.HButtonBox() button_box.set_layout(gtk.ButtonBoxStyle.EDGE) back_button = gtk.Button(stock=gtk.STOCK_GO_BACK) button_box.add(back_button) save_button = UIUtils.create_button('Save & Exit', UIUtils.BUTTON_ICONS.SAVE, UIUtils.BUTTON_ICON_SIZES.PX32) button_box.add(save_button) next_button = gtk.Button(stock=gtk.STOCK_GO_FORWARD) button_box.add(next_button) next_handler = lambda w: self.next_test2(back_button, next_button) if self.check2.test2_index >= len(self.check2.test2s) - 1: next_button.set_label(gtk.STOCK_OK) next_handler = lambda w: self.save_and_export() self.handler_man.add_handler(next_button, 'clicked', next_handler) self.handler_man.add_handler( back_button, 'clicked', lambda w: self.back_test2(back_button, next_button)) self.handler_man.add_handler( save_button, 'clicked', lambda w: self.window.destroy() ) #this will call save_and_exit() since the window 'destroy' signal is connected to that method (see constructor) back_button.set_sensitive(self.check2.test2_index > 0) next_button.set_sensitive( self.check2.test2_index < len(self.check2.test2s)) return button_box
def _build_list_store(self): list_store = gtk.ListStore( gobject.TYPE_INT, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_INT, gobject.TYPE_STRING, gobject.TYPE_STRING, ) db = BLLDatabase() checks_list = Check.db_select(db) for check in checks_list: created = UIUtils.get_db_timestamp_str(str( check.created)) if check.created != None else '-' last_run = UIUtils.get_db_timestamp_str(str( check.last_run)) if check.last_run != None else '-' completed = UIUtils.get_db_timestamp_str(str( check.completed)) if check.completed != None else '-' filters_str = '' if not check.filters: filters_str = '-' else: for i in range(len(check.filters)): filters_str += check.filters[i].get_filter_desc_str() if i < len(check.filters) - 1: filters_str += ',\n' list_store.append([ check.db_id, check.name, created, completed, last_run, check.input_filename, check.wav_filename, check.default_context_padding, str(check.pick_randomly), filters_str, ]) db.close() return list_store
def main(): input_foldername = UIUtils.open_folder(title='Select Source Folder') output_foldername = None if input_foldername: output_foldername = UIUtils.open_folder( title='Select Destination Folder') if not input_foldername or not output_foldername: exit() csv_filenames = filter(lambda name: name.lower().endswith('.csv'), os.listdir(input_foldername)) for filename in csv_filenames: process_file(input_foldername + '\\' + filename, output_foldername + '\\' + filename) print 'Filtering complete.'