Question
Add a command in which the inputs of the user will be sent and save to notepad with filename being database.txt. Code: from tkinter import*
Add a command in which the inputs of the user will be sent and save to notepad with filename being database.txt.
Code:
from tkinter import*
from tkinter import messagebox
services = []
def showInfo():
for i in range(len(services)):
selected=""
if services[i].get()>=1:
selected += str(i)
def submit():
name=entry1.get()
age=entry2.get()
gender=entry3.get()
address=entry1.get()
if (name=="" and age=="" and gender=="" and address==""):
messagebox.showinfo("","Blank not allowed")
else:
messagebox.showinfo("","Your response have been submitted") and quit()
root=Tk()
root.title("Health and Security Checklist")
root.geometry("300x800")
global entry1
global entry2
global entry3
global entry4
Label(root,text="User Information").place(x=100,y=10)
Label(root,text="Name").place(x=20,y=50)
Label(root,text="Age").place(x=20,y=90)
Label(root,text="Gender").place(x=20,y=130)
Label(root,text="Address").place(x=20,y=170)
entry1=Entry(root,bd=5)
entry1.place(x=140,y=50)
entry2=Entry(root,bd=5)
entry2.place(x=140,y=90)
entry3=Entry(root,bd=5)
entry3.place(x=140,y=130)
entry4=Entry(root,bd=5)
entry4.place(x=140,y=170)
Label(root,text="Health Checklist").place(x=100,y=220)
Label(root,text="Are you experiencing some of these symptoms?").place(x=20,y=250)
for i in range(8):
option = IntVar()
option.set(0)
services.append(option)
Checkbutton(text= "Sore Throat",
variable=services[0]).place(x=20,y=285)
Checkbutton(text= "Headaches",
variable=services[1]).place(x=20,y=320)
Checkbutton(text= "Cough or Colds",
variable=services[2]).place(x=20,y=355)
Checkbutton(text= "Body Aches or Pains",
variable=services[3]).place(x=20,y=390)
Checkbutton(text= "Fever",
variable=services[4]).place(x=20,y=425)
Label(root,text="Security Checklist").place(x=100,y=475)
Label(root,text="Have you observed some of these activities?").place(x=20,y=505)
for i in range(4):
option = IntVar()
option.set(0)
services.append(option)
Checkbutton(text= "Stealing",
variable=services[5]).place(x=20,y=540)
Checkbutton(text= "Vandalism",
variable=services[6]).place(x=20,y=575)
Checkbutton(text= "Drug usage",
variable=services[7]).place(x=20,y=610)
Checkbutton(text= "Violence",
variable=services[8]).place(x=20,y=645)
Checkbutton(text= "Trespassing",
variable=services[9]).place(x=20,y=680)
Button(root,text="Submit",command=submit,height=2,width=13,bd=6).place(x=100,y=730)
root.mainloop()
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started