ccu.fancyplots._gui.energy¶
GUI elements for defining free energies in a mechanism.
This module defines the EnergyWindow class.
- class ccu.fancyplots._gui.energy.EnergyWindow(parent: MechanismSection, *args, **kwargs)[source]¶
Bases:
ToplevelDefine free energies for mechanism paths.
- Variables:
dropdown – A
tk.OptionMenufor selecting the pathway to configure.energy_definition_frame – A
ttk.Framecontainingttk.Entryandttk.Labelinstances for defining free energies.free_energy_entries – A dictionary mapping mechanism step names to the
ttk.Entrywidget.free_energy_labels – A dictionary mapping mechanism step names to the labeling widget.
free_energy_vars – A dictionary mapping mechanism step names to the
tkinter.StringVarinstances in control of thettk.Entrywidgets which record the free energies of the mechanism step.legend_entry – The
ttk.Entryfor defining the legend text for the current pathway.legend_label – The
ttk.Labelfor defining the legend text for the current pathway.parent – A
MechanismSectionpath_var – A
tk.StringVarrecording the name of the pathway for which energies are being defined.
Create and launch a window for specifying free energies.
- Parameters:
parent – The parent
mechanism.MechanismSection.*args – Positional arguments for
tkinter.Toplevel.**kwargs – Keyword arguments fo
tkinter.Toplevel.
- _create_free_energy_widgets() Frame[source]¶
Create widgets for specifying the free energies of each path.
This method modifies
ccu.fancyplots._gui.energy.EnergyWindow.free_energy_labelsandccu.fancyplots._gui.energy.EnergyWindow.free_energy_entriesin place.- Returns:
The
ttk.Framein which the free energy widgets reside.
- _create_legend_widgets() tuple[Label, Entry, StringVar][source]¶
Create the widgets for specifying legend labels.
- Returns:
A 2-tuple (
label,entry) whose first and second elements are attk.Labelandttk.Entry, respectively.
- _make_dropdown() tuple[StringVar, OptionMenu][source]¶
Create a dropdown menu for selecting reaction pathways.
- Returns:
A 2-tuple (
var,menu) representing thetkinter.StringVarstoring the value of the active reation pathway and the option menu.
- property pathway¶
The pathway indicated by the dropdown selection.
- property pathway_index¶
The index of pathway indicated by the dropdown.
- save_energy_data(index: int | None = None) None[source]¶
Update FED data with the values from
EnergyWindow.free_energy_entries.- Parameters:
index – The index of the pathway to update with the current widget values. Defaults to None, in which case,
EnergyWindow.pathway_indexis used.
- save_legend_data(index: int | None = None) None[source]¶
Save the legend label for the present pathway and return True.
- Parameters:
index – The index of the pathway to update with the current widget values. Defaults to None, in which case,
EnergyWindow.pathway_indexis used.
- update_widgets(_) None[source]¶
Update the energy and legend
Entrywidgets.Developer’s Note
This should be the only place that
EnergyWindow._previous_pathwayis edited. Unlike other Tkinter widgets whose callbacks allow for the specification of state-dependent variables (e.g., the name of the triggering widget, the value before the action, etc.), the OptionMenu callback is always called without arguments. This makes it difficult to update the parameters before changing the values because the value in the option menu is already changed when the callback is called. A workaround is to duplicate the state of the shown option in theEnergyWindow._previous_pathwayattribute and manually manage it here.