Esempio n. 1
0
def _add_update_events(subplot: plt_axes.Subplot, dna_helix_graph: nx.DiGraph,
                       nucleotide_plots: Dict[Nucleotide, _NUCLEOTIDE_PLOT]):
    subplot.figure.canvas.mpl_connect(
        'draw_event', lambda x: subplot.pchanged())
    subplot.figure.canvas.mpl_connect(
        'resize_event', lambda x: subplot.pchanged())

    text_initial_position = list(nucleotide_plots.values())[0].body.center
    text_object = subplot.text(
        text_initial_position[0], text_initial_position[1], "",
        ha="right", va="top", ma="left",
        bbox=dict(facecolor='white', edgecolor='blue', pad=5.0))
    text_object.set_visible(False)

    subplot.figure.canvas.mpl_connect(
        'button_press_event',
        partial(_remove_nucleotide_info_text, text_object=text_object))
    subplot.figure.canvas.mpl_connect(
        'pick_event',
        partial(_draw_nucleotide_info, dna_helix_graph=dna_helix_graph,
                text_object=text_object, subplot=subplot))