diff --git a/Dans_Diffraction/__init__.py b/Dans_Diffraction/__init__.py index e65b822..216c361 100644 --- a/Dans_Diffraction/__init__.py +++ b/Dans_Diffraction/__init__.py @@ -208,11 +208,14 @@ def doc_str(): # tkGUI Activation def start_gui(xtl=None): """Start GUI window (requires tkinter)""" - try: - from .tkgui import CrystalGui - CrystalGui(xtl) - except ImportError: - print('GUI functionality not available, you need to install tkinter.') + from .tkgui import CrystalGui + CrystalGui(xtl) + + +def start_properties_gui(): + """Start XRay Interactions GUI""" + from .tkgui.properties import XrayInteractionsGui + XrayInteractionsGui() # FDMNES Activation @@ -224,3 +227,9 @@ def activate_fdmnes(initial_dir=None, fdmnes_filename='fdmnes_win64.exe'): :return: None """ fdmnes_checker(activate=True, fdmnes_filename=fdmnes_filename, initial_dir=initial_dir) + + +def start_fdmnes_gui(): + """Start GUI for FDMNES""" + from .tkgui.fdmnes import AnaFDMNESgui + AnaFDMNESgui() diff --git a/Dans_Diffraction/__main__.py b/Dans_Diffraction/__main__.py index 68c2cec..1da1284 100644 --- a/Dans_Diffraction/__main__.py +++ b/Dans_Diffraction/__main__.py @@ -37,4 +37,10 @@ print(xtl.info()) elif 'gui' in arg.lower(): xtl.start_gui() + elif 'properties' in arg.lower(): + from Dans_Diffraction.tkgui.properties import XrayInteractionsGui + XrayInteractionsGui() + elif 'fdmnes' in arg.lower(): + from Dans_Diffraction.tkgui.fdmnes import AnaFDMNESgui + AnaFDMNESgui() diff --git a/Dans_Diffraction/tkgui/basic_widgets.py b/Dans_Diffraction/tkgui/basic_widgets.py index ca9173d..e693d52 100644 --- a/Dans_Diffraction/tkgui/basic_widgets.py +++ b/Dans_Diffraction/tkgui/basic_widgets.py @@ -105,11 +105,14 @@ def topmenu(root, menu_dict): # Setup menubar menubar = tk.Menu(root) - for item in menu_dict: - men = tk.Menu(menubar, tearoff=0) - for label, function in menu_dict[item].items(): - men.add_command(label=label, command=function) - menubar.add_cascade(label=item, menu=men) + for item, obj in menu_dict.items(): + if isinstance(obj, dict): + men = tk.Menu(menubar, tearoff=0) + for label, function in obj.items(): + men.add_command(label=label, command=function) + menubar.add_cascade(label=item, menu=men) + else: + menubar.add_command(label=item,command=obj) root.config(menu=menubar) diff --git a/Dans_Diffraction/tkgui/properties.py b/Dans_Diffraction/tkgui/properties.py index 9a6c5c8..5557b51 100644 --- a/Dans_Diffraction/tkgui/properties.py +++ b/Dans_Diffraction/tkgui/properties.py @@ -8,7 +8,7 @@ from .. import functions_general as fg from .. import functions_crystallography as fc from .. import functions_plotting as fp -from .basic_widgets import tk, StringViewer, SelectionBox, messagebox +from .basic_widgets import tk, StringViewer, SelectionBox, messagebox, topmenu from .basic_widgets import (TF, BF, SF, LF, HF, bkg, ety, btn, opt, btn2, btn_active, opt_active, txtcol, @@ -312,9 +312,8 @@ class XrayInteractionsGui: Calculate X-Ray interactions with Matter """ - def __init__(self, xtl): + def __init__(self, xtl=None): """Initialise""" - self.xtl = xtl # Create Tk inter instance self.root = tk.Tk() self.root.wm_title('X-Ray Interactions with Matter') @@ -330,9 +329,9 @@ def __init__(self, xtl): frame.pack(side=tk.LEFT, anchor=tk.N) # Crystal info - name = xtl.name - formula = xtl.Properties.molname() - density = round(xtl.Properties.density(), 3) + name = xtl.name if xtl else 'Fe' + formula = xtl.Properties.molname() if xtl else 'Fe' + density = round(xtl.Properties.density(), 3) if xtl else 92.735 # Variables self.chem_formula = tk.StringVar(frame, formula) @@ -364,6 +363,14 @@ def __init__(self, xtl): 'Wavelength (nm)': 'nm' } + # ---Menu--- + menu = { + 'Periodic Table': self.menu_info_table, + 'Unit Converter': self.menu_converter, + 'About': self.menu_about, + } + topmenu(self.root, menu) + # ---Line 0--- line = tk.Frame(frame) line.pack(side=tk.TOP, expand=tk.TRUE, fill=tk.X, pady=5) @@ -460,6 +467,20 @@ def __init__(self, xtl): activebackground=btn_active) var.pack(side=tk.LEFT) + def menu_info_table(self): + from .periodic_table import PeriodTableGui + PeriodTableGui() + + def menu_converter(self): + """Open unit converter""" + from .converter import UnitConverter + UnitConverter() + + def menu_about(self): + about = "Xray Interactions with Matter\nBy Dan Porter 2025\n\n" + about += "Inspired by CXRO: https://henke.lbl.gov/optical_constants/\n\n" + messagebox.showinfo('X-Ray Interactions with Matter', about) + def get_scan(self): scan_type = self.scan_type.get() scan_min = self.scan_min.get() diff --git a/docs/Dans_Diffraction.classes_crystal.html b/docs/Dans_Diffraction.classes_crystal.html index b7e0df7..e23a791 100644 --- a/docs/Dans_Diffraction.classes_crystal.html +++ b/docs/Dans_Diffraction.classes_crystal.html @@ -6,7 +6,7 @@
- Dans_Diffraction.classes_crystal (version 3.2.4) | index c:\users\grp66007\onedrive - diamond light source ltd\pythonprojects\dans_diffraction\dans_diffraction\classes_crystal.py |
classes_crystal.py
@@ -34,8 +34,8 @@
Diamond
2017
-Version 3.2.4
-Last updated: 22/05/23
+Version 3.3.0
+Last updated: 06/02/25
Version History:
27/07/17 1.0 Version History started.
@@ -59,6 +59,7 @@
15/11/21 3.2.2 Added Cell.orientation, updated Cell.UV()
12/01/21 3.2.3 Added Symmetry.axial_vector
22/05/23 3.2.4 Added Symmetry.wyckoff_label(), Symmetry.spacegroup_dict
+06/05/25 3.3.0 Symmetry.from_cif now loads operations from find_spacegroup if not already loaded
@author: DGPorter
@@ -70,8 +71,9 @@
Dans_Diffraction.functions_crystallography | Dans_Diffraction.functions_general + | Dans_Diffraction.functions_lattice | numpy - |
+
@@ -293,7 +295,7 @@
|
- | CrystalOrientation(lattice_parameters=(), *args, **kwargs) + CrystalOrientation(*lattice_parameters, **kwargs) | CrystalOrientation Class @@ -70,7 +67,7 @@ y-axis : vector normal to x,z axes (parallel to beam (+z) in lab frame) | ||
Methods defined here: -
| ||||
|