Skip to content

Commit

Permalink
Merge branch 'fix/error-colours'
Browse files Browse the repository at this point in the history
* closes #9
* fix/error-colours:
  more flexible path status colours/messages
  os.path.exists("") is True
  complain if regroot is bad
  missing import of Color class
  • Loading branch information
jefferis committed Apr 16, 2015
2 parents c567b7e + 6f7c7e9 commit 6d84463
Showing 1 changed file with 30 additions and 14 deletions.
44 changes: 30 additions & 14 deletions CMTK_Registration_GUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -17,28 +18,43 @@
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()
imgdir = os.path.join(regroot,'images')
if os.path.exists(imgdir):
else:
regrootf.setForeground(Color.red)
statusf.setText('Please choose valid root directory')
statusf.setForeground(Color.red)
return
# 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 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):
Expand Down

0 comments on commit 6d84463

Please sign in to comment.