Skip to content

Commit

Permalink
Version 2.3.0
Browse files Browse the repository at this point in the history
Merged pull request for non-integer hkl option on SF and electron form factors.
Thanks Prestipino!
Added menu with various options to GUI.
Updated docs and examples.
Added periodic_table.py GUI element
  • Loading branch information
DanPorter committed May 16, 2023
1 parent 3ee9349 commit e5dffd0
Show file tree
Hide file tree
Showing 6 changed files with 352 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Dans_Diffraction/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@


__version__ = '2.3.0'
__date__ = '08/05/23'
__date__ = '16/05/23'


# Build
Expand Down
9 changes: 5 additions & 4 deletions Dans_Diffraction/tkgui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
Diamond
2019
Version 2.3.0
Last updated: 26/01/21
Version 2.4.0
Last updated: 16/05/23
Version History:
10/11/17 0.1 Program created
Expand All @@ -24,11 +24,12 @@
15/10/20 2.2.1 Slight correction to SymmetryGui - no longer adds 'm' to labels
21/01/21 2.2.2 Added 'xray dispersion' scattering option
26/01/21 2.3.0 Refactored properites into new file, added x-ray interactions GUI
16/05/23 2.4.0 Added periodic_table.py and added menu items to CrystalGUI. Changed default fonts and colours
@author: DGPorter
"""

from .crystal import CrystalGui

__version__ = '2.3.0'
__date__ = '26/01/20'
__version__ = '2.4.0'
__date__ = '16/05/23'
20 changes: 10 additions & 10 deletions Dans_Diffraction/tkgui/basic_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@
from tkinter import messagebox

# Fonts
TF = ["Times", 12]
BF = ["Times", 14]
SF = ["Times New Roman", 14]
LF = ["Times", 14]
TF = ['Palatino', 12] # ["Times", 12]
BF = ['Palatino', 14] # ["Times", 14]
SF = ['Palatino', 14] # ["Times New Roman", 14]
LF = ['Palatino', 14] # ["Times", 14]
MF = ["Courier", 8] # fixed distance format
HF = ['Courier',12]
TTF = ("Helvetica", 10, "bold italic")
# Colours - background
bkg = 'snow'
ety = 'white'
btn = 'azure' #'light slate blue'
opt = 'azure' #'light slate blue'
btn2 = 'gold'
TTBG = 'light grey'
bkg = 'snow' # background colour
ety = 'white' # entry box
btn = 'azure' # buttons 'light slate blue'
opt = 'azure' # option background 'light slate blue'
btn2 = 'gold' # main button
TTBG = 'light grey' # Title background
# Colours - active
btn_active = 'grey'
opt_active = 'grey'
Expand Down
37 changes: 32 additions & 5 deletions Dans_Diffraction/tkgui/crystal.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

import sys, os
import matplotlib.pyplot as plt # Plotting
import matplotlib.pyplot as plt # Plotting
import numpy as np


Expand All @@ -30,6 +30,7 @@
from .multi_crystal import MultiCrystalGui
from .multiple_scattering import MultipleScatteringGui
from .tensor_scattering import TensorScatteringGui
from .periodic_table import PeriodTableGui


class CrystalGui:
Expand Down Expand Up @@ -70,11 +71,16 @@ def __init__(self, xtl=None):
'All Atom Sites': self.menu_info_structure,
'Properties': self.menu_info_properties,
'Show CIF': self.menu_info_cif,
},
'Element Info': {
'Element Info': self.menu_info_elements,
'Periodic Table': self.menu_info_table,
},
'Help': {
'Help': popup_help,
'Examples': self.menu_examples,
'Activate FDMNES option': self.menu_start_fdmnes,
'Analyse FDMNES data': self.menu_analyse_fdmnes,
'Documentation': menu_docs,
'GitHub Page': menu_github,
'About': popup_about,
Expand Down Expand Up @@ -230,9 +236,14 @@ def menu_info_elements(self):
"""View atom properties"""
ele_list = ['%3s: %s' % (sym, nm) for sym, nm in fc.atom_properties(None, ['Element', 'Name'])]
choose = SelectionBox(self.root, ele_list, multiselect=True, title='Select elements').show()
ch_ele = [ele[:3].strip() for ele in choose]
string = fc.print_atom_properties(ch_ele)
StringViewer(string, 'Element Properties: %s' % ' '.join(ch_ele), width=60)
if choose:
ch_ele = [ele[:3].strip() for ele in choose]
string = fc.print_atom_properties(ch_ele)
StringViewer(string, 'Element Properties: %s' % ' '.join(ch_ele), width=60)

def menu_info_table(self):
"""Open periodic table"""
PeriodTableGui()

def menu_examples(self):
"""List example files, open in system viewer"""
Expand Down Expand Up @@ -271,6 +282,22 @@ def menu_examples(self):
parent=self.root
)

def menu_start_fdmnes(self):
"""Search for FDMNES, restart GUI"""
from Dans_Diffraction import activate_fdmnes, fdmnes_checker, start_gui
activate_fdmnes()
if fdmnes_checker():
self.on_closing()
start_gui(self.xtl)
else:
messagebox.showinfo('FDMNES Checker', 'FDMNES could not be found')

def menu_analyse_fdmnes(self):
"""Open FDMNS analysis GUI"""
from .fdmnes import AnaFDMNESgui
AnaFDMNESgui()


###################################################################################
############################## FUNCTIONS ##########################################
###################################################################################
Expand Down Expand Up @@ -579,7 +606,7 @@ def __init__(self, xtl, symmetric_only=True, magnetic_moments=False):
scany.config(command=self.text.yview)

def fun_set(self):
"Get positions from crystal object, fill text boxes"
"""Get positions from crystal object, fill text boxes"""
# Build string
str = ''
if self.magnetic_moments:
Expand Down
3 changes: 3 additions & 0 deletions Dans_Diffraction/tkgui/fdmnes.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ def __init__(self, output_path=None, output_name='out'):

if output_path is None or not os.path.isfile(os.path.join(output_path, output_name + '.txt')):
self.fun_loadpath()
return

self.fdm = FdmnesAnalysis(output_path, output_name)

Expand Down Expand Up @@ -477,6 +478,8 @@ def fun_loadpath(self, event=None):
calc_name = filename.split('.')[0]
self.root.destroy()
AnaFDMNESgui(filepath, calc_name)
else:
self.root.destroy()

def fun_xanes(self, event=None):
"""Button XANES"""
Expand Down
Loading

0 comments on commit e5dffd0

Please sign in to comment.