TrabalhosGratuitos.com - Trabalhos, Monografias, Artigos, Exames, Resumos de livros, Dissertações
Pesquisar

O Jogo Simples de Cores - Python

Por:   •  2/6/2020  •  Abstract  •  351 Palavras (2 Páginas)  •  291 Visualizações

Página 1 de 2

from tkinter import *

import random

def novo():

global x, y

x = random.choice(listacores)

y = random.choice(listacores)

texto_topo.configure(text = (("A cor da forma abaixo, em inglês, é ")+("'")+(x)+("'.")))

c.configure(background=y)

def fecharf():

jogo.destroy()

def mudarframe(frame):

frame.tkraise()

def botaoverdadeirof():

if x == y:

mudarframe(vitória)

else:

mudarframe(derrota)

def botaofalsof():

if x != y:

mudarframe(vitória)

else:

mudarframe(derrota)

jogo = Tk()

jogo.geometry("500x350")

# FRAMES

janela = Frame(jogo, width = "560", height = "460")

janela.grid(row=0, column=0)

vitória = Frame(jogo, width = "560", height = "460", background = "White")

vitória.grid(row=0, column=0)

derrota = Frame(jogo, width = "560", height = "460", background = "White")

derrota.grid(row=0, column=0)

# WIDGETS VITÓRIA

labelframe = Label(vitória, text = "Você ganhou!", font = "Calibri 22", foreground = "Green", background = "White")

labelframe.pack()

botaojogardenovo = Button(vitória, text = "Jogar novamente", width = 20, font = "Calibri 18", command=lambda:[mudarframe(janela), novo()])

botaojogardenovo.pack()

botaofechar = Button(vitória, text = "Fechar jogo", width = 20, font = "Calibri 18", background = "Red", foreground = "White", command=fecharf)

botaofechar.pack()

# WIDGETS DERROTA

labelframe = Label(derrota, text = "Você perdeu", font = "Calibri 22", foreground = "Red", background = "White")

labelframe.pack()

botaojogardenovo = Button(derrota, text = "Jogar novamente", font = "Calibri 18", width = 20, command=lambda:[mudarframe(janela),

...

Baixar como (para membros premium)  txt (2.8 Kb)   pdf (37.8 Kb)   docx (8.4 Kb)  
Continuar por mais 1 página »
Disponível apenas no TrabalhosGratuitos.com