0% found this document useful (0 votes)
16 views

Itr Python

Uploaded by

a7947375
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Itr Python

Uploaded by

a7947375
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 38

An

Industrial Training Report


on

“PYTHON”
Submitted in partial fulfilment for the award of degree of

Bachelor of Technology
in
Department of Electronics & Communication Engineering

2022-2023

Submitted to: Submitted by :

Mr. Abhinandan Jain Prashansha Khandelwal


Assistant Professor 20ESKEC091
Department of ECE B-TECH – V TH SEM
SKIT M& G, Jaipur ECE B

Mr. Lalit Kumar Lata


Assistant Professor
Department of ECE
SKIT M& G, Jaipur

Department of Electronics and Communication Engineering


Swami Keshvanand Institute of Technology, Management & Gramothan, Jaipur
Rajasthan Technical University,Kota

1 | Page
ACKNOWLEDGEMENT

There are always some key personalities whose roles are vital for the successful
completion of any work. However, it would not have been possible to complete this work
without the kind support and help of many individuals and organization. I would like to
extend my sincere thanks to all of them.

I am highly indebted to my mentors Mr. Lalit Kumar Lata, Assistant Professor & Mr.
Abhinandan Jain, Assistant Professor for their guidance and constant supervision as
well as for providing necessary information regarding the industrial training seminar &
also for their support in completing the Industrial Training. I would like to thank
Mr.Lalit Kumar Lata, Assistant Professor, Department of Electronics and
Communication, SKIT M & G, Jaipur for their kind support and guidance to complete
my Industrial Training Successfully. They helped us throughout the training. Their
excellent guidance has been instrumental in making this training a success.

I would like to thank Prof. (Dr.) Mukesh Arora, Professor & Head, Department of
Electronics and communication, SKIT M & G, Jaipur for providing me the opportunity to
do training in consistent direction and the adequate means and support to pursue this
training.

Finally, earnest and sincere thanks to all the Faculty members of Electronics and
Communication Department, SKIT M & G, Jaipur for their direct and indirect support in
the completion of this industrial training.

Last but not least, we sincerely express our deepest gratitude to our families for their
wholehearted support and encouragement to us to take up this course. In addition, a very
special thanks to our colleagues and friends for their support.

Prashansha Khandelwal (20ESKEC091)

2 | Page
TABLE OF CONTENTS

Acknowledgement ii
Table of Content iii
Certificate iv

Chapter 1: Python
1.1 Introduction 5
1.2 Object oriented programming language 5
1.3 Scripting language 6
1.4 History of python 6
Chapter 2: Data Types
2.1 What is data types 7
2.2 Variables 7
2.3 Strings 8
2.4 Creating Strings 8
2.5 Python operators 8

3 | Page
Chapter 3: Tuples And Lists
3.1 Tuples 10
3.2 Accessing values in tuples 10
3.3 List 11
3.4 Accessing values in lists 11
Chapter 4: Loops
4.1 Loops 13
4.2 Conditional statements 14
4.3 Functions 15
Chapter 5: Project
5.1 Introduction 17
5.2 Code 18
5.3 Result 34
Chapter 6: Conclusion And References 35

4 | Page
CHAPTER 1: PYTHON

5 | Page
INTRODUCTION TO PYTHON :-
Python is a widely used high-level, general-purpose, interpreted, dynamic
programming language. Its design philosophy emphasizes code
readability, and its syntax allows programmers to express concepts in
fewer lines of code than would be possible in languages such as C++ or
Java. The language provides constructs intended to enable clear programs
on both a small and large scale. Python supports multiple programming
paradigms, including object-oriented, imperative and functional
programming or procedural styles. It features a dynamic type system and
automatic memory management and has a large and comprehensive
standard library. Python interpreters are available for installation on many
operating systems, allowing Python code execution on a wide variety of
systems.

OBJECT ORIENTED PROGRAMMING LANGUAGE :


Object-oriented programming (OOP) is a programming paradigm based
on the concept of "objects", which may contain data, in the form of fields,
often known as attributes; and code, in the form of procedures, often
known as methods. A distinguishing feature of objects is that an object's
procedures can access and often modify the data fields of the object with
which they are associated (objects have a notion of "this" or "self").

In OO programming, computer programs are designed by making them


out of objects that interact with one another. There is significant diversity
in object-oriented programming, but most popular languages are class-
based, meaning that objects are instances of classes, which typically also
determines their type.

SCRIPTING LANGUAGE:

6 | Page
A scripting or script language is a programming language that supports
scripts, programs written for a special run-time environment that automate
the execution of tasks that could alternatively be executed one-by-one by
a human operator. Scripting languages are often interpreted (rather than
compiled). Primitives are usually the elementary tasks or API calls, and
the language allows them to be combined into more complex programs.
Environments that can be automated through scripting include software
applications, web pages within a web browser, the shells of operating
systems (OS), embedded systems, as well as numerous games.
A scripting language can be viewed as a domain-specific language for a
particular environment; in the case of scripting an application, this is also
known as an extension language. Scripting languages are also sometimes
referred to as very high-level programming languages, as they operate at a
high level of abstraction, or
as control languages.

HISTORY OF PYTHON:

Python was conceived in the late 1980s, and its implementation was
started in December 1989 by Guido van Rossum at CWI in the
Netherlands as a successor to the ABC language (itself inspired by SETL)
capable of exception handling and interfacing with the Amoeba operating
system. Van Rossum is Python's principal author, and his continuing
central role in deciding the direction of Python is reflected in the title
given to him by the Python community, benevolent dictator for life
(BDFL).

CHAPTER 2: DATA TYPES

7 | Page
WHAT IS DATA TYPES

Data types determine whether an object can do something, or whether it


just would not make sense. Other programming languages often
determine whether an operation makes sense for an object by making sure
the object
can never be stored somewhere where the operation will be performed on
the object (this type system is called static typing). Python does not do
that.
Instead it stores the type of an object with the object, and checks
when the operation is performed whether that operation makes sense for
that object (this is called dynamic typing).

VARIABLES

Variables are nothing but reserved memory locations to store values. This
means that when you create a variable you reserve some space in
memory.
Based on the data type of a variable, the interpreter allocates memory and
decides what can be stored in the reserved memory. Therefore, by
assigning different data types to variables, you can store integers,
decimals or characters in these variables.

Ex:
Counter = 100 # An integer assignment
miles = 1000.0 # A floating point
name = "John" # A string

STRINGS

8 | Page
In programming terms, we usually call text a string. When you think of a
string as a collection of letters, the term makes sense. All the letters,
numbers, and symbols in this book could be a string. For that matter, your
name could be a string, and so could your address.

CREATING STRINGS

In Python, we create a string by putting quotes around text. For example,


we could take our otherwise useless

• "hello" + "world" "helloworld" # concatenation


• "hello"*3 "hellohellohello" # repetition
• "hello"[0] "h" # indexing
• "hello"[-1] "o" # (from end)
• "hello"[1:4] "ell" # slicing
• len("hello") 5 # size
• "hello" < "jello" 1 # comparison
• "e" in "hello" 1 # search

PYTHON OPERATORS

Python Operators in general are used to perform operations on values and


variables. These are standard symbols used for the purpose of logical and
arithmetic operations.

9 | Page
ARITHMATIC OPERATORS:

10 | Page
CHAPTER 3: TUPLES AND LISTS

TUPLES:

Creating a tuple is as simple as putting different comma-separated values.


Optionally you can put these comma-separated values
between parentheses also.

For example −
tup1 = ('physics', 'chemistry', 1997, 2000);
tup2 = (1, 2, 3, 4, 5); tup3 = "a", "b", "c", "d";

ACCESSING VALUES IN TUPLES:

To access values in tuple, use the square brackets for slicing along with
the index or
indices to obtain value available at that index. For example −
tup1 = ('physics', 'chemistry', 1997, 2000);
tup2 = (1, 2, 3, 4, 5, 6, 7 ); print "tup1[0]: ",
tup1[0]
print "tup2[1:5]: ", tup2[1:5]
When The above Code is executed, it produces the following result−
tup1[0]: physics
tup2[1:5]: [2, 3, 4, 5]

11 | Page
LIST

The list is a most versatile datatype available in Python which can be


written as a list of comma-separated values (items) between square
brackets. Important thing about a list is that items in a list need not be of
the same type. Creating a list is as simple as putting
different comma-separated values between square brackets. For example

list1 = ['physics', 'chemistry', 1997, 2000];


list2 = [1, 2, 3, 4, 5 ]; list3 = ["a", "b", "c", "d"];
Similar to string indices, list indices start at 0, and lists can be sliced,
concatenated and so on.

ACCESSING VALUES IN LISTS:

To access values in lists, use the square brackets for slicing along with the
index or indices to obtain value available at that index. For example −

list1 = ['physics', 'chemistry', 1997, 2000];


list2 = [1, 2, 3, 4, 5, 6, 7 ]; print "list1[0]: ",
list1[0]
print "list2[1:5]: ", list2[1:5]

Output:
list1[0]: physics
list2[1:5]: [2, 3, 4, 5]

12 | Page
Update: list = ['physics', 'chemistry', 1997, 2000];
print "Value available at index 2 : "
print list[2]
list[2] = 2001;
print "New value available at index 2 : "
print list[2]

Output:
Value available at index 2: 1997
New value available at index 2: 2001

Delete: list1 = ['physics', 'chemistry', 1997, 2000];


print list1
del list1[2];
print "After deleting value at index 2 : "
print list1 ['physics', 'chemistry', 1997, 2000]

13 | Page
CHAPTER 4: LOOPS

Programming languages provide various control structures that allow for


more complicated execution paths. A loop statement allows us to execute
a statement or group of statements multiple times. The following diagram
illustrates a loop statement –Python programming language provides
following types of loops to handle looping requirements.

Example:

For Loop:
>>> for mynum in [1, 2, 3, 4, 5]:
print "Hello", mynum
Hello
1
Hello
2
Hello
3
Hello
4
Hello
5

14 | Page
While Loop:
>>> count = 0
>>> while (count < 4): print
'The count is:', count count =
count + 1
The count is: 0
The count is: 1
The count is: 2
The count is: 3

Conditional Statements:

Decision making is anticipation of conditions occurring while execution


of the program and specifying actions taken according to the conditions.
Decision structures evaluate multiple expressions which produce TRUE
or FALSE as outcome. You need to determine which action to take and
which statements to execute if outcome is TRUE or FALSE otherwise.

STATEMENTS
Python programming language provides following types of decision making
statements.

Example:

If Statement:
>>> state = “Texas”
>>> if state == “Texas”:
print “TX
TX

15 | Page
If...Else Statement:

>>> if state == “Texas”


print “TX”
else:
print “[inferior state]”

If...Else...If Statement:

>>>if name == “Paige”


print “Hi Paige!”
elif name = = “Walker”:
print “Hi Walker!” else:
print “Imposter!”

FUNCTION

Function blocks begin with the keyword def followed by the function
name and parentheses ( ( ) ).

Any input parameters or arguments should be placed within these


parentheses. You can also define parameters inside these parentheses. The
first statement of a function can be an optional statement -the
documentation string of the function.

The code block within every function starts with a colon (:) and is
indented. The statement return [expression] exits a function, optionally
passing back an expression to the caller. A return statement with no
arguments is the same as return None.

16 | Page
Syntex:

def functionname( parameters ):


"function_docstring"
function_suite
return [expression]

Example:

1.def printme( str ):


"This prints a passed string into this function"
print str
return

2. # Function definition is here


def printme( str ):
"This prints a passed string into this function" print
str
return;

# Now you can call printme function printme("I'm first call to user
defined function!") printme("Again second call to the same function")

17 | Page
CHAPTER 5: Project
Text Editor

Introduction:

Text Editor is a simple application that helps a user to write texts


and save it in a file. It is a basic beginners project but very
interesting to make. So let’s get started.

Project details:

This is very interesting project using python. Here we are going to


create a text editor which will have several options like copy,
paste, save, save as etc. we will try to include every possible option
in it. While creating the project we will be using these modules and
libraries –

1 TKinter Module
2 Filedialouge

18 | Page
CODE

import tkinter as tk
from tkinter import Button, Image, StringVar, Tk, ttk
from tkinter import font,colorchooser,filedialog,messagebox
import os
main_application=tk.Tk()
main_application.geometry('1200x800')
main_application.title('text editor')

########### MAIN MENU ###################


main_menu=tk.Menu()
# file icons import
new_icon=tk.PhotoImage(file='icons/new.png')
open_icon=tk.PhotoImage(file='icons/open.png')
save_icon=tk.PhotoImage(file='icons/save.png')
save_as_icon=tk.PhotoImage(file='icons/save_as.png')
exit_icon=tk.PhotoImage(file='icons/exit.png')

# edit icons
copy_icon=tk.PhotoImage(file='icons/copy.png')
paste_icon=tk.PhotoImage(file='icons/paste.png')

19 | Page
cut_icon=tk.PhotoImage(file='icons/cut.png')
clear_all_icon=tk.PhotoImage(file='icons/clear_all.png')
find_icon=tk.PhotoImage(file='icons/find.png')
# view icons
tool_bar_icon=tk.PhotoImage(file='icons/tool_bar.png')
status_bar_icon=tk.PhotoImage(file='icons/status_bar.png')

# colour theme icons


light_default_icon=tk.PhotoImage(file='icons/light_default.png')
light_plus_icon=tk.PhotoImage(file='icons/light_plus.png')
monokai_icon=tk.PhotoImage(file='icons/monokai.png')
night_blue_icon=tk.PhotoImage(file='icons/night_blue.png')
red_icon=tk.PhotoImage(file='icons/red.png')
dark_icon=tk.PhotoImage(file='icons/dark.png')

file=tk.Menu(main_menu,tearoff=False)
edit=tk.Menu(main_menu,tearoff=False)
view=tk.Menu(main_menu,tearoff=False)
colour_theme=tk.Menu(main_menu,tearoff=False)
theme_choice=tk.StringVar()
color_icons=(light_default_icon,light_plus_icon,red_icon,night_blue_icon,d
ark_icon,monokai_icon)

color_dict={
'Ligth Default' : ('#000000','#ffffff'),

20 | Page
'Ligth Plus' : ('#474747','#e0e0e0'),
'Dark' : ('#c4c4c4','#2d2d2d'),
'Red' : ('#2d2d2d','#ffe8e8'),
'Monokai' : ('#d3b774','#474747'),
'Night Blue' : ('#ededed','#6b9dc2')

}
# for view use cascade
main_menu.add_cascade(label='File',menu=file)
main_menu.add_cascade(label='Edit',menu=edit)
main_menu.add_cascade(label='View',menu=view)
main_menu.add_cascade(label='Colour Theme',menu=colour_theme)

############ TOOLBAAR ###################


tool_bar=ttk.Label(main_application)
tool_bar.pack(side=tk.TOP,fill=tk.X)
# font box
font_tuple=tk.font.families()
font_family=tk.StringVar()
font_box=ttk.Combobox(tool_bar,width=30,
textvariable=font_family,state='readonly')
font_box['values']=font_tuple
font_box.current(font_tuple.index('Arial'))
font_box.grid(row=0,column=0,padx=5)

21 | Page
# size box
size_family=tk.IntVar()
font_size=ttk.Combobox(tool_bar,width=14,textvariable=size_family,state='
readonly')
font_size['values']=tuple(range(6,100,2))
# align left btn
align_left_icon=tk.PhotoImage(file='icons/align_left.png')
align_left_btn=ttk.Button(tool_bar,image=align_left_icon)
align_left_btn.grid(row=0,column=6,padx=5)
# align center btn
align_center_icon=tk.PhotoImage(file='icons/align_center.png')
align_center_btn=ttk.Button(tool_bar,image=align_center_icon)
align_center_btn.grid(row=0,column=7,padx=5)
# align right btn
align_right_icon=tk.PhotoImage(file='icons/align_right.png')
align_right_btn=ttk.Button(tool_bar,image=align_right_icon)
align_right_btn.grid(row=0,column=8,padx=5)

#************************************************************
**************
########### TEXT EDITIOR ###################
text_editor=tk.Text(main_application)
text_editor.config(wrap='word',relief=tk.FLAT)

22 | Page
scroll_bar=tk.Scrollbar(main_application)
text_editor.focus_set()
scroll_bar.pack(side=tk.RIGHT,fill=tk.Y)
text_editor.pack(fill=tk.BOTH,expand=True)
scroll_bar.config(command=text_editor.yview)
text_editor.config(yscrollcommand=scroll_bar.set)

########### SATTUS BAR ###################


status_bar=ttk.Label(main_application,text='status bar')
status_bar.pack(side=tk.BOTTOM)
####*******************tool baar
functionality********************************
# font family and font size functionality
current_font_family='Arial'
current_font_size=10
def font_changer(main_application):
global current_font_family
current_font_family=font_family.get()
text_editor.configure(font=(current_font_family,current_font_size))

def fontsize_changer(main_application):
global current_font_size

23 | Page
current_font_size=size_family.get()
text_editor.configure(font=(current_font_family,current_font_size))

font_box.bind("<<ComboboxSelected>>",font_changer)
font_size.bind("<<ComboboxSelected>>",fontsize_changer)

# button size funcationality


# for bold button
def change_bold():
text_property=tk.font.Font(font=text_editor['font'])
if text_property.actual()['weight']=='normal':

text_editor.configure(font=(current_font_family,current_font_size,'bold'))
if text_property.actual()['weight']=='bold':

text_editor.configure(font=(current_font_family,current_font_size,'normal'))

bold_btn.configure(command=change_bold)
# for italic button
def change_italic():
text_property=tk.font.Font(font=text_editor['font'])
if text_property.actual()['slant']=='roman':

text_editor.configure(font=(current_font_family,current_font_size,'italic'))

24 | Page
if text_property.actual()['slant']=='italic':

text_editor.configure(font=(current_font_family,current_font_size,'roman'))

italic_btn.configure(command=change_italic)
# for underline button
def change_underline():
text_property=tk.font.Font(font=text_editor['font'])
if text_property.actual()['underline']==0:

text_editor.configure(font=(current_font_family,current_font_size,'underline
'))
if text_property.actual()['underline']==1:

text_editor.configure(font=(current_font_family,current_font_size,'normal'))

underline_btn.configure(command=change_underline)
#print(tk.font.Font(font=text_editor['font'].actual())
### for font color changer
def font_color():
color_var=tk.colorchooser.askcolor()
text_editor.configure(fg=color_var[1])
font_color_btn.configure(command=font_color)
text_editor.configure(font=('Arial',10))
# for align functanality

25 | Page
def align_right():
text_content=text_editor.get(1.0,'end')
text_editor.tag_config('right',justify=tk.RIGHT)
text_editor.delete(1.0,tk.END)
text_editor.insert(tk.INSERT,text_content,'right')
align_right_btn.configure(command=align_right)
### status bar funcationality
text_changed=False
def changed(event=None):
global text_changed
if text_editor.edit_modified():
text_changed=True
words=len(text_editor.get(1.0,'end-1c').split())
chara=len(text_editor.get(1.0,'end-1c'))
status_bar.config(text=f'Charcaters : {chara} Words : {words}')
text_editor.edit_modified(False)
text_editor.bind("<<Modified>>",changed)

#************************************************************
########### MAIN MENU FUNCATIONLITY ##########
url=''

26 | Page
# file commond

#### NEW FUNCTIONALITY


def new_file(event=None):
global url
url=''
text_editor.delete(1.0,tk.END)
file.add_command(label='New',image=new_icon,compound=tk.LEFT,accel
erator='ctrl+N',command=new_file)
# OPEN FUNCTIONALITY
def open_file(event=None):
global url
url=filedialog.askopenfilename(initialdir=os.getcwd(),title='select
file',filetypes=(('Text File','*.txt'),('ALL Files','*.*')))
try:
with open(url,'r') as fy:
text_editor.delete(1.0,tk.END)
text_editor.insert(1.0,fy.read())
except FileNotFoundError:
return
except:
return
main_application.title(os.path.basename(url))

27 | Page
file.add_command(label='Open',image=open_icon,compound=tk.LEFT,acce
lerator='ctrl+O',command=open_file)

# save functionality
def save_file(event=None):
global url
try:
if url:
content=str(text_editor.get(1.0,tk.END))
with open(url,'w',encoding='utf-8') as fw:
fw.write(content)
else:
url = filedialog.asksaveasfile(mode = 'w', defaultextension='.txt',
filetypes=(('Text File', '.txt'), ('All files', '.*')))
content2=str(text_editor.get(1.0,tk.END))
url.write(content2)
url.close()
except:
return

file.add_command(label='Save',image=save_icon,compound=tk.LEFT,accel
erator='ctrl+S',command=save_file)
# save as functionality
def save_as_file(event=None):
global url

28 | Page
try:
content=text_editor.get(1.0, tk.END)
url = filedialog.asksaveasfile(mode = 'w', defaultextension='.txt',
filetypes=(('Text File', '.txt'), ('All files', '.*')))
url.write(content)
url.close()
except:
return
text_editor.config(font=('Arial',10))

file.add_command(label='Save_as',image=save_as_icon,compound=tk.LEF
T,accelerator='ctrl+Alt+S',command=save_as_file)
# exit functionality
def exit_file(event=None):
global url, text_changed
try:
if text_changed:
mbox = messagebox.askyesnocancel('Warning', 'Do you want to save
the file ?')
if mbox is True:
if url:
content = str(text_editor.get(1.0, tk.END))

29 | Page
with open(url, 'w', encoding='utf-8') as fw:
fw.write(content)

file.add_command(label='Save',image=save_icon,compound=tk.LEFT,accel
erator='ctrl+S',command=save_file)
# save as functionality
def save_as_file(event=None):
global url
try:
content=text_editor.get(1.0, tk.END)
url = filedialog.asksaveasfile(mode = 'w', defaultextension='.txt',
filetypes=(('Text File', '.txt'), ('All files', '.*')))
url.write(content)
url.close()
except:
return
text_editor.config(font=('Arial',10))

file.add_command(label='Save_as',image=save_as_icon,compound=tk.LEF
T,accelerator='ctrl+Alt+S',command=save_as_file)
# exit functionality
def exit_file(event=None):
global url, text_changed

30 | Page
try:
if text_changed:
mbox = messagebox.askyesnocancel('Warning', 'Do you want to save
the file ?')
if mbox is True:
if url:
content = str(text_editor.get(1.0, tk.END))
with open(url, 'w', encoding='utf-8') as fw:
fw.write(content)

file.add_command(label='Save',image=save_icon,compound=tk.LEFT,accel
erator='ctrl+S',command=save_file)
# save as functionality
def save_as_file(event=None):
global url
try:
content=text_editor.get(1.0, tk.END)
url = filedialog.asksaveasfile(mode = 'w', defaultextension='.txt',
filetypes=(('Text File', '.txt'), ('All files', '.*')))
url.write(content)
url.close()
except:
return
text_editor.config(font=('Arial',10))
file.add_command(label='Save_as',image=save_as_icon,compound=tk.LEF
T,accelerator='ctrl+Alt+S',command=save_as_file)

31 | Page
# exit functionality
def exit_file(event=None):
global url, text_changed
try:
if text_changed:
mbox = messagebox.askyesnocancel('Warning', 'Do you want to save
the file ?')
else:
content2 = str(text_editor.get(1.0, tk.END))
url = filedialog.asksaveasfile(mode = 'w', defaultextension='.txt',
filetypes=(('Text File', '.txt'), ('All files', '.*')))
url.write(content2)
url.close()
main_application.destroy()
elif mbox is False:
main_application.destroy()
else:
main_application.destroy()
except:
return

file.add_command(label='Exit',image=exit_icon,compound=tk.LEFT,acceler
ator='ctrl+Q',command=exit_file)
# edit commond

32 | Page
# copy
edit.add_command(label='Copy',image=copy_icon,compound=tk.LEFT,acc
elerator='ctrl+C',command=lambda: text_editor.event_generate("<Control
c>"))
text_editor.delete(1.0,tk.END)

edit.add_command(label='Clear
All',image=clear_all_icon,compound=tk.LEFT,accelerator='ctrl+Alt+z',com
mand=clear_all)
# find functionality
def find_func(event=None):
def find():
word=find_input.get()
text_editor.tag_remove('match','1.0',tk.END)
matches=0
if word:
start_pos='1.0'
while True:
start_pos=text_editor.search(word,start_pos,stopindex=tk.END)
if not start_pos:
break
end_pos=f'{start_pos}+{len(word)}c'
text_editor.tag_add('match',start_pos,end_pos)
matches+=1
start_pos=end_pos

33 | Page
text_editor.tag_config('match',foreground='black',background='red')
def Replace():
word=find_input.get()
replace_text=replace_input.get()
content=text_editor.get(1.0,tk.END)
new_content=content.replace(word,replace_text)
text_editor.delete(1.0,tk.END)
text_editor.insert(1.0,new_content)

find_dialog=tk.Toplevel()
find_dialog.geometry('450x250+500+200')
replace_input=ttk.Entry(findframe,width=30)
find_btn=ttk.Button(findframe,text='Find',command=find)
replace_btn=ttk.Button(findframe,text='Replace',command=Replace)
text_find_label.grid(row=0,column=0,padx=4,pady=4)
text_replace_label.grid(row=1,column=0,padx=4,pady=4)

find_dialog.mainloop()

edit.add_command(label='Find',image=find_icon,compound=tk.LEFT,accel
erator='ctrl+F',command=find_func)
# view commond

34 | Page
# VIEW FUNCTIONALITY
show_statusbar=tk.BooleanVar()
show_statusbar.set(True)
show_toolbar=tk.BooleanVar()
show_toolbar.set(True)
def hide_toolbar():
global show_toolbar
if show_toolbar:
tool_bar.pack_forget()
show_toolbar=False
else:
text_editor.pack_forget()
#status_bar.pack_forget()
tool_bar.pack(side=tk.TOP,fill=tk.X)
text_editor.pack(fill=tk.BOTH,expand=True)
#status_bar.pack(side=tk.BOTTOM)
show_toolbar=True
def hide_statusbar():
global show_statusbar
if show_statusbar:
status_bar.pack_forget()

35 | Page
show_statusbar=False
else:
text_editor.pack_forget()
status_bar.pack(side=tk.BOTTOM,fill=tk.Y)
text_editor.pack(fill=tk.BOTH,expand=True)
show_statusbar=True

view.add_checkbutton(label='Tool
Bar',onvalue=True,offvalue=False,variable =show_toolbar,
image=tool_bar_icon,compound=tk.LEFT,command=hide_toolbar)
view.add_checkbutton(label='Status
Bar',onvalue=True,offvalue=False,variable =show_statusbar,
image=status_bar_icon,compound=tk.LEFT,command=hide_statusbar)
# color theme commond
# colour theme functionality
def change_theme():
choose_theme=theme_choice.get()
colourtuple=color_dict.get(choose_theme)
fg_color,bg_color=colourtuple[0],colourtuple[1]
text_editor.config(background=bg_color,fg=fg_color)
count=0
for i in color_dict:
colour_theme.add_radiobutton(label=i,image=color_icons[count],variable=t
heme_choice,compound=tk.LEFT,command=change_theme)
count=count+1
#************************************************************

36 | Page
# bind shortcut key
main_application.config(menu=main_menu)
main_application.bind("<Control-n>",new_file)
main_application.mainloop()
Result :

CHAPTER 6 : CONCLUSION And REFERENCES

Conclusion

37 | Page
So that’s how we have successfully made a text editor by python. This
text editor can write texts, can change fonts of the texts , can change the
alignment of the text, save it, copy, redo, undo etc. basically we have
made a little notepad with python in aur project.

References

● www.python.org
● www.studylib.net.in
● Techinnovation notes
● www.pythonforeverybody.in

38 | Page

You might also like