Skip to content

Commit 20abfc2

Browse files
committed
start work on logging tree changes; add __version__ to main GSASII module
1 parent 172608b commit 20abfc2

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

GSASII/GSASIIGUI.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
__version__ = '5.0.0'
1717
gv = GSASIIpath.getSavedVersionInfo()
1818
if gv is not None:
19-
if len(gv.git_tags):
19+
if len(gv.git_versiontag):
20+
__version__ = gv.git_versiontag[1:]
21+
elif len(gv.git_tags):
2022
__version__ = gv.git_tags[0]
2123
elif len(gv.git_prevtags):
2224
__version__ = gv.git_prevtags[0]
@@ -94,7 +96,18 @@ def MacOpenFiles(self, filenames):
9496
if sys.platform == "darwin":
9597
wx.CallLater(50,application.ClearStartup)
9698
GSASIIpath.InvokeDebugOpts()
99+
wx.GetApp().Yield()
100+
wx.CallLater(2000,DoStuff)
97101
application.MainLoop()
98102

103+
def DoStuff():
104+
import wx
105+
wx.GetApp().Yield()
106+
print('entering DoStuff')
107+
wx.Sleep(1)
108+
print('after wait')
109+
wx.Sleep(2)
110+
print('leaving DoStuff')
111+
wx.GetApp().Yield()
99112
if __name__ == '__main__':
100113
main()

GSASII/GSASIIdataGUI.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ def new_util_find_library( name ):
9999
commonNames = ['abc','bca','cab','a-cb','ba-c','-cba','P->A','A->P','P->B','B->P','P->C','C->P',
100100
'P->I','I->P','P->F','F->P','H->R','R->H','R->O','O->R','abc*','setting 1->2'] #don't put any new ones after the setting one!
101101

102+
loggingExitCommands = []
103+
# clear out any old commamnds in the file
104+
with open('/tmp/G2logging.txt','w') as fp:
105+
fp.write(f'# GSAS-II event logging file {time.ctime()}\n')
106+
102107
def GetDisplay(pos):
103108
'''Gets display number (0=main display) for window position (pos). If pos outside all displays
104109
returns None
@@ -617,6 +622,7 @@ def GSASIImain(application):
617622
dlg.ShowModal()
618623
finally:
619624
dlg.Destroy()
625+
for cmd in loggingExitCommands: cmd() # cleanup logging
620626
sys.exit()
621627

622628
application.main = GSASII(None) # application.main is the main wx.Frame (G2frame in most places)
@@ -634,6 +640,11 @@ def GSASIImain(application):
634640
class G2EventLogger(wx.EvtHandler):
635641
'''This is used to record all wx events
636642
'''
643+
def log2File(self,txt):
644+
with open('/tmp/G2logging.txt','a') as fp:
645+
fp.write(txt)
646+
fp.write('\n')
647+
637648
def ProcessEvent(self, event):
638649
# how to log "action" widgets (checkbuttons, buttons, etc.)?
639650
# How to log info supplied in dialogs
@@ -650,6 +661,7 @@ def ShowTreeSelection(tree):
650661
txt = tree.GetItemText(sel)
651662
print(' parent',txt)
652663
print('Tree selection (after)',l)
664+
self.log2File(f'Tree_selection: {l}')
653665
#fp = open('/tmp/events.txt','a')
654666
#print(f"Event {event.GetEventType()} Obj {event.GetEventObject()}")
655667
#fp.write(f"Event {event.GetEventType()} Obj {event.GetEventObject()}\n")
@@ -710,11 +722,12 @@ def logFrame(self,frame):
710722
self.eventLog = {}
711723
self.start = time.time()
712724
self.G2frame = frame
713-
frame.PushEventHandler(self)
725+
self.G2frame.PushEventHandler(self)
726+
loggingExitCommands.append(self.unlogFrame)
714727
def unlogFrame(self):
715728
# note that we need to do a PopEventHandler before the
716729
# frame is deleted
717-
frame.PopEventHandler(self)
730+
self.G2frame.PopEventHandler()
718731

719732
#### Create main frame (window) for GUI; main menu items here #######################################
720733
class GSASII(wx.Frame):
@@ -2448,6 +2461,7 @@ def OnPreferences(self,event):
24482461
project = None
24492462
G2fil.openInNewTerm(project)
24502463
print ('exiting GSAS-II')
2464+
for cmd in loggingExitCommands: cmd() # cleanup logging
24512465
sys.exit()
24522466

24532467
def _Add_ImportMenu_smallangle(self,parent):
@@ -4684,6 +4698,7 @@ def ExitMain(self, event):
46844698
self.G2plotNB.Destroy()
46854699
if self.undofile and os.path.exists(self.undofile):
46864700
os.remove(self.undofile)
4701+
for cmd in loggingExitCommands: cmd() # cleanup logging
46874702
sys.exit()
46884703

46894704
def OnExportMTZ(self,event):

GSASII/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@ def no_path_hacking(event_name, args):
3030

3131

3232
from .GSASIIGUI import main # noqa: E402
33+
from .GSASIIGUI import __version__
3334

3435
__all__ = ['main']

0 commit comments

Comments
 (0)