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

def board1::Board::drawBoard (   self  ) 

Displays the background picture, and draws the lines and hoshi points of
    the go board.
    If PIL is installed, this also creates the PhotImages for black, white stones. 

Definition at line 247 of file board1.py.

00247                        :
        """ Displays the background picture, and draws the lines and hoshi points of
            the go board.
            If PIL is installed, this also creates the PhotImages for black, white stones. """

        self.delete('non-bg')     # delete everything except for background image
        c0, c1 = self.canvasSize
        size = 2*c0 + (self.boardSize-1)*c1
        self.config(height=size, width=size)
        
        if self.img:
            self.delete('board')
            for i in range(size/100 + 1):
                for j in range(size/100 + 1):
                    self.create_image(100*i,100*j,image=self.img, tags='board')

        color = 'black'

        for i in range(self.boardSize):
          self.create_line(c0, c0 + c1*i, c0 + (self.boardSize-1)*c1, c0 + c1*i, fill=color, tags='non-bg')
          self.create_line(c0 + c1*i, c0, c0 + c1*i, c0+(self.boardSize-1)*c1, fill=color, tags='non-bg')

        # draw hoshi's:

        if c1 > 7:

            if self.boardSize in [13,19]:
                b = (self.boardSize-7)/2
                for i in range(3):
                    for j in range(3): 
                        self.create_oval(c0 + (b*i+3)*c1 - 2, c0 + (b*j+3)*c1 - 2,
                                         c0 + (b*i+3)*c1 + 2, c0 + (b*j+3)*c1 + 2, fill = 'black', tags='non-bg')
            elif self.boardSize == 9:
                self.create_oval(c0 + 4*c1 - 2, c0 + 4*c1 - 2,
                                 c0 + 4*c1 + 2, c0 + 4*c1 + 2, fill = 'black', tags='non-bg')

        # draw coordinates:

        if self.coordinates:
            for i in range(self.boardSize):
                a = 'ABCDEFGHJKLMNOPQRST'[i]
                self.create_text(c0 + c1*i, c1*self.boardSize+3*c0/4+4, text=a,
                                 font = ('Helvetica', 5+c1/7, 'bold'))
                self.create_text(c0 + c1*i, c0/4+1, text=a, font = ('Helvetica', 5+c1/7, 'bold'))
                self.create_text(c0/4+1, c0+c1*i, text=`self.boardSize-i`,font = ('Helvetica', 5+c1/7, 'bold'))
                self.create_text(c1*self.boardSize+3*c0/4+4, c0 + c1*i, text=`self.boardSize-i`, font = ('Helvetica', 5+c1/7, 'bold'))
                


        global PILinstalled
        if PILinstalled:
            try:
                self.bStone = ImageTk.PhotoImage(self.blackStone.resize((c1,c1)))
                self.wStone = ImageTk.PhotoImage(self.whiteStone.resize((c1,c1)))
            except:
                PILinstalled = 0




    def resize(self, event = None):


Generated by  Doxygen 1.6.0   Back to index