1

While working with Tkinter, I have created two lists as below.

list1=['Archie']
list2=['mynameisarchie']

Within a function, I have defined a condition as follows.

 def clicked():
    global list1
    global list2
    count=0
    count1=0
    if e4.get() in list1:
        count+=1
    if e5.get() in list2:
        count1+=1
    if count!=0:
        messagebox.showinfo('Problem', 'Username Already in Use')
    if count1!=0:
        messagebox.showinfo('Problem','Password Already in Use')
    count2=count+count1
    if count2==0:
        messagebox.showinfo('Congrats','Successfully Registered')

If count2==0, then I want the values of e4.get() and e5.get() to get appended to list1 and list2.

When I run the program and the user enters some value in e4 and e5 and say it satisfies the above condition, I want those values to get permanently appended in the list such that even if I kill the program and run it again, the appended values are retained in the list and are utilised in the comparison shown in the code.

Is it possible to do so?

P.S - list1 and list2 are not present within any function and are independent.

Ash
  • 19
  • 3

1 Answers1

1

Maybe keeping the list1 and list2 either in a file (and then using simple file handling through your tkinter program) or in your database (like sqlite3 and here also editing it through your tkinter program) will help you to "permanently" change the values of list1 and list2, after every time you run the GUI program.

Else, you need to manually update the values inside the code, every time you run your application.

Kartikeya
  • 818
  • 2
  • 6
  • 11