def _toggle_playing_icon(self, is_on): icon = UIUtils.BUTTON_ICONS.VOLUME_OFF if is_on: icon = UIUtils.BUTTON_ICONS.VOLUME_ON icon_path = UIUtils.get_icon_path(icon, UIUtils.BUTTON_ICON_SIZES.PX64) self.playing_icon.set_from_file(icon_path) while gtk.events_pending(): gtk.main_iteration()
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_toolbar(self): toolbar = gtk.Toolbar() toolbar.set_orientation(gtk.Orientation.HORIZONTAL) filter_errors_button = gtk.ToggleToolButton() filter_errors_button.set_active( True ) #set this before the connecting the clicked handler so it doesn't cause trouble filter_errors_button.connect( 'toggled', lambda w: self.toggle_filter_errors(w.get_active())) filter_errors_icon = gtk.Image() filter_errors_icon.set_from_file( UIUtils.get_icon_path(UIUtils.BUTTON_ICONS.FLAG)) filter_errors_button.set_label('Show Errors Only') filter_errors_button.set_icon_widget(filter_errors_icon) expand_button = gtk.ToolButton() expand_icon = gtk.Image() expand_icon.set_from_file( UIUtils.get_icon_path(UIUtils.BUTTON_ICONS.EXPAND)) expand_button.set_label('Expand All') expand_button.set_icon_widget(expand_icon) expand_button.connect('clicked', lambda w: self.treeview.expand_all()) collapse_button = gtk.ToolButton() collapse_icon = gtk.Image() collapse_icon.set_from_file( UIUtils.get_icon_path(UIUtils.BUTTON_ICONS.COLLAPSE)) collapse_button.set_label('Collapse All') collapse_button.set_icon_widget(collapse_icon) collapse_button.connect('clicked', lambda w: self.treeview.collapse_all()) rescan_button = gtk.ToolButton() rescan_icon = gtk.Image() rescan_icon.set_from_file( UIUtils.get_icon_path(UIUtils.BUTTON_ICONS.REFRESH)) rescan_button.set_label('Rescan File') rescan_button.set_icon_widget(rescan_icon) rescan_button.connect('clicked', lambda w: self._rescan_file()) play_seg_button = gtk.ToolButton() play_icon = gtk.Image() play_icon.set_from_file( UIUtils.get_icon_path(UIUtils.BUTTON_ICONS.PLAY)) play_seg_button.set_label('Play Seg') play_seg_button.set_icon_widget(play_icon) play_seg_button.connect('clicked', lambda w: self.play_selected_seg()) close_button = gtk.ToolButton() close_icon = gtk.Image() close_icon.set_from_file( UIUtils.get_icon_path(UIUtils.BUTTON_ICONS.CLOSE)) close_button.set_label('Close') close_button.set_icon_widget(close_icon) close_button.connect('clicked', lambda w: self.window.destroy()) exit_button = gtk.ToolButton() exit_icon = gtk.Image() exit_icon.set_from_file( UIUtils.get_icon_path(UIUtils.BUTTON_ICONS.EXIT)) exit_button.set_label('Exit') exit_button.set_icon_widget(exit_icon) exit_button.connect('clicked', lambda w: gtk.main_quit()) toolbar.insert(filter_errors_button, -1) toolbar.insert(expand_button, -1) toolbar.insert(collapse_button, -1) toolbar.insert(gtk.SeparatorToolItem(), -1) toolbar.insert(play_seg_button, -1) toolbar.insert(rescan_button, -1) toolbar.insert(gtk.SeparatorToolItem(), -1) toolbar.insert(close_button, -1) toolbar.insert(exit_button, -1) return toolbar