Question

8. Assume that in a program, the following statement creates a Canvas widget and a it to the self.canvas variable: self.canva

python
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution (a)-->

import tkinter
class ShapeExample:
def __init__(self):
self.main_window = tkinter.Tk()
self.canvas = tkinter.Canvas(self.main_window,width=200, height=200)
self.canvas.create_line(0,0,200,200,width="3")
  
self.canvas.pack()
tkinter.mainloop()
shape = ShapeExample()

#Screen shot

import tkinter class ShapeExample: def init__(self): self.main_window-tkinter.Tk) self.canvas-tkinter.Canvas(self.main_window

#output

tk

Solution (b):-->

import tkinter
class ShapeExample:
def __init__(self):
self.main_window = tkinter.Tk()
self.canvas = tkinter.Canvas(self.main_window,width=200, height=200)
self.canvas.create_rectangle(50,50, 100,100,fill="black",outline="red")
self.canvas.pack()
tkinter.mainloop()
shape = ShapeExample()

//Screen shot

import tkinter Eclass ShapeExample: 申 def-init-(self): self.main-window tkinter.Tk() self.canvas-tkinter.Canvas (self.main_wi

#output

tk

Solution (c)-->

import tkinter
class ShapeExample:
def __init__(self):
self.main_window = tkinter.Tk()
self.canvas = tkinter.Canvas(self.main_window,width=200, height=200)
x0 = 100-50
y0 = 100- 50
x1 = 100+50
y1 = 100+50
self.canvas.create_oval(x0,y0,x1,y1,fill= "green")
self.canvas.pack()
tkinter.mainloop()
shape = ShapeExample()

#Screen Shot

import tkinter Eclass ShapeExample: def init__(self): self.main-window tkinter.Tk() self . canvas tkinter.canvas(self.main-wi

#output

tk

Solution (d):-->

import tkinter
class ShapeExample:
def __init__(self):
self.main_window = tkinter.Tk()
self.canvas = tkinter.Canvas(self.main_window,width=200, height=200)
self.canvas.create_rectangle(20,20,180,180)
self.canvas.create_arc(20,20,180,180,fill="green", outline="blue",start=0,extent=90)
self.canvas.pack()
tkinter.mainloop()
shape = ShapeExample()

#screen shots

import tkinter Eclass ShapeExample: 申 def-init-(self): self.main_window-tkinter.Tk) self.canvas-tkinter.Canvas(self.main_wind

#output

tk

#if you need any help regarding this solution ............ please leave a comment .......... thanks

Add a comment
Know the answer?
Add Answer to:
python 8. Assume that in a program, the following statement creates a Canvas widget and a it to the self.canvas variable: self.canvas tkinter.Canvas(self.main_window, width-200, height-200) Wri...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Growing Plant program following guidelines Drawing Canvas Code: import java.awt.Canvas; import java.awt.*; import java.awt.geom.*; /** *...

    Growing Plant program following guidelines Drawing Canvas Code: import java.awt.Canvas; import java.awt.*; import java.awt.geom.*; /** * */ /** */ public class DrawingCanvas extends Canvas { protected String drawString; protected double angleIncrement; DrawingCanvas() { this.setPreferredSize(new Dimension(400, 400)); } public void setDrawString(String s) { drawString = s; } public void setAngleIncrement(double d) { angleIncrement = Math.PI * d/ 180.0; } /** * Paint routine for our canvas. The upper Left hand corner * is 0, 0 and the lower right hand corner...

  • Game Description: Most of you have played a very interesting game “Snake” on your old Nokia...

    Game Description: Most of you have played a very interesting game “Snake” on your old Nokia phones (Black & White). Now it is your time to create it with more interesting colors and features. When the game is started a snake is controlled by up, down, left and right keys to eat food which appears on random locations. By eating food snake’s length increases one unit and player’s score increases by 5 points. Food disappears after 15 seconds and appears...

  • The following guidelines outline the basic template for a robot vacuum cleaner game. The game must...

    The following guidelines outline the basic template for a robot vacuum cleaner game. The game must be implemented in c programming language. It mimics a robotic vacuum cleaner. The code must only use the following libraries: #include <math.h> #include <stdlib.h> #include <string.h> #include <limits.h> and any .graphics and .timers libraries. The guidelines are outlined as follows: Terminal Set-up: you may assume that the terminal will be quite large, for example, on the order of 150×50, or more. Status Display: The...

  • The following guidelines outline the basic template for a robot vacuum cleaner game. The game must be implemented in c programming language. It mimics a robotic vacuum cleaner. The code must only use...

    The following guidelines outline the basic template for a robot vacuum cleaner game. The game must be implemented in c programming language. It mimics a robotic vacuum cleaner. The code must only use the following libraries: #include <math.h> #include <stdlib.h> #include <string.h> #include <limits.h> and any .graphics and .timers libraries. The guidelines are outlined as follows: Terminal Set-up: you may assume that the terminal will be quite large, for example, on the order of 150×50, or more. Status Display: The...

  • I need a basic program in C to modify my program with the following instructions: Create...

    I need a basic program in C to modify my program with the following instructions: Create a program in C that will: Add an option 4 to your menu for "Play Bingo" -read in a bingo call (e,g, B6, I17, G57, G65) -checks to see if the bingo call read in is valid (i.e., G65 is not valid) -marks all the boards that have the bingo call -checks to see if there is a winner, for our purposes winning means...

  • You need not run Python programs on a computer in solving the following problems. Place your...

    You need not run Python programs on a computer in solving the following problems. Place your answers into separate "text" files using the names indicated on each problem. Please create your text files using the same text editor that you use for your .py files. Answer submitted in another file format such as .doc, .pages, .rtf, or.pdf will lose least one point per problem! [1] 3 points Use file math.txt What is the precise output from the following code? bar...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT