def choose_marker(marker=None, all_markers=None, change_param=True): global services if marker != None: return marker markers_box = gtk.combo_box_new_text() if not all_markers: all_markers = biology.markers.get_marker_names() for name in all_markers: markers_box.append_text(name) markers_box.show() dia = gtk.Dialog( 'Marker Picker', services.get_top_widget(), gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, #binary flags or'ed together (gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) dia.vbox.pack_start(gtk.Label('Pick A marker')) dia.vbox.pack_start(markers_box) dia.show() result = dia.run() dia.destroy() if result == gtk.RESPONSE_OK: #res = biology.markers.marker_from_name(markers_box.get_active_text()) res = markers_box.get_active_text() if change_param: services.get_current_changer().set_parameter(0, repr(res)) return res elif result == gtk.RESPONSE_CANCEL: return None
def choose_marker(marker=None, all_markers=None, change_param=True): global services if marker != None: return marker markers_box = gtk.combo_box_new_text() if not all_markers: all_markers = biology.markers.get_marker_names() for name in all_markers: markers_box.append_text(name) markers_box.show() dia = gtk.Dialog('Marker Picker', services.get_top_widget(), gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, #binary flags or'ed together (gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) dia.vbox.pack_start(gtk.Label('Pick A marker')) dia.vbox.pack_start(markers_box) dia.show() result = dia.run() dia.destroy() if result == gtk.RESPONSE_OK: #res = biology.markers.marker_from_name(markers_box.get_active_text()) res = markers_box.get_active_text() if change_param: services.get_current_changer().set_parameter(0, repr(res)) return res elif result == gtk.RESPONSE_CANCEL: return None
def choose_file(filename=None): if filename != None: return filename def run_dialog_gui(): dialog = gtk.FileChooserDialog( title='Choose file', action=gtk.FILE_CHOOSER_ACTION_OPEN, buttons=( gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK)) dialog.set_default_response(gtk.RESPONSE_OK) filename = None if dialog.run() == gtk.RESPONSE_OK: filename = dialog.get_filename() dialog.destroy() return filename synced_run_dialog_gui = create_sync_wrapper(run_dialog_gui) filename = synced_run_dialog_gui() if not filename: raise Exception('No file chosen') global services services.get_current_changer().set_parameter(0, "r'%s'" % filename) return filename
def cache(data): def update_params(changer, data): new_choices = [] for i in xrange(len(data.option_lists)): choices_for_list = [] for j in xrange(len(data.option_lists[i])): if(data.tree_store[(i,j)][1]): choices_for_list.append(data.option_lists[i][j]) new_choices.append(choices_for_list) expanded = [data.tree_view.row_expanded((i)) for i in xrange(len(data.titles))] changer.set_parameter_by_name('choices', repr(new_choices)) changer.set_parameter_by_name('expanded_titles', repr(expanded)) changer.set_parameter_by_name('expanded_titles', repr(expanded)) def apply_clicked(button, data, changer): update_params(changer, data) services.replay_script() def row_expanded_collapsed(treeview, iter, path, data, changer): update_params(changer, data) def row_toggled(cell, path, data, changer): data.button.show() parent = data.tree_store[path].parent if parent: data.tree_store[path][1] = not data.tree_store[path][1] update_title_values(parent, data) else: new_val = not any([child[1] for child in data.tree_store[path].iterchildren()]) for child in data.tree_store[path].iterchildren(): child[1] = new_val update_title_values(data.tree_store[path], data) update_params(changer, data) data.tree_store = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_BOOLEAN, gobject.TYPE_BOOLEAN) data.tree_view = gtk.TreeView(data.tree_store) data.tree_view.connect('row_expanded', row_expanded_collapsed, data, services.get_current_changer()) data.tree_view.connect('row_collapsed', row_expanded_collapsed, data, services.get_current_changer()) data.tree_view.set_headers_visible(False) data.renderer_toggle = gtk.CellRendererToggle() data.renderer_toggle.set_property('activatable', True) data.renderer_toggle.connect('toggled', row_toggled, data, services.get_current_changer()) data.renderer_text = gtk.CellRendererText() data.renderer_text.set_property('wrap-width', 220) data.column0 = gtk.TreeViewColumn("Item", data.renderer_text, text=0) data.column1 = gtk.TreeViewColumn("Selected", data.renderer_toggle, active=1, inconsistent=2) # TODO: add inconsistent here #data.renderer_text.set_fixed_size(250,-1) data.tree_view.append_column(data.column0) data.tree_view.append_column(data.column1) data.vbox = gtk.VBox() data.vbox.pack_start(data.tree_view) data.button = gtk.Button('Apply') data.button.connect('clicked', apply_clicked, data, services.get_current_changer()) data.vbox.pack_start(data.button) data.tree_view.show() data.vbox.show() data.title_label = services.add_widget_in_control_box(control_title, data.vbox)
def cache(data): def button_click(button, changer): new_file = file_dialog(title, filename and os.path.dirname(filename)) if new_file: changer.set_parameter_by_name('filename', repr(new_file)) services.replay_script() data.button = gtk.Button(label=filename) data.button.set_size_request(250,-1) data.button.connect('clicked', button_click, services.get_current_changer()) data.title_label = services.add_widget_in_control_box(title, data.button)
def cache(data): def changed(combobox, changer): changer.set_parameter(0, repr(combobox.get_active_text())) services.replay_script() data.box = gtk.combo_box_new_text() for option in options: data.box.append_text(option) data.handler_id = data.box.connect( 'changed', changed, services.get_current_changer()) #data.slider.set_size_request(150,-1) data.title_label = services.add_widget_in_control_box(title, data.box)
def cache(data): def button_release(range, event, changer): changer.set_parameter(0, range.get_value()) services.replay_script() data.slider = gtk.HScale() data.slider.set_value_pos(gtk.POS_LEFT) data.slider.set_range(min_val, max_val) data.slider.connect( 'button-release-event', button_release, services.get_current_changer()) #data.slider.set_size_request(150,-1) data.title_label = services.add_widget_in_control_box(title, data.slider)
def cache(data): def changed(combobox, changer): changer.set_parameter(0, repr(combobox.get_active_text())) services.replay_script() data.box = gtk.combo_box_new_text() for option in options: data.box.append_text(option) data.handler_id = data.box.connect('changed', changed, services.get_current_changer()) #data.slider.set_size_request(150,-1) data.title_label = services.add_widget_in_control_box(title, data.box)
def cache(data): def button_release(range, event, changer): changer.set_parameter(0, range.get_value()) services.replay_script() data.slider = gtk.HScale() data.slider.set_value_pos(gtk.POS_LEFT) data.slider.set_range(min_val, max_val) data.slider.connect('button-release-event', button_release, services.get_current_changer()) #data.slider.set_size_request(150,-1) data.title_label = services.add_widget_in_control_box( title, data.slider)
def cache(data): def button_click(button, changer): new_file = file_dialog(title, filename and os.path.dirname(filename)) if new_file: changer.set_parameter_by_name('filename', repr(new_file)) services.replay_script() data.button = gtk.Button(label=filename) data.button.set_size_request(250, -1) data.button.connect('clicked', button_click, services.get_current_changer()) data.title_label = services.add_widget_in_control_box( title, data.button)
def __init__(self, ax, all_markers, rect_range, color_label, only_x=False, no_selection=False): self.all_markers = all_markers self.ax = ax self.color_label = color_label self.rect = None self.press = None self.ignore_next_on_press = False self.only_x = only_x self.no_selection = no_selection if not self.no_selection: self.renew_rect(rect_range) self.connect() global services self.changer = services.get_current_changer()
def choose_file(filename=None): if filename != None: return filename def run_dialog_gui(): dialog = gtk.FileChooserDialog( title='Choose file', action=gtk.FILE_CHOOSER_ACTION_OPEN, buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK)) dialog.set_default_response(gtk.RESPONSE_OK) filename = None if dialog.run() == gtk.RESPONSE_OK: filename = dialog.get_filename() dialog.destroy() return filename synced_run_dialog_gui = create_sync_wrapper(run_dialog_gui) filename = synced_run_dialog_gui() if not filename: raise Exception('No file chosen') global services services.get_current_changer().set_parameter(0, "r'%s'" % filename) return filename
def __init__(self, ax, dims): self.ax = ax self.changer = services.get_current_changer() self.cidrelease = self.ax.figure.canvas.mpl_connect( 'button_release_event', self.on_release) self.dims = dims
def cache(data): def update_params(changer, data): new_choices = [] for i in xrange(len(data.option_lists)): choices_for_list = [] for j in xrange(len(data.option_lists[i])): if (data.tree_store[(i, j)][1]): choices_for_list.append(data.option_lists[i][j]) new_choices.append(choices_for_list) expanded = [ data.tree_view.row_expanded((i)) for i in xrange(len(data.titles)) ] changer.set_parameter_by_name('choices', repr(new_choices)) changer.set_parameter_by_name('expanded_titles', repr(expanded)) changer.set_parameter_by_name('expanded_titles', repr(expanded)) def apply_clicked(button, data, changer): update_params(changer, data) services.replay_script() def row_expanded_collapsed(treeview, iter, path, data, changer): update_params(changer, data) def row_toggled(cell, path, data, changer): data.button.show() parent = data.tree_store[path].parent if parent: data.tree_store[path][1] = not data.tree_store[path][1] update_title_values(parent, data) else: new_val = not any([ child[1] for child in data.tree_store[path].iterchildren() ]) for child in data.tree_store[path].iterchildren(): child[1] = new_val update_title_values(data.tree_store[path], data) update_params(changer, data) data.tree_store = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_BOOLEAN, gobject.TYPE_BOOLEAN) data.tree_view = gtk.TreeView(data.tree_store) data.tree_view.connect('row_expanded', row_expanded_collapsed, data, services.get_current_changer()) data.tree_view.connect('row_collapsed', row_expanded_collapsed, data, services.get_current_changer()) data.tree_view.set_headers_visible(False) data.renderer_toggle = gtk.CellRendererToggle() data.renderer_toggle.set_property('activatable', True) data.renderer_toggle.connect('toggled', row_toggled, data, services.get_current_changer()) data.renderer_text = gtk.CellRendererText() data.renderer_text.set_property('wrap-width', 220) data.column0 = gtk.TreeViewColumn("Item", data.renderer_text, text=0) data.column1 = gtk.TreeViewColumn( "Selected", data.renderer_toggle, active=1, inconsistent=2) # TODO: add inconsistent here #data.renderer_text.set_fixed_size(250,-1) data.tree_view.append_column(data.column0) data.tree_view.append_column(data.column1) data.vbox = gtk.VBox() data.vbox.pack_start(data.tree_view) data.button = gtk.Button('Apply') data.button.connect('clicked', apply_clicked, data, services.get_current_changer()) data.vbox.pack_start(data.button) data.tree_view.show() data.vbox.show() data.title_label = services.add_widget_in_control_box( control_title, data.vbox)