Ejemplo n.º 1
0
def showBoard():
   
    global board, tileButtonDict, tileList, gameBoard, difficulty
    createGame(difficulty)
    

    rowLabelCount = 0
    columnLabelCount = 0

    if len(tileList) > 256:
        
        rowLength = int(len(tileList)/16)

    else:

        rowLength = math.sqrt(len(tileList)) 
        
    rowCount = 0
    columnCount = 0
  
    for tile in tileList:

        if not tile.isMined:

            surroundingMines = Text(board, text=str(tile.surroundingMineCount), grid=[columnCount,rowCount])
            surroundingMines.height = 2
            surroundingMines.width = 3
            textDict[tile.label] = surroundingMines

        else:

            picture = Picture(board, image='bomb2.jpg', grid=[columnCount,rowCount])   
            picture.height = 25
            picture.width = 15
            mineDict[tile.label] = picture
        
        tileButton = PushButton(board, command=playGame, image = 'blank.jpg' , args=[tile], grid=[columnCount,rowCount], text='')#str(tile)#.isMined))#str(tile))
        tileButton.bg = 'gray60'
        #print ('button grid', tileButton.grid)
        tileButton.when_right_button_pressed = markTile
        tileButton.width = 32
        tileButton.height = 37
        tileButtonDict[tile.label] = tileButton
        columnCount += 1
            
        if columnCount == rowLength:

            rowCount += 1
            columnCount = 0
Ejemplo n.º 2
0
                button.widget.text = str(button_num + 1)

            else: 
                button.widget.text = ''

        else:

            button.widget.text = '1'

def lock_button(button):

    print('is locked?', button_lock_dict[button.widget])

    if button_lock_dict[button.widget] == True:
        print('im in')
        button.widget.enable()
        button_lock_dict[button.widget] = False

    else:

        button.widget.disable()
        button_lock_dict[button.widget] = True

begButton = PushButton(game_board, width=12, text='')#, grid=[0,0])
begButton.when_left_button_pressed = incriment_number
begButton.when_right_button_pressed = lock_button
begButton.bg = 'gray80'
button_lock_dict[begButton] = False

app.display()