Skip to content

Instantly share code, notes, and snippets.

@CoutinhoElias
Last active May 2, 2020 00:24
Show Gist options
  • Save CoutinhoElias/cff146a074e9aaa725c97bd468062ed1 to your computer and use it in GitHub Desktop.
Save CoutinhoElias/cff146a074e9aaa725c97bd468062ed1 to your computer and use it in GitHub Desktop.
cartas
import PySimpleGUI as sg
naipes = ['C', 'E', 'O', 'P']
games_in_table = []
cards_in_hands = [(3, 'O'), (3, 'C'), (1, 'P'), (8, 'E'),
(10, 'E'), (2, 'C'), (6, 'C'), (13, 'C'),
(4, 'P'), (9, 'P'), (7, 'P'), (13, 'E'),
(10, 'P'), (9, 'C'), (3, 'E')]
cards_in_trash = [(10, 'P'), (9, 'C'), (3, 'E')]
for j in naipes:
games_in_table.append([cards_in_hands[i] for i in range(len(cards_in_hands)) if cards_in_hands[i][1] == j])
games_in_table.append([(3, 'O'), (4, 'O'), (5, 'O')])
MAX_ROWS = len(games_in_table)
layout = [[sg.Text('---------------------------------------------------- CARTAS NO LIXO ----------------------------------------------------'), sg.Text('', key='_OUTPUT_')],
[sg.Button('Show', size=(4, 2), pad=(0,0))]]
layout += [[sg.Text('---------------------------------------------------- JOGOS NA MESA ----------------------------------------------------'), sg.Text('', key='_OUTPUT_')],]
layout += [[sg.Button(games_in_table[i][j], size=(4, 2), key=(i,j), pad=(0,0)) for j in range(len(games_in_table[i]))] for i in range(MAX_ROWS)]
layout += [
[sg.Text('---------------------------------------------------- CARTAS NA MÃO ----------------------------------------------------'), sg.Text('', key='_OUTPUT_')],
[sg.Button(cards_in_hands[i], size=(4, 2), pad=(0,0)) for i in range(len(cards_in_hands)) if cards_in_hands[i][1] == 'C'],
[sg.Button(cards_in_hands[i], size=(4, 2), pad=(0,0)) for i in range(len(cards_in_hands)) if cards_in_hands[i][1] == 'E'],
[sg.Button(cards_in_hands[i], size=(4, 2), pad=(0,0)) for i in range(len(cards_in_hands)) if cards_in_hands[i][1] == 'O'],
[sg.Button(cards_in_hands[i], size=(4, 2), pad=(0,0)) for i in range(len(cards_in_hands)) if cards_in_hands[i][1] == 'P'],
]
'''
layout.append([sg.Text('---------------------------------------------------- CARTAS NO LIXO ----------------------------------------------------'), sg.Text('', key='_OUTPUT_')],)
layout.append([sg.Button(cards_in_hands[i], size=(4, 2), pad=(0,0)) for i in range(len(cards_in_hands)) if cards_in_hands[i][1] == 'C'],)
'''
window = sg.Window('Jogando Biriba.', layout, size=(1165,600))
while True:
event, values = window.read()
print(event)
if event in (None, 'Exit'):
break
# window[(row, col)].update('New text') # To change a button's text, use this pattern
# For this example, change the text of the button to the board's value and turn color black
#window[event].update(board[event[0]][event[1]], button_color=('white','black'))
window.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment