I need help with my code

I have the below code that helps me check a log file . The code is working fine but I need some modifications . There are three field for users to input . The fields are user name , extension and default URL . I want an option to click on remember my username and extension number so that users won’t be entering this details all the time.

Below is my code
from msilib.schema import Error
import threading
import xml.etree.ElementTree as ET
import json
import requests
import time

from functools import partial
from tkinter import *
from functools import partial


def find(name, ext, url, uids, filename=‘AvayaOnexPortalClientLog.log’):
with open(filename, ‘r’) as f:
log = f.read()

lines = log.splitlines()
tagName = 'additionalCallInfo'
i = 0
for line in lines:
    i += 1
    if 'booleanFlag="true"><additionalCallInfo><callingPartyInfo external' in line:
        a = line.index(tagName)-1
        b = a + 2 + line[a + 2:].index(tagName) + len(tagName) + 1
        xmlPart = line[a:b]
        #print(str(a) + "  " + str(b))
        #print('line : ' + str(i) + "\n" + xmlPart)
        root = ET.fromstring(xmlPart)
        # print(root.tag)

        for child in root:
            if child.tag == 'callingPartyInfo':
                calling = child
            elif child.tag == 'calledPartyInfo':
                called = child
            elif child.tag == 'uniqueCallId':
                uid = child.text

        if uid in uids:
        mobNum = '-1'
        if calling.attrib['callerName'] == name and calling.attrib['number'] == ext:
            mobNum = called.attrib['number']

        elif called.attrib['callerName'] == name and called.attrib['number'] == ext:
            mobNum = calling.attrib['number']
        if mobNum == '-1':
            print('Extension number mismatch')
        x = {"Mobile": str(mobNum), "ReferredBy": name,
             "action": "generateLead"}
        headers = {
            "User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36"}
        response = requests.post(url, headers=headers, json=x)
        print("Sent request for unique caller id = " +
              str(uid) + " , json = " + str(x))
        print("Received response : json = " + str(response.json()) + '\n')

def start(nameField, extField, urlField):
global running
if running:
print(‘Already running’)
running = True
name = nameField.get()
ext = extField.get()
url = urlField.get()
uids = set()

def loop():
    while running:
        find(name, ext, url, uids)
    print('Program Stopped.')
thread = threading.Thread(target=loop)

def stop():
global running
running = False


tkWindow = Tk()
tkWindow.title(‘Log App’)

nameLabel = Label(tkWindow, text=“Name”).grid(row=0, column=0)
name = StringVar()
nameEntry = Entry(tkWindow, textvariable=name).grid(row=0, column=1)

extLabel = Label(tkWindow, text=“Extension Number”).grid(row=1, column=0)
ext = StringVar()
extEntry = Entry(tkWindow, textvariable=ext).grid(row=1, column=1)

urlLabel = Label(tkWindow, text=“Post URL”).grid(row=2, column=0)
url = StringVar()
urlEntry = Entry(tkWindow, textvariable=url).grid(row=2, column=1)

start = partial(start, name, ext, url)

def test():

def post():

myjson = json.dumps({“Mobile”: “9876543210”,

“ReferredBy”: “Shivang”, “action”: “generateLead”})


headers = {

“User-Agent”: “Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36”}

response = requests.post(’,json=myjson)


except BaseException as e:


t = threading.Thread(target=post)


running = False
startButton = Button(tkWindow, text=“Start”,
command=start).grid(row=4, column=0)

stopButton = Button(tkWindow, text=“Stop”,
command=stop).grid(row=5, column=0)

testButton = Button(tkWindow, text=“Test”,

command=test).grid(row=5, column=0)

running = False

Can you advise how to implement this remember my username and extension?..

I would say: to the code which constructs the window, add a check to see if a file exists, and if it does, load those values from the file as the default values; and add a checkbox that activates code that takes those values and writes them to the file the first part is looking for. On first run, the boxes will be blank, because no file exists; if the user checks the box, execution writes the values to the file; on the next run, those values are read from the file and appear in the text boxes.

Yes you are right that what the code does . When I convert this.py file to exe I want a field that an additional checkbox field on the gui interface that says remember my login details.