ccu.fancyplots.gui package¶
A subpackage for the FancyPlots GUI.
The FancyPlots GUI can be launched programatically a via the following idiom:
import tkinter as tk
from ccu.fancyplots.gui.root import FancyPlotsGUI
root = tk.Tk()
app = FancyPlotsGUI(master=root)
app.master.mainloop()
Alternatively, the GUI can be launched from the command line, via the ccu-fancyplots subcommand:
ccu fed
In both cases, one has the option to load data from a previous FancyPlots
session by specifying a cache file via the cache_file parameter of
the ccu.fancyplots.gui.root.FancyPlotsGUI constructor or the
ccu-fancyplots --cache CLI option of ccu fed.
Submodules¶
ccu.fancyplots.gui.annotation module¶
GUI elements for defining free energy diagram annotations.
This module defines the AnnotationSection class.
- class ccu.fancyplots.gui.annotation.AnnotationSection(parent: FancyPlotsGUI, *args, **kwargs)[source]¶
Bases:
Labelframe,UpdatableFrameGUI component for adding annotations to the free energy diagram.
- Variables:
annotations – A list of
data.Annotations
Create section for adding annotations to the free energy diagram.
ccu.fancyplots.gui.energy module¶
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
MechanismSection.path_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.
- 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.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.
ccu.fancyplots.gui.fed module¶
GUI widgets for displaying free energy diagrams.
Specifically, this module provides the
FreeEnergyDiagram and
TightFreeEnergyDiagram classes.
- class ccu.fancyplots.gui.fed.FreeEnergyDiagram(parent: FancyPlotsGUI, *args, **kwargs)[source]¶
Bases:
ToplevelView the free energy diagram.
- Variables:
canvas – The
FigureCanvasTkAggin which the free energy diagram in plotted.coordinate_label – The
ttk.Labelused to display the mouse coordinates.cleanup_button – The
ttk.Buttonused to preview the diagram with a tight layout.introduction – The
ttk.Labelused to display the cursor coordinate hint.parent – The
root.FancyPlotsGUI.tooltip – The
Tooltipused to display the tight layout hint.
Create a window for displaying a free energy diagram.
- Parameters:
parent – The running
root.FancyPlotsGUIinstance.*args – Positional arguments for
tkinter.Toplevel.**kwargs – Keyword arguments fo
tkinter.Toplevel.
- generate_figure() tuple[Axes | None, Axes | None, Figure | None][source]¶
Generate the free energy diagram.
- Returns:
The output of
plotting.generate_figure()if a mechanism is defined. Otherwise, (None, None, None).
- class ccu.fancyplots.gui.fed.TightFreeEnergyDiagram(parent: FancyPlotsGUI, *args, **kwargs)[source]¶
Bases:
ToplevelView the free energy diagram with a tight layout.
Create a window for displaying a tight layout free energy diagram.
- Parameters:
parent – The running
root.FancyPlotsGUIinstance.*args – Positional arguments for
tkinter.Toplevel.**kwargs – Keyword arguments fo
tkinter.Toplevel.
ccu.fancyplots.gui.formatting module¶
GUI elements for defining plot formatting parameters.
This module defines the FormattingSection class.
- class ccu.fancyplots.gui.formatting.FormattingSection(parent: FancyPlotsGUI, *args, parameters: FormattingParameters | None = None, **kwargs)[source]¶
Bases:
Labelframe,UpdatableFrameA
ttk.LabelFramecontaining all formatting parameters.Note that instances of this class are listeners for the custom <Validate> event emitted by
frames.FancyFormatFrameinstances.- Variables:
parent – The
root.FancyPlotsGUI.formatting_parameters – A
data.FormattingParametersinstance mapping the names of formatting parameters to their values. Defaults to a copy ofdata.DEFAULT_PARAMETERS.frames – A list of
FancyFormatFrameinstances in which the formatting parameters are set.
Create a section for specifying plot formatting parameters.
- Parameters:
parent – The running
root.FancyPlotsGUIinstance.*args – Positional arguments for
tkinter.Toplevel.parameters – A
formatting.FormattingParametersdictionary mapping parameter names to their values. Defauls toDEFAULT_PARAMETERS.**kwargs – Keyword arguments fo
tkinter.Toplevel.
- initialize_frames() list[FancyFormatFrame][source]¶
Create
ttk.LabelFramewidgets for setting formatting parameters.- Returns:
A list of
FancyFormatFramewidgets used to set formatting parameters.- Raises:
NotImplementedError – Unsupported annotation type for formatting
parameter. Only annotated type hints are supported. –
ccu.fancyplots.gui.frames module¶
Validation-enabled GUI elements.
This module defines the FancyFormatFrame class.
- class ccu.fancyplots.gui.frames.FancyFormatFrame(parent: ~tkinter.ttk.Labelframe, *args, label: str = '', value: ~typing.Any = None, tooltip: str = '', validator: ~ccu.fancyplots.validation.Validator[~ccu.fancyplots.gui.frames._T] = <function no_validation_validator>, serializer: ~ccu.fancyplots.validation.Serializer[~ccu.fancyplots.gui.frames._T] = <function default_serializer>, pad: tuple[float, float, float, float] = (5, 3, 5, 3), **kwargs)[source]¶
Bases:
LabelframeA
ttk.LabelFramefor setting formatting parameters.Note that
FancyFormatFrameinstances emit the <<Validate>> event. To listen for this event, handlers should be bound to the event usingMisc.bindandMisc.event_add.- Variables:
entry – A
ttk.Entryin which a user specifies a formatting parameter.tooltip – A :class`.tooltip.Tooltip` displaying help text.
validator – A
validation.Validatorused to validate and convert the text inentry.serializer – A
validation.Serializerused to convert the Python value to a string.
A ttk.LabelFrame for setting formatting parameters.
- Parameters:
parent – The containing
ttk.LabelFrame.*args – Positional parameters for
ttk.LabelFrame.label – The name of the formatting parameter. Defaults to “”.
value – The initial value of the formatting parameter. Defaults to None.
tooltip – The tooltip message. Defaults to “”.
validator – A
Validatorfor validating and converting user input. Defaults tovalidation.no_validation_validator().serializer – A
validation.Serializerinstance forconverting the Python version of the value to a string.
pad – Specify the padding (left, top, bottom, right) to use for the tooltip. Defaults to (5, 3, 5, 3).
**kwargs – Keyword arguments for
ttk.LabelFrame.
- alerting_validator(value: str) bool[source]¶
Validate a value and generate a
<<Validate>>event.- Parameters:
value – The value to validate.
- Returns:
True if the value if valid. False, otherwise.
Note
Listeners should be bound to the
<<Validate>>event in order to respond to this behaviour.
- property python_value: _T¶
The Python value of the text in
FancyFormatFrame.entry.- Raises:
ValidationError – The current value in
FancyFormatFrame.entry –
- property value¶
The text in
FancyFormatFrame.entry.
ccu.fancyplots.gui.instructions module¶
GUI elements for viewing the FancyPlots walkthrough.
This module defines the InstricutionsWindow class.
- class ccu.fancyplots.gui.instructions.InstructionsWindow(parent: FancyPlotsGUI, *args, **kwargs)[source]¶
Bases:
ToplevelView the instructions of how to use FancyPlots.
- Variables:
parent – The running
root.FancyPlotsGUIinstance.image – The A Tkinter-compatible version of the usage instructions.
image_label – The
ttk.Labelcontaining the image.
Create a windown for viewing the instructions.
- Parameters:
parent – The running
root.FancyPlotsGUIinstance.*args – Positional arguments for
tkinter.Toplevel.**kwargs – Keyword arguments for
tkinter.Toplevel.
ccu.fancyplots.gui.mechanism module¶
GUI elements for defining reaction mechanisms.
Specifically, this module defines the StepPanel, PathPanel,
and MechanismSection classes.
- class ccu.fancyplots.gui.mechanism.MechanismSection(parent: FancyPlotsGUI, *args, **kwargs)[source]¶
Bases:
Labelframe,UpdatableFrameGUI element for specifying mechanism free energies.
- Variables:
parent – The running
root.FancyPlotsGUIinstance.step_panel – A
ttk.LabelFramefor defining the names of mechanism steps.path_panel – A
ttk.LabelFramefor defining the number of pathways.gibbs_button – A
ttk.Buttonfor launching theEnergyWindow.reorder_button – A
ttk.Buttonfor launching theReorderWindow.
Create a subpanel for defining a reaction mechanism.
- Parameters:
parent – The containing
mechanism.MechanismSection.*args – Positional arguments for
ttk.LabelFrame.**kwargs – Keyword arguments for
ttk.LabelFrame.
- class ccu.fancyplots.gui.mechanism.PathPanel(parent: MechanismSection, *args, **kwargs)[source]¶
Bases:
LabelframeDefine the number of pathways.
- Variables:
parent – The parent
ccu.fancyplots.gui.mechanism.MechanismSection.spinbox – The
tk.Spinboxused to define the number of pathways.var – The
tkinter.IntVarfor thetk.Spinbox.
Create a subpanel for defining the number of mechanism pathways.
- Parameters:
parent – The containing
mechanism.MechanismSection.*args – Positional arguments for
ttk.LabelFrame.**kwargs – Keyword arguments for
ttk.LabelFrame.
- class ccu.fancyplots.gui.mechanism.StepPanel(parent: MechanismSection, *args, **kwargs)[source]¶
Bases:
LabelframeDefine the name and number of mechanism steps.
Note that step names are stripped of all surrounding whitespace.
- Variables:
entry – The
ttk.Entryused to define mechanism steps.parent – The parent
ccu.fancyplots.gui.mechanism.MechanismSection.var – The
tk.StringVarfor thettk.Entry.
Create a subpanel for defining the mechanism steps.
- Parameters:
parent – The containing
mechanism.MechanismSection.*args – Positional arguments for
ttk.LabelFrame.**kwargs – Keyword arguments for
ttk.LabelFrame.
ccu.fancyplots.gui.palette module¶
GUI elements for viewing the matplotlib colour palette.
This module defines the PaletteWindow class.
- class ccu.fancyplots.gui.palette.PaletteWindow(parent: FancyPlotsGUI, *args, **kwargs)[source]¶
Bases:
ToplevelView available matplotlib colours.
- Variables:
image – The A Tkinter-compatible version of the usage instructions.
image_label – The
ttk.Labelcontaining the image.parent – The running
root.FancyPlotsGUIinstance.source_label – The
ttk.Labelcontaining the image source.
Create a subpanel for defining a reaction mechanism.
- Parameters:
parent – The runnnig
root.FancyPlotsGUIinstance.*args – Positional arguments for
tk.Toplevel.**kwargs – Keyword arguments for
tk.Toplevel.
ccu.fancyplots.gui.plotting module¶
Functions for plotting free energy diagrams.
The main function is ccu.fancyplots.gui.plotting.generate_figure().
Examples
>>> from ccu.fancyplots.data import DEFAULT_PARAMETERS
>>> from ccu.fancyplots.data import FEDData
>>> from ccu.fancyplots.gui.plotting import generate_figure
>>> energy_data = [[0.0, 1.5, 0.5]]
>>> data = FEDData(
... energy_data=energy_data,
... mechanism=["*", "*H", "H2"],
... legend_labels=["Cu(111)"],
... )
>>> generate_figure(data, DEFAULT_PARAMETERS, visual=True)
- class ccu.fancyplots.gui.plotting.SymHandler(marker_pad=0.3, numpoints=None, **kwargs)[source]¶
Bases:
HandlerLine2D- Parameters:
marker_pad (float) – Padding between points in legend entry.
numpoints (int) – Number of points to show in legend entry.
**kwargs – Keyword arguments forwarded to .HandlerBase.
- create_artists(legend, orig_handle, xdescent, ydescent, width, height, fontsize, trans)[source]¶
Return the legend artists generated.
- Parameters:
legend (~matplotlib.legend.Legend) – The legend for which these legend artists are being created.
orig_handle (~matplotlib.artist.Artist or similar) – The object for which these legend artists are being created.
xdescent, ydescent, width, height (int) – The rectangle (xdescent, ydescent, width, height) that the legend artists being created should fit within.
fontsize (int) – The fontsize in pixels. The legend artists being created should be scaled according to the given fontsize.
trans (~matplotlib.transforms.Transform) – The transform that is applied to the legend artists being created. Typically from unit coordinates in the handler box to screen coordinates.
- ccu.fancyplots.gui.plotting.add_annotations(engine: Axes | ModuleType, annotations: list[Annotation], fontsize: float, font: str) None[source]¶
Add the annotations to the free energy diagram.
- Parameters:
engine – The engine with which to create the legend. Can either be an
axes.Axesobject ormatplotlib.pyplot.annotations – The annotations to add.
fontsize – The font size to use for the annotations.
font – The matplotlib font family to use to write the annotations.
- ccu.fancyplots.gui.plotting.bracket_ts_step(ts_step_index: int, energies: dict[str, float | None]) tuple[int, int][source]¶
Determine the indices of the nearest mechanism steps to a TS.
- Parameters:
ts_step_index – The index of the transition state step.
energies – A list of free energies. The ith entry in
energiescorresponds to the ith step inpathway.
- Raises:
RuntimeError – Unable to bracket the transition step. Either there is no elementary reaction step defined prior to the reaction step or there is no elementary reaction step defined after the reaction step.
- Returns:
A 2-tuple (
index_before,index_after) indicating the indices of the nearest, defined reaction steps before and after the transition state, respectively.
- ccu.fancyplots.gui.plotting.create_axes(parameters: FormattingParameters, *, visual: bool = True) tuple[Axes, Figure][source]¶
Create the primary axes for plotting free energy diagrams.
- Parameters:
parameters – The formatting parameters to use to plot the diagram
visual – Whether or not the image is being displayed. Determines the interface to matplotlib that is used. Defaults to True.
- Returns:
A 2-tuple (
ax,fig) whose first and second elements are the primary axes and figure used to plot the diagram, respectively.
- ccu.fancyplots.gui.plotting.create_legend(engine: Axes | ModuleType, lines: list[Artist | None], legend_entries: list[str | None], fontsize: float, loc: str) None[source]¶
Create the legend for the free energy diagram.
- Parameters:
engine – The engine with which to create the legend. Can either be an
axes.Axesobject ormatplotlib.pyplot.lines – The
artist.Artistobjects for which legend entries will be made.legend_entries – A list of legend entries.
fontsize – The fontsize for the legend.
loc – The legend location. See the documentation for
matplotlib.legend.Legendfor valid values.
- ccu.fancyplots.gui.plotting.create_ts_curve(ts_step_index: int, energies: list[float | None], step_count: int) tuple[list[float], list[float]][source]¶
Create the plotting data for a transition state curve.
- Parameters:
ts_step_index – The index of the transition state step.
energies – A list of free energies. The ith entry in
energiescorresponds to the ith step inpathway.step_count – A weighted index for mechanism steps. Elementary steps increment the index by 2 while steps corresponding to transition states increment the index by 1.
- Returns:
A 2-tuple (
xx,yy) whose first and second elements are the x and y values to be plotted on the free energy diagram.
- ccu.fancyplots.gui.plotting.format_primary_axes(ax: Axes, engine: Axes | ModuleType, parameters: FormattingParameters, count: int) None[source]¶
Format the primary axis.
- Parameters:
ax – The primary
matplotlib.axes.Axes.engine – The engine with which to create the legend. Can either be an
axes.Axesobject ormatplotlib.pyplot.parameters – The
formatting.FormattingParametersto use for the axes.count – A weighted index for mechanism steps. Elementary steps increment the index by 2 while steps corresponding to transition states increment the index by 1.
- ccu.fancyplots.gui.plotting.format_secondary_axes(ax: Axes, parameters: FormattingParameters) None[source]¶
Format the secondary axis.
- Parameters:
ax – The secondary
matplotlib.axes.Axes.parameters – The
formatting.FormattingParametersto use for the axes.
- ccu.fancyplots.gui.plotting.generate_figure(diagram_data: FEDData, parameters: FormattingParameters = {'boxsize': (6, 4.5), 'colors': ('black', 'blue', 'red', 'lime', 'fuchsia'), 'dpi': 1200, 'font': 'Sans Serif', 'fontsize': 14, 'legend_loc': 'best', 'linewidth': 2.25, 'markeredgewidth': 0.3, 'markersize': 7, 'savename': 'fed.svg', 'tick_dec': 2, 'tick_double': False, 'tick_loc': 'out', 'tick_min': 1, 'title': '', 'xlabel': 'Reaction Coordinate', 'xlim': None, 'xscale': 'linear', 'ylabel': '$\\Delta$G / eV', 'ylim': None, 'yscale': 'linear'}, annotations: list[Annotation] | None = None, *, visual: bool = True) tuple[Axes, Axes | None, Figure][source]¶
Generate the free energy diagram figure.
- Parameters:
diagram_data – The data for the free energy diagram.
parameters – The formatting parameters to use to create the free energy diagram.
annotations – Annotations for the free energy data. Defaults to an empty list.
visual – Whether or not to display the image. If False, the figure will be saved to file instead of displayed. Defaults to True.
- Returns:
A 3-tuple (
ax1,``ax2``,figure).ax1is the primary axes containing the free energy diagram.ax2is the secondary axes; it is None unless the “tick_double” parameter is True inparameters.figureis thematplotlib.figure.Figurecontaining all plot elements.
- ccu.fancyplots.gui.plotting.interpolate(x0: tuple[float, float, float], y0: tuple[float, float, float]) tuple[list[float], list[float]][source]¶
Interpolate between three points with a sinusoidal function.
- Parameters:
x0 – The x-coordinates of the start, mid-, and end points.
y0 – The y-coordinates of the start, mid-, and end points.
- Returns:
The x- and y-coordinates of the interpolation.
- ccu.fancyplots.gui.plotting.plot_energy_data(ax: Axes, data: FEDData, parameters: FormattingParameters) tuple[int, list[Artist | None]][source]¶
Plot the free energy diagrams of all pathways.
- Parameters:
ax – The
axes.Axeson which to plot the Gibbs plot.data – The free energy data to plot.
parameters – The formatting parameters to use to plot the free energy diagram.
- Returns:
A 2-tuple (
step_count,lines) wherestep_countis a weighted index for mechanism steps. Elementary steps increment the index by 2 while steps corresponding to transition states increment the index by 1.linesis a list ofartist.Artistobjects, each corresponding to a data point in the data series.
- ccu.fancyplots.gui.plotting.plot_fed(ax: Axes, energies: list[float | None], mechanism: list[str], color: str, zorder: int, linewidth: float) tuple[int, Artist | None][source]¶
Plot the free energy diagram of a pathway.
- Parameters:
ax – The
axes.Axeson which to plot the free energy diagram.energies – A list of free energies. The ith entry in
energiescorresponds to the ith step inpathway.mechanism – A list of strings corresponding to the steps of a reaction mechanism.
color – A string corresponding to a matplotlib colour.
zorder – The zorder for the lines for the pathway. A lower zorder indicates that the line will be drawn first.
linewidth – The width of the line to use to plot the free energy diagram.
- Returns:
A 2-tuple (
step_count,line) wherestep_countis a weighted index for mechanism steps. Elementary steps increment the index by 2 while steps corresponding to transition states increment the index by 1.lineis a representativeartist.Artistobject for the data series.
ccu.fancyplots.gui.root module¶
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)
app.master.mainloop()
- class ccu.fancyplots.gui.root.FancyPlotsGUI(cache_file: str | ~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, useFancyPlots.master.Launch the main GUI for FancyPlots.
- Parameters:
cache_file – A string or
Pathpointing 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.master – The top level
tkinter.Tkinstance.
- 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¶
ccu.fancyplots.gui.tooltip module¶
A robust tooltip class.
This module provides the Tooltip class.
- class ccu.fancyplots.gui.tooltip.Tooltip(parent: Widget | Widget, *, bg: str = '#000000', pad: tuple[float, float, float, float] = (5, 3, 5, 3), text: str = '', waittime: int = 400, wraplength: float = 250)[source]¶
Bases:
objectCreate a tooltip for a given widget as the mouse goes on it.
see:
- http://stackoverflow.com/questions/3221956/
what-is-the-simplest-way-to-make-tooltips- in-tkinter/36221216#36221216
- http://www.daniweb.com/programming/software-development/
code/484591/a-tooltip-class-for-tkinter
Originally written by vegaseat on 2014.09.09.
Modified to include a delay time by Victor Zaccardo on 2016.03.25.
- Variables:
parent – The widget over which the user must hover to activate the tooltip.
bg – The tooltip background as a hex string. Defaults to “#FFFFEA”.
pad – A 4-tuple (left, top, bottom, right), indicating the padding around the text within the tooltip (in pixels).
text – The text displayed in the tooltip. Defaults to an empty string.
waittime – Time before displaying (in milliseconds). Defaults to 400.
wraplength – Length before wrapping text (in pixels). Defaults to 250.
Create a tooltip.
- Parameters:
parent – The parent widget over which one must hover to generate the tooltip.
bg – The tooltip background. Defaults to “#FFFFEA”.
pad – The padding to use for the tooltip. Defaults to (5, 3, 5, 3).
text – The text to display on the tooltip. Defaults to “”.
waittime – The time (in milliseconds) to wait for a user to hover before generating the tooltip. Defaults to 400.
wraplength – The character length at which the tooltip message will wrap. Defaults to 250.
ccu.fancyplots.gui.utils module¶
GUI utility functions.
Specifically, this module provides ccu.fancyplots.gui.utils.open_image(),
which opens a Tkinter-compatible version of an image shipped with
ccu., and ccu.fancyplots.gui.utils.print_decal(), which prints an
Easter egg.
- ccu.fancyplots.gui.utils.open_image(name: str, width: int, height: int) PhotoImage[source]¶
Open Tkinter-compatible version of a
ccuimage.- Parameters:
name – The name of the image to open.
width – The width of the image when opened.
height – The height of the image when opened.
- Returns:
A Tkinter-compatible version of the opened image.