forked from Techsrijan/summer2025
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtext_in_tkintr.py
More file actions
30 lines (27 loc) · 862 Bytes
/
text_in_tkintr.py
File metadata and controls
30 lines (27 loc) · 862 Bytes
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
from tkinter import *
from tkinter import filedialog
root=Tk()
def get_text_data():
print(t.get(1.0,END))
def open_file():
f=filedialog.askopenfile(initialdir="/",
filetypes=[("Text files", "*.txt"), ("All files", "*.*")])
print(f)
for data in f:
# print(data)
t.insert(END, data)
t=Text(root,height=15,padx=10,pady=10,width=15,wrap=WORD,selectbackground='red')
# t.pack(fill=BOTH,expand=1)
# t.insert(END,'HOW are you what are you')
# t.insert(END,'HOW are you')
t.pack()
btn=Button(root,text="get_text_data", fg="red",bg="yellow",
font=("comic sans ms",15,'bold'),
command=get_text_data)
btn.pack()
btn1=Button(root,text="open file", fg="red",bg="yellow",
font=("comic sans ms",15,'bold'),
command=open_file)
btn1.pack()
root.geometry("600x500+500+200")
root.mainloop()