From 6f7c7e93103d37cf2937422df71bcb8e5ec96a83 Mon Sep 17 00:00:00 2001 From: Gregory Jefferis Date: Thu, 16 Apr 2015 07:39:24 +0100 Subject: [PATCH] more flexible path status colours/messages * closes https://github.com/jefferis/fiji-cmtk-gui/issues/9 --- CMTK_Registration_GUI.py | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/CMTK_Registration_GUI.py b/CMTK_Registration_GUI.py index 3a99b0d..cb263dc 100644 --- a/CMTK_Registration_GUI.py +++ b/CMTK_Registration_GUI.py @@ -29,26 +29,32 @@ def textValueChanged(self, tvc): statusf.setText('Please choose valid root directory') statusf.setForeground(Color.red) return - imgdir = os.path.join(regroot,'images') - if os.path.exists(imgdir): + # check if we already have a sensible images dir - if not, then set + imgdir = imgdirf.getText() + if len(imgdir)==0 or not os.path.exists(imgdir): + imgdir = os.path.join(regroot,'images') imgdirf.setText(imgdir) - imgdirf.setForeground(Color.black) + else: statusf.setText('') - return - imgdirf.setForeground(Color.red) - statusf.setText('Please choose input image/directory') - statusf.setForeground(Color.red) class ImageDirListener(TextListener): def textValueChanged(self, tvc): - regroot = regrootf.getText() - if len(regroot)>0 and os.path.exists(regroot): - #print "regroot:"+regroot+ " exists!" - return imgdir = imgdirf.getText() - if len(imgdir)>0 and os.path.exists(imgdir): - regrootf.setText(os.path.dirname(imgdir)) + # no comment if unset + if len(imgdir)==0: + statusf.setText('') return + # no comment if unset + if os.path.exists(imgdir): + statusf.setText('') + imgdirf.setForeground(Color.black) + regroot = regrootf.getText() + if len(regroot)==0 or not os.path.exists(regroot): + regrootf.setText(os.path.dirname(imgdir)) + else: + imgdirf.setForeground(Color.red) + statusf.setText('Please choose valid images directory') + statusf.setForeground(Color.red) class OuputSuffixListener(TextListener): def textValueChanged(self, tvc):