def setup_check_column(title, colnr): col = new_toggle_column(title, toggled_callback=(self.specimen_tv_toggled, (store, colnr)), data_func=toggle_renderer, resizable=False, expand=False, activatable=True, active_col=colnr) setattr(col, "colnr", colnr) widget.append_column(col)
def setup_treeview_col_c_visible(self, treeview, name, col_descr, col_index, tv_col_nr): def toggle_renderer(column, cell, model, itr, data=None): try: col = column.get_col_attr("active") value = model.get_value(itr, col) cell.set_property('active', not_none(value, False)) except TypeError: if settings.DEBUG: raise pass col = new_toggle_column(" ", toggled_callback=(self.on_marker_visible_toggled, (treeview.get_model(), col_index)), data_func=toggle_renderer, resizable=False, expand=False, activatable=True, active_col=col_index) setattr(col, "colnr", col_index) treeview.append_column(col) return True
def setup_treeview_col_c_visible(self, treeview, name, col_descr, col_index, tv_col_nr): def toggle_renderer(column, cell, model, itr, data=None): try: col = column.get_col_attr("active") value = model.get_value(itr, col) cell.set_property('active', not_none(value, False)) except TypeError: if settings.DEBUG: raise pass col = new_toggle_column( " ", toggled_callback=(self.on_marker_visible_toggled, (treeview.get_model(), col_index)), data_func=toggle_renderer, resizable=False, expand=False, activatable=True, active_col=col_index) setattr(col, "colnr", col_index) treeview.append_column(col) return True
def setup_refinables_tree_view(self, store, widget): """ Setup refinables TreeView layout """ widget.set_show_expanders(True) if sys.platform == "win32": def get_label(column, cell, model, itr, user_data=None): ref_prop = model.get_tree_node_object(itr) cell.set_property("text", ref_prop.text_title) return widget.append_column(new_text_column('Name/Prop', xalign=0.0, data_func=get_label)) else: # Labels are parsed for mathtext markup into pb's: def get_pb(column, cell, model, itr, user_data=None): ref_prop = model.get_tree_node_object(itr) try: if not hasattr(ref_prop, "pb") or not ref_prop.pb: ref_prop.pb = create_pb_from_mathtext( ref_prop.title, align='left', weight='medium' ) cell.set_property("pixbuf", ref_prop.pb) except RuntimeError: logger.warning("An error occured when trying to convert a property title to a PixBuf") raise return widget.append_column(new_pb_column('Name/Prop', xalign=0.0, data_func=get_pb)) # Editable floats: def get_value(column, cell, model, itr, *args): col = column.get_col_attr('markup') try: value = model.get_value(itr, col) value = "%.5f" % value except TypeError: value = "" cell.set_property("markup", value) return def on_float_edited(rend, path, new_text, model, col): itr = model.get_iter(path) try: model.set_value(itr, col, float(new_text)) except ValueError: return False return True def_float_args = { "sensitive_col": store.c_refinable, "editable_col": store.c_refinable, "visible_col": store.c_refinable, "data_func": get_value } widget.append_column(new_text_column( "Value", markup_col=store.c_value, edited_callback=( on_float_edited, (store, store.c_value,) ), **def_float_args )) widget.append_column(new_text_column( "Min", markup_col=store.c_value_min, edited_callback=( on_float_edited, (store, store.c_value_min,) ), **def_float_args )) widget.append_column(new_text_column( "Max", markup_col=store.c_value_max, edited_callback=( on_float_edited, (store, store.c_value_max,) ), **def_float_args )) # The 'refine' checkbox: widget.append_column(new_toggle_column( "Refine", toggled_callback=(self.refine_toggled, (store,)), resizable=False, expand=False, active_col=store.c_refine, sensitive_col=store.c_refinable, activatable_col=store.c_refinable, visible_col=store.c_refinable ))
def setup_refinables_tree_view(self, store, widget): """ Setup refinables TreeView layout """ widget.set_show_expanders(True) if sys.platform == "win32": def get_label(column, cell, model, itr, user_data=None): ref_prop = model.get_tree_node_object(itr) cell.set_property("text", ref_prop.get_text_title()) return widget.append_column(new_text_column('Name/Prop', xalign=0.0, data_func=get_label)) else: # Labels are parsed for mathtext markup into pb's: def get_pb(column, cell, model, itr, user_data=None): ref_prop = model.get_tree_node_object(itr) try: if not hasattr(ref_prop, "pb") or not ref_prop.pb: ref_prop.pb = create_pb_from_mathtext( ref_prop.title, align='left', weight='medium' ) cell.set_property("pixbuf", ref_prop.pb) except RuntimeError: logger.warning("An error occured when trying to convert a property title to a PixBuf") raise return widget.append_column(new_pb_column('Name/Prop', xalign=0.0, data_func=get_pb)) # Editable floats: def get_value(column, cell, model, itr, *args): col = column.get_col_attr('markup') try: value = model.get_value(itr, col) value = "%.5f" % value except TypeError: value = "" cell.set_property("markup", value) return def on_float_edited(rend, path, new_text, model, col): itr = model.get_iter(path) try: model.set_value(itr, col, float(new_text)) except ValueError: return False return True def_float_args = { "sensitive_col": store.c_refinable, "editable_col": store.c_refinable, "visible_col": store.c_refinable, "data_func": get_value } widget.append_column(new_text_column( "Value", markup_col=store.c_value, edited_callback=( on_float_edited, (store, store.c_value,) ), **def_float_args )) widget.append_column(new_text_column( "Min", markup_col=store.c_value_min, edited_callback=( on_float_edited, (store, store.c_value_min,) ), **def_float_args )) widget.append_column(new_text_column( "Max", markup_col=store.c_value_max, edited_callback=( on_float_edited, (store, store.c_value_max,) ), **def_float_args )) # The 'refine' checkbox: widget.append_column(new_toggle_column( "Refine", toggled_callback=(self.refine_toggled, (store,)), resizable=False, expand=False, active_col=store.c_refine, sensitive_col=store.c_refinable, activatable_col=store.c_refinable, visible_col=store.c_refinable ))