-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrack++.py
197 lines (106 loc) · 3.62 KB
/
drack++.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# importing important libarys
import tkinter
import easygui
# creating window titled - "untitled"
r = tkinter.Tk()
r.title('untitled')
# creating functions
# creating function called saveasfile
def saveasfile():
# taking text varible
global text
# making file saving box
filename = easygui.filesavebox()
# saving as the file
file = open(filename,'w')
file.write(text.get('1.0','end-1c'))
file.close()
# replacing the tkinter title
r.title(filename)
# creating function called savefile
def savefile():
# taking text varible
global text
# checking if the file is untitled
# if file is untitled then
# else editing the file
if r.title() == 'untitled':
saveasfile()
else:
file = open(r.title(),'w')
file.write(text.get('1.0','end-1c'))
file.close()
# creating function called openfile
def openfile():
# taking varible called text
global text
# making fileopenbox
filename = easygui.fileopenbox()
# deleteing orignial text
text.delete('1.0','end-1c')
# reading the file and inserting the text of file
text.insert('1.0',open(filename,'r').read())
# replacing the title
r.title(filename)
# creating function called newfile
def newfile():
# taking the varible called text
global text
# deleteing the original text
text.delete('1.0','end-1c')
# renaming the title to untitled file
r.title('untitled')
# making all editing text written in textarea function
# creating function called cut_text
def cut_text():
# taking the varible called text
global text
# generating the event to cut thing from text area
text.event_generate('<<Cut>>')
def copy_text():
# taking the variable called text
global text
# generating the event to cut thing from text area
text.event_generate('<<Copy>>')
def paste_text():
# taking the varible called text
global text
# generating the event to paste thing from text area
text.event_generate('<<Paste>>')
def select_all_text():
# taking the varible text
global text
# generating the event to salecting all things from text area
text.event_generate('<<SelectAll>>')
def delete_all_text():
global text
text.delete('1.0','end-1c')
# creating function called python
# creating text area with varible named text
text = tkinter.Text(r)
# creating all buttons for file
saveasfile_button = tkinter.Button(r,text = 'Save As',command = saveasfile)
savefile_button = tkinter.Button(r,text = 'Save',command = savefile)
openfile_button = tkinter.Button(r,text = 'Open',command = openfile)
newfile_button = tkinter.Button(r,text = 'New',command = newfile)
# creating the buttons for editing text written in text area
cut_text_button = tkinter.Button(r,text = 'Cut',command = cut_text)
copy_text_button = tkinter.Button(r,text = 'Copy',command = copy_text)
paste_text_button = tkinter.Button(r,text = 'Paste',command = paste_text)
select_all_text_button = tkinter.Button(r,text = 'Select All',command = select_all_text)
delete_all_text_button = tkinter.Button(r,text = 'Delete all',command = delete_all_text)
# packing text area in tkinter window
text.pack()
# packing all buttons of file in tkinter window
saveasfile_button.pack()
savefile_button.pack()
openfile_button.pack()
newfile_button.pack()
# packing all buttons of editing text written in text area
cut_text_button.pack()
copy_text_button.pack()
paste_text_button.pack()
select_all_text_button.pack()
delete_all_text_button.pack()
# ending the tkinter
r.mainloop()