Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- from random import *
- turns=10
- points=0
- def onclick():
- global turns,points
- iscat=randint(1,11)
- btn.configure(state="disabled")
- if iscat==1:
- btn.configure(background="blue")
- statlabel.configure(text="You found a cat!")
- points=points+1
- else:
- btn.configure(bg="red")
- statlabel.configure(text="It's empty! Hurry, or all the cats will die!")
- turns=turns-1
- root=Tk()
- root.title("Catsweeper")
- root.configure(background="black")
- frame=Frame(root)
- frame.configure(bg="black")
- Grid.rowconfigure(root, 0, weight=1)
- Grid.columnconfigure(root, 0, weight=1)
- frame.grid(row=0, column=0)
- grid=Frame(frame)
- grid.grid(column=0, row=7, columnspan=2)
- Grid.rowconfigure(frame, 7, weight=1)
- Grid.columnconfigure(frame, 0, weight=1)
- chosenx=int(input("How many rows? "))
- choseny=int(input("How many columns? "))
- for x in range(1,chosenx+1):
- for y in range(1, choseny+1):
- btn=Button(frame, command=onclick, state = "normal")
- btn.grid(column=x, row=y)
- statlabel=Label(frame, text="", background="red", fg="white")
- statlabel.grid(column=choseny+1)
- if turns==0:
- statlabel.configure(text="GAME OVER")
- btn.configure(state="disabled")
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement