Answered Same DayJul 28, 2021

Answer To: PFB

Lalit answered on Aug 06 2021
147 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):
Frame.__init__(self)
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 = color
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 = color
class App(Canvas):
def __init__(self, master=None): #Using master=none by default as this class is a subclass to tk.Frame
Canvas.__init__(self)
self.configure(width=410, height=400, bg="blue")
self.player = 1
self.color = "yellow"
self.p = []
self.place = 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.p.append(list_range)
self.bind("", self.switching_colors)
def switching_colors(self, event):
"""Function to switch color after every click"""
if self.place:
col = int(event.x/72)
stack = 0
while stack < len(self.p):
if self.p[0][col].color == "red" or...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here