๐Ÿ
B.TECH I YEAR โ€ข II SEMESTER โ€ข R25

Python Programming - Lab Manual

Python Programming Laboratory โ€ข Program Solution

๐Ÿ“˜ R25 Regulation ๐ŸŽ“ I Year ๐Ÿ“š II Semester ๐Ÿ Python Programming ๐Ÿงช Lab Program
Selected Program

draw_point

โ† All Python Programs

Aim:

☛   Write a function called draw_point that takes a Canvas and a Point as arguments and draws a representation of the Point on the Canvas.

Solution :


PROGRAM: (draw_point.py)

 
from tkinter import *
# Create an instance of tkinter frame or window
win = Tk ()
# Create Title
win.title(" Draw - point ")
# Set the size of the window
win.geometry("700x350")
# Define a function to draw the line between two points
def draw_point(event):
	x1= event.x
	y1= event.y
	x2= event.x
	y2= event.y
	# Draw an oval in the given co-ordinates
	canvas.create_oval(x1,y1,x2,y2,fill="black",width = 20 )
# Create a canvas widget
canvas = Canvas(win,width = 650,height = 300,background = "white")
canvas.grid(row = 0 ,column = 0)
canvas.bind('<Button-1>',draw_point)
click_num = 0
win.mainloop()

OUTPUT:


image

๐Ÿ’ป Run This Python Program

draw_point
The selected Python program is loaded automatically into the editor. Edit the program, provide input if required and click Run.

The compiler is embedded using OneCompiler. Your Python program runs inside the embedded Python environment; Study Glance does not execute Python code directly on your web server.
โ† Back to Python Lab Programs ๐Ÿ“š All Lab Manuals