pythonfinal
pythonfinal
Project Report On
“Basic Drawing Application”
CERTIFICATE
This is to certify that Ms. Masiha Silviya Santosh Roll No. 32 of 6th Semester of diploma
in Computer engineering has completed the term work satisfactorily in Programming
with python ( ) For academic year 2024-2025 as prescribed in the curriculum.
ACKNOWLEDGMENT
The success and final outcomes of this project required substantial guidance and assistance from
many individuals, and I feel privileged to have received their support throughout the process. My
achievements are a direct result of their supervision, and I want to express my gratitude.
I am especially thankful to my project guide, Mr. A.B. Gaikwad sir, and the Head of the Computer
Department. Their keen interest in my work and consistent guidance were instrumental in
navigating the challenges I faced. I greatly appreciate their valuable insights and unwavering
support, which were crucial to the successful completion of my project.
I would also like to thanks to our principal Mr. Andhare sir who gave me the golden opportunity
to do thiswonderfulprojectthathelped meindoing alot of research and I came to know about so
many new things. Lastly, I thank the Almighty, my parents, and my classmates for their constant
encouragement, without which this assignment would not have been possible.
Your Sincerely,
Masiha Silviya
INDEX
Content
1. Rationale.........................................................................................5
2. Aim of the micro project.................................................................5
3. Course outcomes addressed............................................................5
4. Literature review
1. Steps For Project Implementation..................6
2. Program……………………………………....8
3. Explanation of Program…………………....9
5. Actual Methodology………………………………………….…11
6. Actual Resources required…………………………....................13
7. Output of the Project ................................................................ 14
8. Skill developed/learning out of this micro project………….....15
9. Application of the Project..........................................................16
10. Conclusion ................................................................................ 17
11. Future Scope ............................................................................. 17
12. References ................................................................................ 18
The drawing application is designed for simplicity and ease of use. Users can draw lines, choose
colors, and clear the canvas with minimal effort. The interface is intuitive, allowing real-time
interaction through mouse clicks. For developers, the app’s code is modular, separating drawing
functionality from control elements like buttons. This makes the code cleaner and easier to
maintain. The design is flexible, allowing for easy extension by adding new shapes through a
simple interface, making future updates straightforward.
The aim of this Drawing Application project is to develop an intuitive and user-friendly tool that
enables users to create and manage their drawings effortlessly. The application allows users to
draw lines on a canvas, select colours, and clear their work with ease. By offering simple mouse
interactions and minimal controls, the system ensures that users can focus on the creative process
without being distracted by complex features or settings. This project benefits users by providing
a seamless and enjoyable drawing experience, while also offering flexibility for future
improvements or feature additions.
5
GOVERNMENT POLYTECHNIC DHARASHIV
The Drawing Application focuses on simplicity, allowing users to draw, select colors, and clear
the canvas with ease, prioritizing creativity over complexity. For developers, its modular design
ensures maintainability and scalability. Components like the drawing and control panels, along
with the Shape interface, make adding new features straightforward. The efficient use of the
Graphics class ensures smooth, real-time rendering, making the app both user-friendly and
adaptable for future updates.
6
GOVERNMENT POLYTECHNIC DHARASHIV
Setup:
Open Notepad++, create a new file, and paste the Python code.
Save the file as drawing_application.py in your desired project folder.
Open Command Prompt or Terminal and navigate to the folder where the .py file is
saved.
Run the Python script using python drawing_application.py or python3
drawing_application.py.
PROGRAM
Basic Drawing Application
import tkinter as tk
from tkinter import colorchooser
class DrawingApplication(tk.Tk):
def _init_(self):
super()._init_()
self.title("Simple Drawing Application")
self.geometry("800x600")
self.current_color = "black"
self.shapes = []
self.canvas = tk.Canvas(self, bg="white", width=800, height=550)
self.canvas.pack()
control_panel = tk.Frame(self)
control_panel.pack(side=tk.BOTTOM, fill=tk.X)
clear_button = tk.Button(control_panel, text="Clear", command=self.clear)
clear_button.pack(side=tk.LEFT)
color_button = tk.Button(control_panel, text="Choose Color",
command=self.choose_color)
color_button.pack(side=tk.LEFT)
self.start_point = None
self.canvas.bind("<ButtonPress-1>", self.on_mouse_press)
self.canvas.bind("<B1-Motion>", self.on_mouse_drag)
self.canvas.bind("<ButtonRelease-1>", self.on_mouse_release)
self.lines = []
8
GOVERNMENT POLYTECHNIC DHARASHIV
def draw_shapes(self):
self.canvas.delete("all")
for line in self.lines:
for i in range(1, len(line)):
self.canvas.create_line(line[i-1], line[i], fill=self.current_color, width=2)
def clear(self):
self.lines.clear()
self.canvas.delete("all")
def choose_color(self):
color = colorchooser.askcolor(color=self.current_color)[1]
if color:
self.current_color = color
if _name_ == "_main_":
app = DrawingApplication()
app.mainloop()
9
GOVERNMENT POLYTECHNIC DHARASHIV
Explanation of Program
Control Panel:
Choose Color Button: Allows the user to select a drawing color using a color picker dialog
(colorchooser.askcolor()).
Drawing Panel (DrawPanel): This is the area where the actual drawing happens.
Mouse Events:
The panel listens for mouse press and release events. When the mouse is pressed, the starting
point of the drawing is captured. When the mouse is released, the endpoint is recorded, and a
new line is drawn between the two points.
Clear Method:
The clear() method removes all shapes from the list, essentially resetting the canvas to a
blank state.
Shape Interface:
This interface defines a contract for drawable objects. All shapes (e.g., lines) must
implement the draw() method. The interface makes it easy to add new shapes in the future
by simply creating new classes that implement this method (e.g., adding circles or
rectangles).
Line Class:
The Line class represents a line drawn between two points with a specified color. It
implements the Shape interface and the draw() method, using the create_line() function to
render the line on the canvas.
10
GOVERNMENT POLYTECHNIC DHARASHIV
Main Method:
The main() method initializes the application by calling app.mainloop() to start the event loop
for the GUI. It ensures that the GUI operates smoothly and is thread-safe by using the main
event dispatch loop, which is essential in GUI applications.
Key Features:
Drawing Lines: Users can click and drag the mouse to draw lines on the canvas.
Color Selection: The color of the lines can be changed through a color picker dialog.
Clear Canvas: Users can click the "Clear" button to remove all drawn lines and reset the
canvas.
Real-time Drawing: The application provides immediate feedback as users draw lines,
ensuring a dynamic and interactive experience.
Design Considerations:
Extensibility: The use of the Shape interface allows the addition of new shapes (e.g.,
rectangles, circles) without changing the core application logic. This provides flexibility to
enhance the app with new drawing tools.
User-Friendly: The application is designed to be simple and intuitive, with basic mouse
interactions and easy-to-understand buttons for color selection and canvas clearing.
11
GOVERNMENT POLYTECHNIC DHARASHIV
3. Implementation:
Built the application using Java programming
12
GOVERNMENT POLYTECHNIC DHARASHIV
13
GOVERNMENT POLYTECHNIC DHARASHIV
14
GOVERNMENT POLYTECHNIC DHARASHIV
9.0 Conclusion:
The Simple Drawing Application demonstrates the effective use of Python’s Tkinter library to
build an interactive and user-friendly drawing tool. Its clean interface and event-driven design
allow users to draw freely and select colors with ease. The object-oriented structure ensures
the code is organized and maintainable, providing a solid foundation for future improvements
such as shape tools, file saving, and enhanced drawing capabilities. This project highlights the
potential of Python for creating practical GUI-based applications.
Support for saving and exporting drawings in image formats like PNG or JPEG.
Enhancement of drawing options with advanced color pickers, brush sizes, and gradients.
15
GOVERNMENT POLYTECHNIC DHARASHIV
11.0 References:
www.geeksforgeeks.com
www.wikipedia.com
www.stackoverflow.com
16