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:
objectA Fancy Plots GUI application.
- Variables:
master – The application root window - the topmost
tkinter.Tkinstance.windows – A dictionary containing the child windows (:class`tkinter.TopLevel`) of the GUI.
sections – A
Sectionsinstance.
Note
FancyPlotsGUIis not a window and, as such, one cannot use it directly to manipulate properties of the GUI. For that, useFancyPlotsGUI.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
FreeEnergyDiagramto 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 caseDEFAULT_PARAMETERSwill be used.master – The top level
tkinter.Tkinstance.
- _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.Toplevelinstances and containing the root window.
- _quit_window(key: Literal['energy_window', 'graph_window', 'tight_layout', 'instructions_window', 'matplotlib_palette'], window: Toplevel) Callable[[], None][source]¶
- property cache: FancyCache¶
Retrieve an updated account of FancyPlots’ data.
- class ccu.fancyplots._gui.root.Sections[source]¶
Bases:
TypedDictThe subframes of a FancyPlotsGUI app.
- Variables:
formatting (ccu.fancyplots._gui.formatting.FormattingSection) – The subsection for defining plot formatting parameters.
mechanism (ccu.fancyplots._gui.mechanism.MechanismSection) – The subsection for defining reaction free energies and legend labels.
footer (ccu.fancyplots._gui.footer.FooterSection) – The subsection for miscelleneous support (e.g., instructions, graph viewing/saving.)
annotation (ccu.fancyplots._gui.annotation.AnnotationSection) – The subsection for defining graph annotations.
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¶
- formatting: FormattingSection¶
- mechanism: MechanismSection¶
- class ccu.fancyplots._gui.root.Windows[source]¶
Bases:
TypedDictThe top-level windows of a FancyPlots GUI.
- Variables:
energy_window (ccu.fancyplots._gui.energy.EnergyWindow | None) – The
tkinter.Toplevelinstance for defining Gibbs free energies.graph_window (ccu.fancyplots._gui.fed.FreeEnergyDiagram | None) – The
tkinter.Toplevelinstance for viewing the free energy diagram.tight_layout (ccu.fancyplots._gui.fed.TightFreeEnergyDiagram | None) – The
tkinter.Toplevelinstance for viewing the free energy diagram in a tight layout.instructions_window (ccu.fancyplots._gui.instructions.InstructionsWindow | None) – The
tkinter.Toplevelinstance for viewing the instructions for using FancyPlots.matplotlib_palette (ccu.fancyplots._gui.palette.PaletteWindow | None) – The
tkinter.Toplevelinstance for viewing the instructions for viewing thematplotlibcolour palette.
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¶