-
Notifications
You must be signed in to change notification settings - Fork 0
/
tkinter(form).py
41 lines (34 loc) · 1.08 KB
/
tkinter(form).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
from tkinter import *
window = Tk()
window.title("Wellcome to my Server")
window.geometry('400x200')
window.configure(background = "Light green")
name = Label(window,text = "Full Name").pack()
no =Label(window,text = "contact Name").pack()
lbl = Label(window,text = "empty")
lbl.pack(expand = True, fill =BOTH)
frame = Frame(window,bg ="red")
frame.pack()
name_entry =Entry(frame)
name_entry.pack()
no_entry = Entry(frame)
no_entry.pack()
def btn_click():
res = "Welcome "+ name_entry.get()+" your no is "+ no_entry.get()
lbl.configure(text = res)
def write():
file = open("form.txt","a")
res ="Wellcome "+name_entry.get() +"your no is "+no_entry.get()+"\n"
file.write(res)
file.close()
def read():
file = open("form.txt","r")
x = file.readline()
lbl.configure(text = x)
btn = Button(window,text = "submit",command = btn_click)
rbtn = Button(window,text = "read",command = read)
wbtn = Button(window,text = "write",command = write)
btn.pack(expand = True, fill = BOTH)
rbtn.pack(expand = True, fill = BOTH)
wbtn.pack(expand = True, fill = BOTH)
window.mainloop()