ccu.fancyplots._gui.root

The main logic for the FancyPlots root window.

The FancyPlotsGUI class encompasses the main application logic for a FancyPlots application.

In addition to the main application class, FancyPlotsGUI, this module also defines the following TypedDict subclasses:

  • Windows: A mapping whose values are the top-level subwindows of a FancyPlots GUI application.

  • Sections: A mapping whose values are subframes of the FancyPlots root window.

Example

Launch the FancyPlots GUI

import tkinter as tk
from ccu.fancyplots._gui.root import FancyPlotsGUI

root = tk.Tk()
app = FancyPlotsGUI(master=root)  # doctest: +SKIP
app.master.mainloop()  # doctest: +SKIP
class ccu.fancyplots._gui.root.FancyPlotsGUI(cache_file: ~pathlib.Path | None = None, data_file: ~pathlib.Path | None = None, style_file: ~pathlib.Path | None = None, master=<class 'tkinter.Tk'>)[source]

Bases: object

A Fancy Plots GUI application.

Variables:
  • master – The application root window - the topmost tkinter.Tk instance.

  • windows – A dictionary containing the child windows (:class`tkinter.TopLevel`) of the GUI.

  • sections – A Sections instance.

Note

FancyPlotsGUI is not a window and, as such, one cannot use it directly to manipulate properties of the GUI. For that, use FancyPlotsGUI.master <ccu.fancyplots._gui.root.FancyPlotsGUI.master>.

Launch the main GUI for FancyPlots.

Parameters:
  • cache_file – A Path pointing to a cache file. Defaults to None. If provided, it is used to pre-populate the formatting parameters, mechanism info, and annotations. Otherwise, a fresh FancyPlots application is launched.

  • data_file – A Path pointing to a data file. Defaults to None. If provided, it is used to pre-populate the free energy data. The data in this file should match the format resulting from dumping an instance of FreeEnergyDiagram to a JSON file.

  • style_file – A Path pointing to a file containing a JSON dictionary of style parameters. The dictionary will be used to construct an instance of ccu.fancyplots.data.FormattingParameters. Defaults to None in which case DEFAULT_PARAMETERS will be used.

  • master – The top level tkinter.Tk instance.

_build_cache(cache_file: Path | None = None, data_file: Path | None = None, style_file: Path | None = None) FancyCache[source]
_configure_windows() None[source]

Define subwindows and key bindings for GUI.

Parameters:

windows – A dictionary mapping names to tkinter.Toplevel instances and containing the root window.

_create_sections() Sections[source]
_initialize_windows() Windows[source]
_organize() None[source]
_quit_all() None[source]
_quit_window(key: Literal['energy_window', 'graph_window', 'tight_layout', 'instructions_window', 'matplotlib_palette'], window: Toplevel) Callable[[], None][source]
_select_all(event: Event) None[source]
_update_graph(_: Event) None[source]

Update the free energy graph.

property cache: FancyCache

Retrieve an updated account of FancyPlots’ data.

save_cache() None[source]

Save the FancyPlots cache.

class ccu.fancyplots._gui.root.Sections[source]

Bases: TypedDict

The subframes of a FancyPlotsGUI app.

Variables:

Example

>>> import tkinter as tk
>>> from ccu.fancyplots._gui.root import FancyPlotsGUI
>>> root = tk.Tk()
>>> app = FancyPlotsGUI(master=root)
    ...
>>> app.master.mainloop()
>>> app.sections[...]  
annotation: AnnotationSection
footer: FooterSection
formatting: FormattingSection
mechanism: MechanismSection
class ccu.fancyplots._gui.root.Windows[source]

Bases: TypedDict

The top-level windows of a FancyPlots GUI.

Variables:

Example

>>> import tkinter as tk
>>> from ccu.fancyplots._gui.root import FancyPlotsGUI
>>> root = tk.Tk()
>>> app = FancyPlotsGUI(master=root)
    ...
>>> app.master.mainloop()
>>> app.windows[...]  
energy_window: EnergyWindow | None
graph_window: FreeEnergyDiagram | None
instructions_window: InstructionsWindow | None
matplotlib_palette: PaletteWindow | None
tight_layout: TightFreeEnergyDiagram | None