1 ### This simple code illustrates how the behavior of the parsing of
2 ### directory in order to build a DicomDir can be controlled by
3 ### the caller. By caller control we mean two things:
4 ### 1/ watch the advancement of the parsing
5 ### 2/ abort it on caller demand
6 ### In this example we arbitrarily stop the parsing (see progessMethod() )
7 ### when the parsing reaches 20% of it's duty. A typical GUI usage of
8 ### this mecanism would be to offer a "Cancel" button to the user...
9 from gdcmPython import *
12 ### Get the pathname from command line or default it to .
14 DirPathName = sys.argv[1]
18 ### The python defined methods that we wan't to call back
22 print "Progress", dicomDir.GetProgress()
23 if( dicomDir.GetProgress() > 0.2 ):
24 dicomDir.AbortProgress()
28 dicomDir=gdcm.DicomDir( DirPathName )
29 print dicomDir.IsReadable()
30 ### Set up the call backs:
31 dicomDir.SetStartMethod(startMethod)
32 dicomDir.SetProgressMethod(progressMethod)
33 dicomDir.SetEndMethod(endMethod)
34 ### Launch the parsing of the directory
35 dicomDir.ParseDirectory()