Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I keep getting an error on this saying something about displayRect not an attribute. I think there is probably some issues with the indentations. import

I keep getting an error on this saying something about displayRect not an attribute. I think there is probably some issues with the indentations.

import tkinter from tkinter import *

class drawRectangleOval():

def __init__(self): window = Tk() window.title("Geometric figures") self.canvas = Canvas(window, width = 200, height = 100, bg = "white") self.canvas.pack() frame = Frame(window) frame.pack() self.v1 = StringVar() rbRectangle = Radiobutton(frame, text = "Rectangle", variable = self.v1, value = 'R', command = self.displayRect) rbOval = Radiobutton(frame, text = "Oval", variable = self.v1, value = 'O', command = self.displayOval) self.v2 = StringVar() cbFilled = Checkbutton(frame, text = "Filled", variable = self.v2, command = self.fillShape) rbRectangle.grid(row=1, column=1) rbOval.grid(row=1, column=2) cbFilled.grid(row=1, column=3) window.mainloop() def displayRect(self): self.canvas.delete("rect","oval") self.canvas.create_rectangle(10,10,190,90,tags = "rect") self.v2.set(0) def displayOval(self): self.canvas.delete("rect", "oval") self.canvas.create_oval(10, 10, 190, 90, tags = "oval") self.v2.set(0) def fillShape(self): self.canvas.delete("rect", "oval") if self.v1.get() == 'R': self.canvas.create_rectangle(10,10,190,90,fill = "black", tags = "rect") else: self.canvas.create_oval(10,10,190,90,fill = "black", tags = "oval") drawRectangleOval()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

Students also viewed these Databases questions