Skip to content

Commit 957953c

Browse files
authored
Add files via upload
All the necessary files. Small updates to GUI.py and temCalcs.py
1 parent c958cc3 commit 957953c

21 files changed

+112
-9
lines changed

Diff for: GUI.py

+61-7
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class App(QMainWindow):
2020

2121
def __init__(self):
2222
super().__init__()
23-
self.title = "TEMTilt v0.01 BETA"
23+
self.title = "ALPHABETA v0.01 BETA"
2424
#self.left = 50
2525
#self.top = 50
2626
#self.width = 640
@@ -278,6 +278,15 @@ def __init__(self, caller):
278278
self.kvbox.setSizePolicy(sp)
279279
temlayout.addWidget(self.kvbox, 1, 6)
280280

281+
#the ewald sphere radius. The angle must be added later when you update the field
282+
self.eslbl = QLabel(u"K0")
283+
self.eslbl.setToolTip("The radius of the Ewald sphere\n1/electron wavelength")
284+
temlayout.addWidget(self.eslbl, 1, 7)
285+
self.k0view = QLineEdit(self)
286+
self.k0view.setReadOnly(True)
287+
self.k0view.setSizePolicy(sp)
288+
temlayout.addWidget(self.k0view, 1, 8)
289+
281290
######The stage menu#################
282291
#add the stage dropdown list
283292
yoffset = 50
@@ -493,6 +502,7 @@ def deleteDetector(self):
493502
def updateVoltage(self, value):
494503
try:
495504
self.currentTEM().setKv(value)
505+
self.updateK0()
496506
except:
497507
pass
498508

@@ -554,6 +564,13 @@ def updateTheta(self):
554564
except: #if no mag data can be found
555565
self.thetaview.setText("")
556566

567+
def updateK0(self):
568+
try:
569+
self.k0view.setText(u"%s 1/\u212B" %(round(self.currentTEM().getEwaldR(units = "angstrom"), 2)))
570+
except:
571+
#when the current TEM is none
572+
self.k0view.setText("")
573+
557574
def currentTEM(self):
558575
if tc.microscopes:
559576
return tc.getMicroscope(self.temlist.currentText())
@@ -698,6 +715,7 @@ def updatebuttons(self):
698715
self.edittembut.hide()
699716
self.deltembut.hide()
700717
self.kvbox.hide()
718+
self.k0view.hide()
701719
#stage buttons
702720
self.stagelist.hide()
703721
self.adstagbut.hide()
@@ -721,8 +739,10 @@ def updatebuttons(self):
721739
self.edittembut.show()
722740
self.deltembut.show()
723741
self.kvbox.show()
742+
self.k0view.show()
724743
#update the kV box
725744
self.kvbox.setValue(self.currentTEM().getKv())
745+
self.updateK0()
726746

727747
#stage buttons
728748
self.stagelist.show()
@@ -807,7 +827,7 @@ def __init__(self, caller):
807827
self.adstrucbut = self.button(logo=".\Images\plus.png", hint = "Add new structure", action = self.createStructure)
808828
self.editstrucbut = self.button(logo = ".\Images\edit.png", hint = "Edit structure", action = self.editStructure)
809829
self.delstrucbut = self.button(logo=".\Images\delete-icon.png", hint = "Delete structure", action = self.deleteStructure)
810-
self.calcbut = self.button(logo=".\Images\calc.png", hint = "Crystallography calculator", action = self.showCalculator)
830+
self.calcbut = self.button(logo=".\Images\wizard.png", hint = "Indexing wizard", action = self.showWizard)
811831

812832
layout.addWidget(self.adstrucbut, 1, 2)
813833
layout.addWidget(self.editstrucbut, 1, 3)
@@ -903,8 +923,8 @@ def deleteStructure(self):
903923
tc.removeStructure(nt)
904924
self.updateAll()
905925

906-
def showCalculator(self):
907-
pass
926+
def showWizard(self):
927+
indexingDialog.getInfo(caller = self.caller)
908928

909929
def currentStruc(self):
910930
try:
@@ -2288,7 +2308,8 @@ def getActiveRow(self):
22882308
return None
22892309

22902310
def showHelp(self):
2291-
self.testIndexation()
2311+
QMessageBox.information(self, " ", "Tilt to some zone axis and capture the diffraction pattern. Of 2 non-colinear reflections (hkl) measure:\n-the distance between (000) and (hkl) in 1/nm.\n-the angle between the detector X-axis and the line that connects (000) and (hkl).\nNote that the X-axis points to the right and that positive angles are clockwise.")
2312+
#self.testIndexation()
22922313

22932314
def testIndexation(self):
22942315
self.l1box.setValue(5.6)
@@ -2401,7 +2422,37 @@ def getres(self):
24012422
else:
24022423
values.append(None)
24032424
return values
2404-
2425+
2426+
class indexingDialog(Dialog):
2427+
"""Opens a window with only an indexing wizard widget"""
2428+
def __init__(self, caller, windowtitle = "Indexing wizard", **kwargs):
2429+
super(indexingDialog, self).__init__()
2430+
#caller is the mainwindow app for access to current settings if necessary
2431+
self.caller = caller
2432+
struc = caller.getCurrentStructure()
2433+
2434+
#the wizard
2435+
self.wiz = indexWizard(struc)
2436+
2437+
#the button box
2438+
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Cancel)
2439+
self.buttonBox.rejected.connect(self.reject)
2440+
2441+
self.makeLayout()
2442+
self.setWindowTitle(windowtitle)
2443+
2444+
def makeLayout(self):
2445+
mainLayout = QVBoxLayout()
2446+
mainLayout.addWidget(self.wiz)
2447+
mainLayout.addWidget(self.buttonBox)
2448+
mainLayout.setSizeConstraint(mainLayout.SetFixedSize)
2449+
self.setLayout(mainLayout)
2450+
2451+
# static method doesn't have to do much in this case
2452+
@staticmethod
2453+
def getInfo(**kwargs):
2454+
dialog = indexingDialog(**kwargs)
2455+
result = dialog.exec_()
24052456

24062457
class microscopeDialog(Dialog):
24072458

@@ -2609,7 +2660,7 @@ def createFormGroupBox(self, name = "", alpha = 0.0, alphamin = -30.0, alphamax=
26092660
qbutton = QPushButton("", self)
26102661
qbutton.setToolTip("What is this?")
26112662
qbutton.setIcon(QIcon(".\Images\question.png"))
2612-
#qbutton.clicked.connect(action)
2663+
qbutton.clicked.connect(self.showHelp)
26132664
qbutton.resize(24+6, 24+6)
26142665
qbutton.setIconSize(QSize(24,24))
26152666
qbutton.setSizePolicy(sp)
@@ -2701,6 +2752,9 @@ def createFormGroupBox(self, name = "", alpha = 0.0, alphamin = -30.0, alphamax=
27012752

27022753
self.formGroupBox.setLayout(layout)
27032754

2755+
def showHelp(self):
2756+
QMessageBox.information(self, " ", "The \u03b1-axis (X) runs along the double-tilt holder main axis pointed out of the microscope, the absolute Z axis is pointed down the column. The \u03b2-axis (Y) is defined by X x Y = Z at (0,0) tilt. Rotations follow the right hand rule.\n\nIf your holder doesn't follow these conventions, use the 'Reversed?' checkboxes appropriately.")
2757+
27042758
def anglemaxupdate(self):
27052759
self.alphabox.setMaximum(self.alphamaxbox.value())
27062760
self.alphabox.setMinimum(self.alphaminbox.value())

Diff for: GUI.spec

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# -*- mode: python -*-
2+
import sys
3+
import os
4+
sys.setrecursionlimit(5000)
5+
6+
block_cipher = None
7+
8+
options = [ ('v', None, 'OPTION') ]
9+
10+
a = Analysis(['GUI.py'],
11+
pathex=['C:\\users\\ncautaer\\desktop\\Python Experience\\TEM calcs v2'],
12+
binaries=[],
13+
datas = [],
14+
#datas=[('\Images\*.png', 'Images')],
15+
hiddenimports=['scipy._lib.messagestream'],
16+
hookspath=[],
17+
runtime_hooks=[],
18+
excludes=[],
19+
win_no_prefer_redirects=False,
20+
win_private_assemblies=False,
21+
cipher=block_cipher)
22+
pyz = PYZ(a.pure, a.zipped_data,
23+
cipher=block_cipher)
24+
exe = EXE(pyz,
25+
a.scripts,
26+
exclude_binaries=True,
27+
name='GUI',
28+
debug=False,
29+
strip=False,
30+
upx=True,
31+
console=True )
32+
coll = COLLECT(exe,
33+
a.binaries,
34+
a.zipfiles,
35+
a.datas,
36+
strip=False,
37+
upx=True,
38+
name='GUI')

Diff for: Images/Icons.pptx

161 KB
Binary file not shown.

Diff for: Images/Nespolo_zone_axis.pdf

299 KB
Binary file not shown.

Diff for: Images/calc.png

3.66 KB
Loading

Diff for: Images/calculate.png

2.6 KB
Loading

Diff for: Images/delete-icon.png

3.61 KB
Loading

Diff for: Images/edit.png

3.92 KB
Loading

Diff for: Images/impo.png

3.61 KB
Loading

Diff for: Images/load.png

4.94 KB
Loading

Diff for: Images/loadaftersave.png

38 KB
Loading

Diff for: Images/loadtest.png

39.8 KB
Loading

Diff for: Images/logo.png

5.9 KB
Loading

Diff for: Images/plus.png

2.54 KB
Loading

Diff for: Images/poubelle.png

4.77 KB
Loading

Diff for: Images/question.png

4.74 KB
Loading

Diff for: Images/save.png

6.49 KB
Loading

Diff for: Images/trash.png

5.15 KB
Loading

Diff for: Images/wizard.png

4.42 KB
Loading

Diff for: ToCompile.txt

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
The working combination for compilation:
2+
- I installed pipenv (as admin) and created a virtual environment for my folder
3+
- In the virtual environment, I installed scipy, numpy, matplotlib, pyqt5, and pyinstaller using:
4+
pyenv run pip package_name
5+
- I ran: pipenv run pyinstaller GUI.py
6+
- This created a spec file. I modified the spec file to include verbose and to include scipy.messagebox as hiddenimport (whatever that does, it was needed)
7+
- I ran the command (as admin) in windows powershell:
8+
pipenv run pyinstaller --onedir --noupx --clean GUI.py
9+
- This gave me a permission error
10+
- I ran it again and there was no problem anymore
11+
- I mannually coppied the Images folder into the generated dist folder. This finally got me a working exe.
12+
13+
Niels Cautaerts, 18/05/18

Diff for: temCalcs.py

-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
import numpy as np
44
import math as ma
5-
import pandas as pd
65
import matplotlib.pyplot as plt
7-
import pickle
86
import re
97
from fractions import Fraction
108
import math

0 commit comments

Comments
 (0)