Skip to content

Commit bde63f3

Browse files
committed
Commented the code
1 parent a8faf3b commit bde63f3

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

GUIScripts/VirtuaL Copy Paste/virtual_copy_paste.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,44 @@
1+
2+
# imported necessary library
13
from tkinter import *
24
from tkinter import messagebox
35
import tkinter.messagebox as mbox
46
import tkinter as tk
57

6-
8+
# created main window
79
root = Tk()
810
root.title("Virtual Copy Paste")
911
root.geometry('1000x700')
1012

11-
12-
def print_output():
13-
mbox.showinfo("Text Entered", "Text Entered :\n\n" + text_enter.get('1.0',END))
14-
15-
# frame 1 ----------------------------------------------
13+
# frame 1 --------------------------- created frame 1 ------------------
1614
def des_f1():
1715
f1.destroy()
1816

19-
17+
# frame 1 created which is the main window
2018
f1 = Frame(root, height=700, width=1000)
2119
f1.propagate(0)
2220
f1.pack(side='top')
2321

22+
# this is for adding image in the main window
2423
c = Canvas(f1, width=1000, height=700)
2524
c.pack()
2625
p1 = PhotoImage(file='Images/copy_paste.gif')
2726
c.create_image(0, 100, image=p1, anchor=NW)
2827

28+
# for starting label
2929
start1 = Label(f1, text='VIRTUAL Copy Paste', font=("Arial", 50), fg="magenta", underline = 0)
3030
start1.place(x=150, y=10)
3131

32+
# created a START button
3233
startb = Button(f1, text="START",command=des_f1,font=("Arial", 30), bg = "light green", fg = "blue", borderwidth=3, relief="raised")
3334
startb.place(x = 180 , y =550 )
3435
# ------------------------------------------------------
3536

3637
# frame 2 ---------------------------------------------
38+
# created global variable s
3739
s = ""
3840

41+
# function for clearing the default text from text1 when put cursor on it
3942
firstclick1 = True
4043
def on_text_enter_click(event):
4144
"""function that gets called whenever entry1 is clicked"""
@@ -44,16 +47,19 @@ def on_text_enter_click(event):
4447
firstclick1 = False
4548
text1.delete('1.0', "end") # delete all the text in the entry
4649

50+
# function for copying the text
4751
def copy_text():
4852
global s
4953
s = s + text1.get("1.0", "end-1c")
5054

55+
# function for seeing the copied text
5156
def see_text():
5257
if(s == ""):
5358
mbox.showerror("Error", "You haven't copied anything!")
5459
else:
5560
mbox.showinfo("Copied Text", "COPIED TEXT :\n\n" + s)
5661

62+
# function for pasting the text
5763
def paste_text():
5864
global s
5965
if (s == ""):
@@ -63,35 +69,40 @@ def paste_text():
6369
text2.insert(END, s)
6470
s = ""
6571

66-
72+
# created frame 2
6773
f2 = Frame(root, height=700, width=1000)
6874
f2.propagate(0)
6975
f2.pack(side='top')
7076

77+
# created first textarea
7178
text1 = tk.Text(f2, height=20, width=35, font=("Arial", 15), bg="light yellow", fg="brown",borderwidth=3, relief="solid")
7279
text1.insert(END, 'Enter any text here and Copy it...') # default line in text area, can be cleared when touched
7380
text1.bind('<FocusIn>', on_text_enter_click)
7481
text1.place(x=50, y=20)
7582

83+
# created second textarea
7684
text2 = tk.Text(f2, height=20, width=35, font=("Arial", 15), bg="light yellow", fg="brown",borderwidth=3, relief="solid")
7785
text2.insert(END, 'Paste the copied text here...') # default line in text area, can be cleared when touched
7886
text2.place(x=550, y=20)
7987

80-
88+
# created COPY button
8189
copyb = Button(f2, text="COPY",command=copy_text,font=("Arial", 30), bg = "light green", fg = "blue", borderwidth=3, relief="raised")
8290
copyb.place(x =100 , y =550 )
8391

92+
# Created SEE button
8493
seeb = Button(f2, text="SEE",command=see_text,font=("Arial", 30), bg = "light green", fg = "blue", borderwidth=3, relief="raised")
8594
seeb.place(x =300 , y =550 )
8695

96+
# created a PASTE button
8797
pasteb = Button(f2, text="PASTE",command=paste_text,font=("Arial", 30), bg = "light green", fg = "blue", borderwidth=3, relief="raised")
8898
pasteb.place(x =480 , y =550 )
8999

100+
# function for exiting
90101
def exit_win():
91102
if messagebox.askokcancel("Exit", "Do you want to exit?"):
92103
root.destroy()
93104

94-
105+
# created a exit button
95106
exitb = Button(root, text="EXIT",command=exit_win,font=("Arial", 30), bg = "red", fg = "blue", borderwidth=3, relief="raised")
96107
exitb.place(x =700 , y =550 )
97108

0 commit comments

Comments
 (0)