how to create a GUI using python to take user input and insert it into excel sheet how to create a GUI using python to take user input and insert it into excel sheet tkinter tkinter

how to create a GUI using python to take user input and insert it into excel sheet


You can create GUI using python tkinter, you can also create input fields using this library and accept the entered value. After this you can simple use python csv library to insert a record into sheet.

You can find more information about tkinter Here

Use this code to read data from test.txt (use your txt file) file, insert data into file also as you asked it will also check if same data exist. You can view the data by clicking on view data button.

from tkinter import *root = Tk()root.geometry("700x700")ivn = StringVar()inputVarName = Entry(root, textvariable=str(ivn))ivn.set(str("text1"))inputVarName.grid(row=0, column=0)ivn2 = StringVar()inputVarName2 = Entry(root, textvariable=str(ivn2))ivn2.set(str("text2"))inputVarName2.grid(row=1, column=0)def printSomething():    with open('help.txt') as f:        r = f.read()    label = Label(root, text=r)    label.grid()def checkdata():    with open('help.txt') as f:        r = f.read()    return r.split("\n")def writetofile():    exist_data = checkdata()    content_list = [ivn.get(), ivn2.get()]    with open("help.txt", "a") as f:        for item in content_list:        if item in exist_data:            msg = "Already exist "+item            label = Label(root, text=msg)            label.grid()        elif not item in exist_data:            f.write("%s\n" % item)applyButton = Button(root, text="Add Data", command=writetofile)applyButton.grid(row=2, column=1)veiwButton = Button(root, text='View Data', command=printSomething)veiwButton.grid(row=3, column=1)root.mainloop()

Note: There are multiple ways to achieve this, one of them is this one.