diff --git a/src/diffpy/pdfgui/doc/manual/fixHTMLCode.py b/src/diffpy/pdfgui/doc/manual/fixHTMLCode.py
index 0e410070..0ec4b70a 100644
--- a/src/diffpy/pdfgui/doc/manual/fixHTMLCode.py
+++ b/src/diffpy/pdfgui/doc/manual/fixHTMLCode.py
@@ -1,5 +1,9 @@
#!/usr/bin/python
+import os
+import re
+import sys
+
"""Replace all equation marks in HTML file with
tag to display
corresponding PNG file. This assumes PNG files are in correct sequence.
Also fix any accented characters texinfo does not get right.
@@ -16,9 +20,6 @@
##############################################################################
# business
-import os
-import re
-import sys
eqcnt = 0
diff --git a/src/diffpy/pdfgui/gui/aboutdialog.py b/src/diffpy/pdfgui/gui/aboutdialog.py
index c71c45b3..2cd47a5e 100644
--- a/src/diffpy/pdfgui/gui/aboutdialog.py
+++ b/src/diffpy/pdfgui/gui/aboutdialog.py
@@ -235,7 +235,7 @@ def onColumbiaLogo(self, event): # wxGlade: DialogAbout.
# end of class DialogAbout
-# #### testing code ###########################################################
+# testing code ###########################################################
if __name__ == "__main__":
app = wx.App()
diff --git a/src/diffpy/pdfgui/gui/mainframe.py b/src/diffpy/pdfgui/gui/mainframe.py
index b7e32efc..bbe63bca 100644
--- a/src/diffpy/pdfgui/gui/mainframe.py
+++ b/src/diffpy/pdfgui/gui/mainframe.py
@@ -758,21 +758,21 @@ def __menuBindings(self):
# For recent items
self.Bind(wx.EVT_MENU_RANGE, self.onMRUFile, id=wx.ID_FILE1, id2=wx.ID_FILE5)
- ## Edit Menu
+ # Edit Menu
self.Bind(wx.EVT_MENU, self.onDelete, id=self.deleteId)
self.Bind(wx.EVT_MENU, self.onCopy, id=self.copyId)
self.Bind(wx.EVT_MENU, self.onPaste, id=self.pasteId)
self.Bind(wx.EVT_MENU, self.onPasteLink, id=self.pasteLinkId)
self.Bind(wx.EVT_MENU, self.onPreferences, self.prefItem)
- ## View menu
+ # View menu
self.Bind(wx.EVT_MENU, self.onDefaultLayout, self.defaultLayoutItem)
self.Bind(wx.EVT_MENU, self.onShowFit, self.showFitItem)
self.Bind(wx.EVT_MENU, self.onShowPlot, self.showPlotItem)
self.Bind(wx.EVT_MENU, self.onShowOutput, self.showOutputItem)
self.Bind(wx.EVT_MENU, self.onShowJournal, self.showJournalItem)
- ## Fits Menu
+ # Fits Menu
self.Bind(wx.EVT_MENU, self.onNewFit, id=self.newFitId)
self.Bind(wx.EVT_MENU, self.onRun, id=self.runFitId)
self.Bind(wx.EVT_MENU, self.onStop, id=self.stopFitId)
@@ -780,9 +780,9 @@ def __menuBindings(self):
self.Bind(wx.EVT_MENU, self.onRSeries, self.rseriesItem)
self.Bind(wx.EVT_MENU, self.onTSeries, self.tseriesItem)
self.Bind(wx.EVT_MENU, self.onDSeries, self.dseriesItem)
- ## Macros are inserted individually
+ # Macros are inserted individually
- ## Phases Menu
+ # Phases Menu
self.Bind(wx.EVT_MENU, self.onInsPhase, id=self.newPhaseId)
self.Bind(wx.EVT_MENU, self.onPrintBL, id=self.printBLId)
self.Bind(wx.EVT_MENU, self.onPrintBA, id=self.printBAId)
@@ -791,16 +791,16 @@ def __menuBindings(self):
self.Bind(wx.EVT_MENU, self.onPlotIStruct, id=self.plotIStructId)
self.Bind(wx.EVT_MENU, self.onPlotFStruct, id=self.plotFStructId)
- ## Data Menu
+ # Data Menu
self.Bind(wx.EVT_MENU, self.onInsData, id=self.newDataId)
self.Bind(wx.EVT_MENU, self.onExportPDF, id=self.exportFitPDFId)
- ## Calculations Menu
+ # Calculations Menu
self.Bind(wx.EVT_MENU, self.onInsCalc, id=self.newCalcId)
self.Bind(wx.EVT_MENU, self.onRun, id=self.runCalcId)
self.Bind(wx.EVT_MENU, self.onSaveCalc, id=self.exportCalcPDFId)
- ## Help Menu
+ # Help Menu
self.Bind(wx.EVT_MENU, self.onDocumentation, self.docItem)
self.Bind(wx.EVT_MENU, self.onAbout, self.aboutItem)
self.Bind(wx.EVT_MENU, self.onRequest, self.requestItem)
@@ -1529,11 +1529,11 @@ def disableSharedMenuItems(self, menu):
noPhases = False
if node:
phases = self.treeCtrlMain.GetPhases(node)
- ## No insert calculation if there are no phases
+ # No insert calculation if there are no phases
if len(phases) == 0:
noPhases = True
- ## No insert calculation if there are no phases
+ # No insert calculation if there are no phases
if noPhases:
menu.Enable(self.newCalcId, False)
@@ -1544,7 +1544,7 @@ def disableSharedMenuItems(self, menu):
clipbranchtype = None
cdata = self.treeCtrlMain.GetClipboard()
- ## No paste if nothing in the clipboard
+ # No paste if nothing in the clipboard
if cdata is None:
menu.Enable(self.pasteId, False)
menu.Enable(self.pasteLinkId, False)
@@ -1573,7 +1573,7 @@ def disableSharedMenuItems(self, menu):
menu.SetLabel(self.pasteId, pastetext)
# Disable certain entries based upon where we clicked.
- ## No copy, paste, or insert on multiple items.
+ # No copy, paste, or insert on multiple items.
if len(selections) > 1:
menu.Enable(self.copyId, False)
menu.Enable(self.pasteId, False)
@@ -1581,7 +1581,7 @@ def disableSharedMenuItems(self, menu):
menu.Enable(self.newDataId, False)
menu.Enable(self.newPhaseId, False)
menu.Enable(self.newCalcId, False)
- ## Disallow paste of fit if no items selected
+ # Disallow paste of fit if no items selected
elif not selections:
menu.Enable(self.copyId, False)
menu.Enable(self.deleteId, False)
@@ -1708,7 +1708,7 @@ def disableMainMenuItems(self):
if not cdata.Gcalc:
menu.Enable(self.exportFitPDFId, False)
- ## Check the run/stop status.
+ # Check the run/stop status.
if self.runningDict:
menu.Enable(self.newId, False)
menu.Enable(self.runCalcId, False)
@@ -1756,7 +1756,7 @@ def disableMainMenuItems(self):
return
# Shared menu items
- ## The bulk of the code for these methods is in the FitTree class.
+ # The bulk of the code for these methods is in the FitTree class.
def onNewFit(self, event):
"""Start a new fit tree.
@@ -2377,7 +2377,14 @@ def onExportNewStruct(self, event):
# branchname = self.treeCtrlMain.GetBranchName(node)
name = self.treeCtrlMain.GetItemText(node)
basename = ".".join(name.split(".")[:-1]) or name
- matchstring = "PDFfit structure file (*.stru)|*.stru|Crystallographic Information File (*.cif)|*.cif|Protein Data Bank file (*.pdb)|*.pdb|Labeled coordinate file (*.xyz)|*.xyz|Raw corrdinate file (*.xyz)|*.xyz|AtomEye configuration file|*"
+ matchstring = (
+ "PDFfit structure file (*.stru)|*.stru|"
+ "Crystallographic Information File (*.cif)|*.cif|"
+ "Protein Data Bank file (*.pdb)|*.pdb|"
+ "Labeled coordinate file (*.xyz)|*.xyz|"
+ "Raw coordinate file (*.xyz)|*.xyz|"
+ "AtomEye configuration file|*"
+ )
d = wx.FileDialog(
None,
"Save as...",
@@ -2416,7 +2423,14 @@ def onExportStruct(self, event):
# branchname = self.treeCtrlMain.GetBranchName(node)
name = self.treeCtrlMain.GetItemText(node)
basename = ".".join(name.split(".")[:-1]) or name
- matchstring = "PDFfit structure file (*.stru)|*.stru|Crystallographic Information File (*.cif)|*.cif|Protein Data Bank file (*.pdb)|*.pdb|Labeled coordinate file (*.xyz)|*.xyz|Raw corrdinate file (*.xyz)|*.xyz|AtomEye configuration file|*"
+ matchstring = (
+ "PDFfit structure file (*.stru)|*.stru|"
+ "Crystallographic Information File (*.cif)|*.cif|"
+ "Protein Data Bank file (*.pdb)|*.pdb|"
+ "Labeled coordinate file (*.xyz)|*.xyz|"
+ "Raw coordinate file (*.xyz)|*.xyz|"
+ "AtomEye configuration file|*"
+ )
d = wx.FileDialog(
None,
"Save as...",
diff --git a/src/diffpy/pdfgui/gui/parameterspanel.py b/src/diffpy/pdfgui/gui/parameterspanel.py
index fc375704..ff043ff5 100644
--- a/src/diffpy/pdfgui/gui/parameterspanel.py
+++ b/src/diffpy/pdfgui/gui/parameterspanel.py
@@ -116,7 +116,7 @@ def refresh(self):
nRows = len(self.parameters)
- ### update the grid
+ # update the grid
# remove all rows and create new ones
self.grid_parameters.BeginBatch()
gridrows = self.grid_parameters.GetNumberRows()
@@ -297,7 +297,7 @@ def popupMenu(self, window, x, y):
menu.Destroy()
return
- ##### Popup menu events ##################################################
+ # Popup menu events ##################################################
def onPopupFill(self, event):
"""Fills cells selected in the grid with a new value"""
@@ -402,7 +402,7 @@ def onPopupRenameParameters(self, event):
event.Skip()
return
- ##### end of Popup menu events ###########################################
+ # end of Popup menu events ###########################################
def onApplyParameters(self, event): # wxGlade: ParametersPanel.
self.fit.applyParameters()
@@ -439,7 +439,7 @@ def fillCells(self, indices, value):
# end of class ParametersPanel
-##### testing code ############################################################
+# testing code ############################################################
if __name__ == "__main__":
class MyFrame(wx.Frame):
@@ -481,4 +481,4 @@ def onInit(self):
app = MyApp(0)
app.MainLoop()
-##### end of testing code #####################################################
+# end of testing code #####################################################
diff --git a/src/diffpy/pdfgui/gui/pdfguiglobals.py b/src/diffpy/pdfgui/gui/pdfguiglobals.py
index b19a7ddb..96f20538 100644
--- a/src/diffpy/pdfgui/gui/pdfguiglobals.py
+++ b/src/diffpy/pdfgui/gui/pdfguiglobals.py
@@ -19,6 +19,8 @@
from pkg_resources import Requirement, resource_filename
+from diffpy.pdfgui.gui import debugoptions
+
# Name of the program
name = "PDFgui"
# Maximum number of files to be remembered
@@ -76,7 +78,6 @@ def iconpath(iconfilename):
cmdargs = []
# debugging options:
-from diffpy.pdfgui.gui import debugoptions
dbopts = debugoptions.DebugOptions()
diff --git a/src/diffpy/pdfgui/gui/tooltips.py b/src/diffpy/pdfgui/gui/tooltips.py
index 095b4ffa..ff860132 100644
--- a/src/diffpy/pdfgui/gui/tooltips.py
+++ b/src/diffpy/pdfgui/gui/tooltips.py
@@ -17,9 +17,12 @@
"""
+def isalias(s):
+ return s[1:-1] and s[:: len(s) - 1] == "{}" and s[1:-1].replace("_", "").isalnum()
+
+
def _expand_tooltip_aliases(ttps):
"Replace aliased equivalent values {other} in tooltip strings."
- isalias = lambda s: (s[1:-1] and s[:: len(s) - 1] == "{}" and s[1:-1].replace("_", "").isalnum())
for n, t in list(ttps.items()):
if not isalias(t):
continue
@@ -79,7 +82,10 @@ def _expand_tooltip_aliases(ttps):
dopingseriespanel = {
- # 'instructionsLabel' : '', # StaticText "Select a fit from the tree on the left then add datasets and assign\ndoping elements and values below. If you have not set up a fit to be\nthe template for the series, hit cancel and rerun this macro once a\nfit has been created."
+ # 'instructionsLabel' : '', # StaticText "Select a fit from the tree on the left then add
+ # datasets and assign\ndoping elements and values below. If you
+ # have not set up a fit to be\nthe template for the series, hit
+ # cancel and rerun this macro once a\nfit has been created."
# 'labelBaseElement' : '', # StaticText "Base element"
# 'textCtrlBaseElement' : '', # TextCtrl
# 'labelDopant' : '', # StaticText "Dopant"
@@ -175,7 +181,9 @@ def _expand_tooltip_aliases(ttps):
temperatureseriespanel = {
- # 'instructionsLabel' : '', # StaticText "Select a fit from the tree on the left then add datasets and assign\ntemperatues below. If you have not set up a fit to be the template\nfor the series, hit cancel and rerun this macro once a fit has been\ncreated."
+ # 'instructionsLabel' : '', # StaticText "Select a fit from the tree on the left
+ # then add datasets and assign\ntemperatues below. If you have not set up a fit to
+ # be the template\nfor the series, hit cancel and rerun this macro once a fit has been\ncreated."
"listCtrlFiles": "Click header to sort by temperature", # AutoWidthListCtrl
# 'buttonUp' : '', # BitmapButton
# 'buttonDown' : '', # BitmapButton
diff --git a/src/diffpy/pdfgui/gui/windowperspective.py b/src/diffpy/pdfgui/gui/windowperspective.py
index 838be3ca..4c2e205b 100644
--- a/src/diffpy/pdfgui/gui/windowperspective.py
+++ b/src/diffpy/pdfgui/gui/windowperspective.py
@@ -15,4 +15,4 @@
"""This contains the default perspective for the gui window."""
-default = "layout2|name=dseries;caption=;state=770;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=400;besth=380;minw=190;minh=200;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=calculation;caption=;state=770;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=400;besth=380;minw=190;minh=200;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=welcome;caption=;state=768;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=400;besth=380;minw=190;minh=200;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=adddata;caption=;state=770;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=400;besth=380;minw=190;minh=200;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=serverconfig;caption=;state=770;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=400;besth=380;minw=190;minh=200;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=addphase;caption=;state=770;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=400;besth=380;minw=190;minh=200;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=blank;caption=;state=770;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=400;besth=380;minw=190;minh=200;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=phase;caption=;state=770;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=400;besth=380;minw=190;minh=200;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=dataset;caption=;state=770;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=400;besth=380;minw=190;minh=200;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=preferences;caption=;state=770;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=400;besth=380;minw=190;minh=200;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=fit;caption=;state=770;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=400;besth=380;minw=190;minh=200;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=rseries;caption=;state=770;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=400;besth=380;minw=190;minh=200;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=tseries;caption=;state=770;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=400;besth=380;minw=190;minh=200;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=outputPanel;caption=PDFfit2 Output;state=10487804;dir=3;layer=0;row=0;pos=0;prop=100000;bestw=400;besth=40;minw=200;minh=40;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=treeCtrlMain;caption=Fit Tree;state=10487804;dir=4;layer=0;row=0;pos=0;prop=100000;bestw=200;besth=100;minw=200;minh=40;maxw=-1;maxh=-1;floatx=471;floaty=730;floatw=208;floath=124|name=plotPanel;caption=Plot Control;state=10487804;dir=4;layer=0;row=0;pos=1;prop=100000;bestw=200;besth=250;minw=200;minh=150;maxw=-1;maxh=-1;floatx=337;floaty=393;floatw=208;floath=274|name=journalPanel;caption=Project Journal;state=10487807;dir=4;layer=0;row=0;pos=0;prop=100000;bestw=450;besth=450;minw=200;minh=200;maxw=-1;maxh=-1;floatx=393;floaty=113;floatw=450;floath=450|dock_size(3,0,0)=59|dock_size(4,0,0)=202|dock_size(5,0,0)=362|"
+default = "layout2|name=dseries;caption=;state=770;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=400;besth=380;minw=190;minh=200;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=calculation;caption=;state=770;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=400;besth=380;minw=190;minh=200;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=welcome;caption=;state=768;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=400;besth=380;minw=190;minh=200;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=adddata;caption=;state=770;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=400;besth=380;minw=190;minh=200;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=serverconfig;caption=;state=770;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=400;besth=380;minw=190;minh=200;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=addphase;caption=;state=770;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=400;besth=380;minw=190;minh=200;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=blank;caption=;state=770;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=400;besth=380;minw=190;minh=200;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=phase;caption=;state=770;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=400;besth=380;minw=190;minh=200;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=dataset;caption=;state=770;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=400;besth=380;minw=190;minh=200;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=preferences;caption=;state=770;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=400;besth=380;minw=190;minh=200;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=fit;caption=;state=770;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=400;besth=380;minw=190;minh=200;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=rseries;caption=;state=770;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=400;besth=380;minw=190;minh=200;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=tseries;caption=;state=770;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=400;besth=380;minw=190;minh=200;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=outputPanel;caption=PDFfit2 Output;state=10487804;dir=3;layer=0;row=0;pos=0;prop=100000;bestw=400;besth=40;minw=200;minh=40;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|name=treeCtrlMain;caption=Fit Tree;state=10487804;dir=4;layer=0;row=0;pos=0;prop=100000;bestw=200;besth=100;minw=200;minh=40;maxw=-1;maxh=-1;floatx=471;floaty=730;floatw=208;floath=124|name=plotPanel;caption=Plot Control;state=10487804;dir=4;layer=0;row=0;pos=1;prop=100000;bestw=200;besth=250;minw=200;minh=150;maxw=-1;maxh=-1;floatx=337;floaty=393;floatw=208;floath=274|name=journalPanel;caption=Project Journal;state=10487807;dir=4;layer=0;row=0;pos=0;prop=100000;bestw=450;besth=450;minw=200;minh=200;maxw=-1;maxh=-1;floatx=393;floaty=113;floatw=450;floath=450|dock_size(3,0,0)=59|dock_size(4,0,0)=202|dock_size(5,0,0)=362|" # noqa: E501
diff --git a/src/diffpy/pdfgui/gui/wxextensions/validators.py b/src/diffpy/pdfgui/gui/wxextensions/validators.py
index 5a09ffff..dd99d7cc 100644
--- a/src/diffpy/pdfgui/gui/wxextensions/validators.py
+++ b/src/diffpy/pdfgui/gui/wxextensions/validators.py
@@ -12,6 +12,9 @@
# See LICENSE.txt for license information.
#
##############################################################################
+import string
+
+import wx
"""This module contains TextValidator, which is an input validator for the
wxTextCtrl. See the wxPython documentation for wxTextCtrl for more about text
@@ -23,10 +26,6 @@
DIGIT_ONLY = 2
FLOAT_ONLY = 3
-import string
-
-import wx
-
class TextValidator(wx.Validator):
"""This validator is designed to check text input for wxTextCtrls. (It might
diff --git a/src/diffpy/pdfgui/tests/testaboutdialog.py b/src/diffpy/pdfgui/tests/testaboutdialog.py
index 1123d46d..44078276 100644
--- a/src/diffpy/pdfgui/tests/testaboutdialog.py
+++ b/src/diffpy/pdfgui/tests/testaboutdialog.py
@@ -43,11 +43,13 @@ def _clickbutton(self, button):
self.dialog.ProcessEvent(e)
return
+ def set_url(self, u):
+ setattr(self, "url", u)
+
def test_LogoClicks(self):
"Check handling of clicks on various logos"
d = self.dialog
- stealurl = lambda u: setattr(self, "url", u)
- with overridewebbrowser(stealurl):
+ with overridewebbrowser(self.set_url):
self._clickbutton(d.bitmap_button_nsf)
self.assertTrue(self.url.endswith("www.nsf.gov"))
self._clickbutton(d.bitmap_button_danse)