Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now
Answered Same Day Jul 28, 2021


Lalit answered on Aug 06 2021
128 Votes
from tkinter import *
from tkinter import font
class Info(Frame):
"""Constructs the canvas and sets the main default start page of the game"""
def __init__(self, master=None):
self.configure(width=410, height=100)
fontstyle = font.Font(self, size=20, family='Arial')
self.t = Label(self, text="Turn Yellow", font=fontstyle)
self.t.grid(sticky=NSEW, pady=20)
class Piece(object):
def __init__(self, x, y, circlepiece, color="black", bg="red"):
"""Function that creates the circle piece"""
self.circlepiece = circlepiece
self.x = x
self.y = y
self.color = colo
self.tour = 1
self.r = 30
self.Piece = self.circlepiece.create_oval(self.x+10,self.y+10,self.x+60,self.y+60,fill=color,outline="blue")
def changecolor(self, color):
"""Function that allows the piece to switch color"""
self.circlepiece.itemconfigure(self.Piece, fill=color)
self.color = colo
class App(Canvas):
def __init__(self, master=None): #Using master=none by default as this class is a subclass to tk.Frame
self.configure(width=410, height=400, bg="blue")
self.player = 1
self.color = "yellow"
self.p = [] = True
for i in range(0, 340, 67):
list_range = []
for j in range(0, 340, 67):
list_range.append(Piece(j, i ,self))
self.bind("", self.switching_colors)
def switching_colors(self, event):
"""Function to switch color after every click"""
col = int(event.x/72)
stack = 0
while stack < len(self.p):
if self.p[0][col].color == "red" or...

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here