Question

PYTHON (Basic GUI Programming Using Tkinter):

(Draw an arrow line)

Write a program that randomly draws an arrow line when the Draw a Random Arrow Line button is clicked, as shown in Figure:

㊥ Random an Arrow Line Draw a Random Arrow Line

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

Explanation::

  • Code in PYTHON is given below
  • Screenshots of the Code is also provided
  • Screenshots of the OUTPUT are given at the end of the code


Code in PYTHON::

from tkinter import *
import tkinter as tk
import random

window = Tk()
window.geometry("500x500")
window.title("Random an Arrow Line")
def drawArrow():
    canvas = tk.Canvas(window, width=500, height=500)
    canvas.pack()
    xy=[]
    for i in range(4):
        xy.append(random.randint(0,501))
    canvas.create_line(xy[0], xy[1], xy[2], xy[3], arrow=tk.LAST)
    button()


def button():
    B = Button(window, text = "Draw a Random Arrow Line", command = drawArrow)
    B.place(x = 150,y = 476)
button()
window.mainloop()

Screenshot of the CODE:

1 from tkinter import* 2 import tkinter as tk 3 import random 4 5 window Tk) window.geometry(500x500 7 window.title(Random

OUTPUT::
TEST CASE 1:

tk Draw a Random Arrow Line

TEST CASE 2:

Random an Arrow Line Draw a Random Arrow Line


Please provide the feedback!!

Thank You!!

Add a comment
Know the answer?
Add Answer to:
PYTHON (Basic GUI Programming Using Tkinter): (Draw an arrow line) Write a program that randomly draws...
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
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
Active Questions
ADVERTISEMENT