From 4ec2cd48a122f59a5416fd80d0e7d844ffddef26 Mon Sep 17 00:00:00 2001 From: Gregory Jefferis Date: Wed, 15 Apr 2015 13:15:58 +0100 Subject: [PATCH 1/4] missing import of Color class * this reinstates coloured highlighting of text when bad directories are entered --- CMTK_Registration_GUI.py | 1 + 1 file changed, 1 insertion(+) diff --git a/CMTK_Registration_GUI.py b/CMTK_Registration_GUI.py index 092c68e..f6f948b 100644 --- a/CMTK_Registration_GUI.py +++ b/CMTK_Registration_GUI.py @@ -2,6 +2,7 @@ from java.awt.event import TextListener from java.awt.event import ItemListener from java.awt import Font +from java.awt import Color from java.lang import Runtime import os,subprocess,sys From 924aaf86307132882528b74c9f241bb7444eab18 Mon Sep 17 00:00:00 2001 From: Gregory Jefferis Date: Wed, 15 Apr 2015 13:47:41 +0100 Subject: [PATCH 2/4] complain if regroot is bad --- CMTK_Registration_GUI.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/CMTK_Registration_GUI.py b/CMTK_Registration_GUI.py index f6f948b..b8484bc 100644 --- a/CMTK_Registration_GUI.py +++ b/CMTK_Registration_GUI.py @@ -18,8 +18,17 @@ class RegRootListener(TextListener): def textValueChanged(self, tvc): regroot = regrootf.getText() - if len(regroot)>0 and os.path.exists(regroot): + if len(regroot)==0: + statusf.setText('') + return + if os.path.exists(regroot): + regrootf.setForeground(Color.black) updateOuputFolders() + else: + regrootf.setForeground(Color.red) + statusf.setText('Please choose valid root directory') + statusf.setForeground(Color.red) + return imgdir = os.path.join(regroot,'images') if os.path.exists(imgdir): imgdirf.setText(imgdir) From a7346be8cd37368501922a67ca1a7f1ff66064e6 Mon Sep 17 00:00:00 2001 From: Gregory Jefferis Date: Wed, 15 Apr 2015 13:58:45 +0100 Subject: [PATCH 3/4] os.path.exists("") is True so need to check for this explicitly --- CMTK_Registration_GUI.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMTK_Registration_GUI.py b/CMTK_Registration_GUI.py index b8484bc..3a99b0d 100644 --- a/CMTK_Registration_GUI.py +++ b/CMTK_Registration_GUI.py @@ -46,7 +46,7 @@ def textValueChanged(self, tvc): #print "regroot:"+regroot+ " exists!" return imgdir = imgdirf.getText() - if os.path.exists(imgdir): + if len(imgdir)>0 and os.path.exists(imgdir): regrootf.setText(os.path.dirname(imgdir)) return From 6f7c7e93103d37cf2937422df71bcb8e5ec96a83 Mon Sep 17 00:00:00 2001 From: Gregory Jefferis Date: Thu, 16 Apr 2015 07:39:24 +0100 Subject: [PATCH 4/4] 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):