예제 #1
0
    def getBoard(self):
        """Main graphics point of the program; shows the board."""
        self.extraList = ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", \
                     "TWS", "DWS", "TLS", "DLS", \
                     "A ", "B ", "C ", "D ", "E ", "F ", "G ", "H ", "I ", "J ", "K ", "L ", "M ", "N ", "O ", \
                     "*", " "]
        colors = {"TWS":"red", "DWS":"pink", "TLS":"light green", "DLS":"light blue", "*":"pink"}
        self.boardFrame = func.Frame(self.root, bd=1, relief=func.SUNKEN)
        self.boardFrame.place(x=50, y=50, width=497, height = 497)
        labels = list()
        squares = list()

        for i in range(16):
            for j in range(16):
                label = self.board[j][i]
                if label in self.extraList:
                    entry = func.Frame(self.boardFrame, bd=1, relief=func.RAISED)
                    entry.place(x=(i*31), y=(j*31), width=31, height=31)
                    labels.append(func.Label(entry, text = label,
                                            height = 31, width = 31))
                    if label in colors.keys():
                        labels[-1].config(bg=colors[label])
                        
                    labels[-1].pack()
                else:
                    if mpl_in == 0:
                        frame = func.Frame(self.boardFrame, bd=1, relief=func.RAISED)
                        frame.place(x=(i*31), y=(j*31), width=31, height=31)
                        entry = func.Frame(self.boardFrame, bd=1, relief=func.SUNKEN)
                        entry.place(x=(i*31) + 3, y=(j*31) + 3, width=25, height=25)
                        squares.append(func.Label(entry, bd = 1, text=label+self.getSubscript(self.scores[label.lower()]),
                                             height=25, width=25, relief=func.RAISED))
                        squares[-1].pack(fill=func.X, padx=1, pady=1)
                        entry.lift()
                        
                    else:
                        #frame = func.Frame(self.boardFrame, bd=1, relief=func.RAISED)
                        #frame.place(x=(i*31), y=(j*31), width=31, height=31)
                        #entry = func.Frame(self.boardFrame, bd=1, relief=func.SUNKEN)
                        #entry.place(x=(i*31) + 3, y=(j*31) + 3, width=25, height=25)
                        hf = Subscript(self.boardFrame, label, i*31, j*31, board=True)
                        #squares.append(hf.label)
                        #squares[-1].pack(fill=func.X, padx=1, pady=1)
                        print(hf.letter)
                    
                    
        self.helpLabel = func.Label(self.root, text = "Note: For best tile placement, \naim for below and to the right of the square.", )
        self.helpLabel.place(x=50, y=10, height=35, width=497)
예제 #2
0
 def getExchangeRack(self):
     self.exchangeRack = func.Frame(self.root, bd=1, relief=func.RAISED)
     self.exchangeRack.place(x=self.exchangeRackX, y=self.exchangeRackY, width=self.exchangeRackWidth, height = self.exchangeRackHeight)
     labels = []
     for i in range(7):
         labels.append(func.Label(self.exchangeRack, relief=func.SUNKEN))
         labels[-1].place(x=i*30+self.exchangeRackX, y=self.exchangeRackY, height=30, width=30)            
예제 #3
0
파일: player.py 프로젝트: Innoviox/Pyrotor
    def scoreAnimation(self, scoreLabel, startX, startY):

        frame = func.Frame(self.root, relief=func.RAISED)
        frame.place(x=startX, y=startY, height=25, width=25)
        label = func.Label(frame,
                           text="+" + str(scoreLabel),
                           bd=1,
                           relief=func.RAISED,
                           height=25,
                           width=25)
        label.pack()

        frame.lift()

        fontsize = 12
        for i in range(1, 15, 1):
            self.player1ScoreLabel.config(height=round(i / 10),
                                          width=round(15 * (i / 10)),
                                          font=("Courier", fontsize + (round(
                                              (i / 10) * 3))))
            self.player1ScoreLabel.place_configure(x=self.scoreX - round(
                (i / 10) * 25),
                                                   y=self.scoreY - round(
                                                       (i / 10) * 25))
            self.player1ScoreLabel.lift()
            self.player1ScoreLabel.update()

        for scoreChange in range(scoreLabel):
            self.player1ScoreLabel.config(
                text="%s's Score: %d" %
                (self.name, self.score + scoreChange + 1))
            self.player1ScoreLabel.update()
            func.sleep(0.05)
        frame.destroy()
        label.destroy()
예제 #4
0
 def chooseBlank(self):
     self.blankWindow.deiconify()
     chooseLabel = func.Label(self.blankWindow, text = "Choose the tile you want your blank to be.")
     chooseLabel.place(x = 400, y = 200, width = 300, height = 100)
     self.choiceWindow = func.Frame(self.blankWindow)
     self.choiceWindow.place(x=400, y=400, width=500, height = 500)
     buttons = []
     row = 1
     column = 1
     for letter in func.ascii_uppercase:
         button = func.Button(self.choiceWindow, text = letter,
                         command = lambda letter=letter: self.setBlank(letter), \
                         height = 1, width = 1)
         buttons.append(button)
         buttons[-1].place(x = row * 30, y = column * 30)
         column += 1
         if column % 6 == 0:
             column = 1
             row += 1
예제 #5
0
파일: player.py 프로젝트: Innoviox/Pyrotor
    def startTurn(self, otherName, otherScore):
        try:
            self.oldroot.destroy()
        except AttributeError:
            pass
        self.drawTiles()
        self.switchTurn = 0
        self.dwlgen = 0
        self.root.deiconify()
        self.root.title("%s's Turn" % self.name)
        self.root.resizable(0, 0)
        self.root.geometry("%dx%d%+d%+d" % (675, 700, 0, 0))
        self.root.config(bg=func.generateRandomColor())
        #        self.root.config(
        self.rackFrame = func.Frame(self.root, bd=1, relief=func.RAISED)
        self.rackFrame.place(x=self.x, y=self.y + 25, width=300, height=50)

        self.getMovables(self.x + 50, self.y + 25)
        for movable in self.movables:
            movable.board = self.board

        self.coverUp = func.Button(self.root,
                                   text="Click to see tiles",
                                   command=self.showTiles)
        self.coverUp.place(x=self.x, y=self.y + 25, width=300, height=50)
        self.coverUp.lift()

        self.rackFrame.lower()
        self.movables[-1].getBoard()

        self.placeButtons()

        self.screenHeight = self.root.winfo_screenheight()
        self.screenWidth = self.root.winfo_screenwidth()

        self.getScoreBoard(otherName, otherScore)

        self.root.mainloop()
예제 #6
0
    def getFrame(self, size):
        """Gets a frame of size {size} (normally 31) with text {self.text + subscirpt of score}"""
     
        #self.frame.pack()
        if mpl_in == 1:
            #self.frame.config(bd=0)
            overarch = Subscript(self.rackFrame, self.text, self.x, self.y)
            self.label = overarch.label
            self.frame = overarch.frame
            #print(self.x, self.y)
            #self.label.place_configure(x=self.x, y=self.y)
            self.label.bind('<ButtonPress-1>', self.startMoveWindow)
            self.label.bind('<B1-Motion>', self.MoveWindow)
            self.label.bind('<ButtonRelease-1>', self.checkForReturn)
            
            self.frame.bind('<ButtonPress-1>', self.startMoveWindow)
            self.frame.bind('<B1-Motion>', self.MoveWindow)
            self.frame.bind('ButtonRelease-1>', self.checkForReturn)

        else:
            self.frame = func.Frame(self.rackFrame, bd=1, relief=func.SUNKEN)
            self.frame.place(x=self.x, y=self.y, width=size, height=size)   
            self.label = func.Label(self.frame, bd=1, relief=func.RAISED, \
                               text=self.text+self.getSubscript(self.scores[self.text.lower()]),  #Puts the points for the letter on the label\
                               height=size, width=size, bg="yellow")
            self.label.pack(fill=func.X, padx=1, pady=1)

            self.label.bind('<ButtonPress-1>', self.startMoveWindow)
            self.label.bind('<B1-Motion>', self.MoveWindow)
            self.label.bind('<ButtonRelease-1>', self.checkForReturn)
            
            self.frame.bind('<ButtonPress-1>', self.startMoveWindow)
            self.frame.bind('<B1-Motion>', self.MoveWindow)
            self.frame.bind('ButtonRelease-1>', self.checkForReturn)
        
        self.frame.lift()