Example #1
0
        def openAxFile(self, event):
            #
            # let the user choose the parameters
            #
            #pp_module="PsaltikiPage"

            axfilename = ""
            tmpdir = ""
            imgdir = ""
            imgvisual = True
            imgmusic = True
            imglyrics = False
            imgborder = False
            imgornate = False
            imgtext = False
            imgtitle = False
            imgflat = False
            imggrey = False
            #opt = c_opt()
            # start options dialog
            dialog = Args([FileOpen("Aruspix file", axfilename, "*.axz"),
                #Directory("or all Aruspix Files in folder", imgdir),
                Directory("Temporary directory (optional)", tmpdir),
                Check("Visualize image","",True),
                Check("Extract music staves","",True),
                Check("Extract lyrics"),
                Check("Extract title elements"),
                Check("Extract ornate letters"),
                Check("Extract text in staff"),
                Check("Extract borders"),
                Check("Flatten as BW"),
                Check("Original greyscale image")],
                name = "Select options")
            
            params = dialog.show()

            if not params:
                return

            i = 0
            axfilename = params[i]; i+=1
            if axfilename == "":
                return
            tmpdir = params[i]; i+=1
            if tmpdir == None:
                tmpdir = ""
            imgvisual = params[i]; i+=1
            imgmusic = params[i]; i+=1
            imglyrics = params[i]; i+=1
            imgborders = params[i]; i+=1
            imgornate = params[i]; i+=1
            imgtext = params[i]; i+=1
            imgtitle = params[i]; i+=1
            imgflat = params[i]; i+=1
            imggrey = params[i]; i+=1
            
            axfile = AxFile(axfilename, tmpdir)
        
            global swap
            swap = axfile.get_img0()
    
            if imgvisual == True:
                name = var_name.get("aruspix_img",\
                    self._shell.locals)
                self._shell.run("%s = %s.swap.visualize()"\
                    % (name, self.label ))
        
            if imgmusic == True:
                name = var_name.get("staves",\
                    self._shell.locals)
                self._shell.run("%s = %s.swap.extract(0)"\
                    % (name, self.label ))
        
            if imglyrics == True:
                name = var_name.get("lyrics",\
                    self._shell.locals)
                self._shell.run("%s = %s.swap.extract(4)"\
                    % (name, self.label ))

            if imgborders == True:
                name = var_name.get("borders",\
                    self._shell.locals)
                self._shell.run("%s = %s.swap.extract(1)"\
                    % (name, self.label ))

            if imgornate == True:
                name=var_name.get("ornate_letters",\
                    self._shell.locals)
                self._shell.run("%s = %s.swap.extract(2)"\
                    % (name, self.label ))

            if imgtext == True:
                name=var_name.get("text_in_staff",\
                    self._shell.locals)
                self._shell.run("%s = %s.swap.extract(3)"\
                    % (name, self.label ))

            if imgtitle == True:
                name=var_name.get("titles",\
                    self._shell.locals)
                self._shell.run("%s = %s.swap.extract(5)"\
                    % (name, self.label ))

            if imgflat == True:
                name=var_name.get("all",\
                    self._shell.locals)
                self._shell.run("%s = %s.swap.flatten()"\
                    % (name, self.label ))

            if imggrey == True:
                swap = axfile.get_img1()
                name=var_name.get("original",\
                    self._shell.locals)
                self._shell.run("%s = %s.swap.image_copy()"\
                    % (name, self.label ))