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: Toplevel

Define free energies for mechanism paths.

Variables:
  • dropdown – A tk.OptionMenu for selecting the pathway to configure.

  • energy_definition_frame – A ttk.Frame containing ttk.Entry and ttk.Label instances for defining free energies.

  • free_energy_entries – A dictionary mapping mechanism step names to the ttk.Entry widget.

  • 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.StringVar instances in control of the ttk.Entry widgets which record the free energies of the mechanism step.

  • legend_entry – The ttk.Entry for defining the legend text for the current pathway.

  • legend_label – The ttk.Label for defining the legend text for the current pathway.

  • parent – A MechanismSection

  • path_var – A tk.StringVar recording 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.

_configure_key_bindings() None[source]

Configure key bindings for the widget.

_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_labels and ccu.fancyplots._gui.energy.EnergyWindow.free_energy_entries in place.

Returns:

The ttk.Frame in 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 a ttk.Label and ttk.Entry, respectively.

_make_dropdown() tuple[StringVar, OptionMenu][source]

Create a dropdown menu for selecting reaction pathways.

Returns:

A 2-tuple (var, menu) representing the tkinter.StringVar storing the value of the active reation pathway and the option menu.

_organize() None[source]
_organize_free_energy_widgets() None[source]

Organize the free energy widgets into an x-by-2 grid.

property options: list[str]

The options (pathways) for the option menu.

property pathway

The pathway indicated by the dropdown selection.

property pathway_index

The index of pathway indicated by the dropdown.

quit_window() None[source]

Gracefully quit the window and save data.

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_index is 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_index is used.

update_widgets(_) None[source]

Update the energy and legend Entry widgets.

Developer’s Note

This should be the only place that EnergyWindow._previous_pathway is 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 the EnergyWindow._previous_pathway attribute and manually manage it here.