Skip to content

Commit

Permalink
Clear entry after profile is added
Browse files Browse the repository at this point in the history
  • Loading branch information
okraska-kropidlowski committed Oct 29, 2023
1 parent 9fb3259 commit 0f1d292
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#Functions definition
def add_profile():
global profiles_file_content
new_profile = add_profile_box.get()
if len(new_profile) > 16:
new_profile = new_profile[:16]
Expand All @@ -28,14 +29,17 @@ def add_profile():
with open('data/profiles_list', "a") as profiles_file:
if profiles_file_content == '':
profiles_file.write(new_profile)
profiles.destroy()
add_profile_box.delete(0, tkinter.END)
return
elif not profiles_file_content.endswith('\n'):
profiles_file.write('\n')
profiles_file.write(new_profile)
profiles.destroy()
add_profile_box.delete(0, tkinter.END)
return
elif profiles_file_content.endswith('\n'):
profiles_file.write(new_profile)
profiles.destroy()
add_profile_box.delete(0, tkinter.END)
return

def profile_name_check(profile_entry):
if (profile_entry.isalnum() or profile_entry in ['_', '-']):
Expand Down

0 comments on commit 0f1d292

Please sign in to comment.