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

def board1::Board::placeLabel (   self,
  pos,
  type,
  text = None,
  color = None,
  override = None 
)

Place label of type type at pos; used to display labels
    from SGF files. If type has the form +XX, add a label of type XX.
    Otherwise, add or delete the label, depending on if there is no label at pos,
    or if there is one.

Definition at line 451 of file board1.py.

00451                                                                          :
        """ Place label of type type at pos; used to display labels
            from SGF files. If type has the form +XX, add a label of type XX.
            Otherwise, add or delete the label, depending on if there is no label at pos,
            or if there is one."""

        if type[0] != '+':

            if self.labels.has_key(pos):
                if self.labels[pos][0] == type:
                    for item in self.labels[pos][2]: self.delete(item)
                    del self.labels[pos]
                    return
                else:
                    for item in self.labels[pos][2]: self.delete(item)
                    del self.labels[pos]

            self.onChange()

        else: type = type[1:]

        labelIDs = []

        if override:
            fcolor = override[0]
            fcolor2 = override[1]
        elif self.status.has_key(pos) and self.status[pos]=='B':
            fcolor = 'white'
            fcolor2 = '#FFBA59'
        elif self.status.has_key(pos) and self.status[pos]=='W':
            fcolor = 'black'
            fcolor2 = ''
        else:
            fcolor = color or 'black'
            fcolor2 = '#FFBA59'
                    
        x1, x2, y1, y2 = self.getPixelCoord(pos, 1)
        if type == 'LB':
            labelIDs.append(self.create_oval(x1+3, x2+3, y1-3, y2-3, fill=fcolor2, outline='',
                                             tags=('label', 'non-bg')))
            labelIDs.append(self.create_text((x1+y1)/2,(x2+y2)/2, text=text, fill=fcolor,
                                             font = (self.labelFont[0].get(), self.labelFont[1].get() + self.canvasSize[1]/5,
                                                     self.labelFont[2].get()),
                                             tags=('label', 'non-bg')))
        elif type == 'SQ':
            labelIDs.append(self.create_rectangle(x1+6, x2+6, y1-6, y2-6, fill = fcolor, tags=('label','non-bg')))
        elif type == 'CR':
            labelIDs.append(self.create_oval(x1+5, x2+5, y1-5, y2-5, fill='', outline=fcolor, tags=('label','non-bg')))
        elif type == 'TR':
            labelIDs.append(self.create_polygon((x1+y1)/2, x2+5, x1+5, y2-5, y1-5, y2-5, fill = fcolor,
                                                tags = ('label', 'non-bg')))
        elif type == 'MA':
            labelIDs.append(self.create_oval(x1+2, x2+2, y1-2, y2-2, fill=fcolor2, outline='',
                             tags=('label', 'non-bg')))
            labelIDs.append(self.create_text(x1+12,x2+12, text='X', fill=fcolor,
                                             font = (self.labelFont[0].get(), self.labelFont[1].get() + 1 + self.canvasSize[1]/5,
                                                     self.labelFont[2].get()),
                                             tags=('label', 'non-bg')))
            
        self.labels[pos] = (type, text, labelIDs)


            
    def placeStone(self, pos, color):


Generated by  Doxygen 1.6.0   Back to index