Logo Search packages:      
Sourcecode: uligo version File versions  Download package

def uligo::App::readProblemColl (   self,
  path = None,
  filename = None 
)

Read a collection of problems from the SGF file given by filename (if None, ask
    for a filename. The file is then split into single problems. The actual parsing
    is done in nextProblem (only the current problem is parsed), to save time. 

Definition at line 834 of file uligo.py.

00834                                                            :
        """ Read a collection of problems from the SGF file given by filename (if None, ask
            for a filename. The file is then split into single problems. The actual parsing
            is done in nextProblem (only the current problem is parsed), to save time. """

        if not self.options.problemModeVar.get():
            self.packGM(0)
            self.options.problemModeVar.set(1)
        
        if self.pbmRec:                  # save statistics for old problem collection
            self.pbmRec.saveToDisk()

        self.creditAvailable = 0
        self.clock.stop()
        self.clock.reset()
        self.cursor = None
        
        if not path or not filename:
            path, filename = os.path.split(tkFileDialog.askopenfilename(filetypes=[('SGF files', '*.sgf'),
                                                                                   ('All files', '*')],
                                                                        initialdir=self.sgfpath))
        if filename:
            try:
                f = open(os.path.join(path,filename))
                s = f.read()
                f.close()
            except IOError:
                showwarning('Open file', 'Cannot open this file\n')
                return
        else:
            self.currentFile = ''
            self.sgfpath = ''
            return
        
        i = 0
                
        self.comments.config(state=NORMAL)
        self.comments.delete('1.0', END)
        self.comments.insert('1.0', 'Reading SGF file ...')
        self.comments.config(state=DISABLED)
        self.board.clear()
        self.board.delMarks()
        self.statusbar.set('empty')
        self.pbmName.set('')
                
        if self.tryVarVar.get():
            self.tryVarButton.deselect()
            self.tryVariation()
        if self.showSolVar.get():
            self.showSolutionButton.deselect()
            self.showSolution()
        self.disableButtons()
        self.board.state('disabled')
        self.master.update()

        # Display everything before the first '(' as a comment:

        j = self.findNextParenthesis(s,0)
        comment = s[0:j]

        # split the file into single SGF games:

        self.pbms=[]
        while i<len(s):
            i = self.findNextParenthesis(s, i)
            if i<len(s):
                j = self.findMatchingParenthesis(s, i)
                self.pbms.append(s[i:j+1])
                i = j+1

        self.comments.config(state=NORMAL)
        self.comments.delete('1.0', END)
        self.comments.insert('1.0', comment)
        self.comments.config(state=DISABLED)

        self.pbmRec = PbmRecord(self.datpath + path, filename,
                                len(self.pbms), self.options.modeVar)

        if self.pbms:                             
            self.currentFile = filename
            self.sgfpath = path
            self.optionsmenu.entryconfig(9,state=NORMAL, command=self.pbmRec.changeMode)
        else:
            self.optionsmenu.entryconfig(9,state=DISABLED)

       
    def quit(self):


Generated by  Doxygen 1.6.0   Back to index