
In your function you have a password2 but no password.

It would be much nicer to return password2 and then call text.insert in the same place you call complex_password. It's unusual to see something like inserting the password result into a global object. Usually a function will return a value or run some process that modifies another value (eg a file on your computer or a class's attributes).
#Complex password creator code
Your code is quite confusing in some places. Text = tk.Text(text_frame, borderwidth=10, height=8, width=20, relief="sunken") Main.resizable(width=tk.FALSE, height=tk.FALSE) You can organize code this way import tkinter as tk In complex_password you don't need if count = 12 because this part can be outside while/for loop. In complex_password you can use for loop instead while and don't need variable count. In complex_password you can randint(1, 2) instead randint(1, 4) because it gives the same probability - 50% for letter and 50% for number. You can add empty lines in functions to separate some part of functions You can use "" directly with join "".join(password1)Īround text_frame in tk.Text((text_frame). In comments you can put one space after # - to make it more readable. Password1 and password2 are local variables so you can use one name password in both functions.įor loop put in two lines - to make it more readable. You don't have to convert string.ascii_lowercase and string.ascii_uppercase into list. You can use string.ascii_lowercase instead of letters list, and string.ascii_uppercase instead of capital. 'Silver', 'Bronze', 'Platinum', 'Titanium', 'Exploding', 'Ladybug', 'Grass', Main.resizable(width=FALSE, height=FALSE) Simple = ttk.Button(button_frame, text="Simple", command=simple_password)Ĭomplex = ttk.Button(button_frame, text="Complex", command=complex_password)Ĭlear = ttk.Button(button_frame, text="Clear", command=clear_text)įor child in frame.winfo_children(): id_configure(padx=5, pady=10)

Password2.append(random.choice((letters)))ĭef simple_password(): #simple password functionĭef clear_text(): #clear txt box function

Text = Text((text_frame), borderwidth=10, height=8, width=20, relief="sunken",)ĭef complex_password(): #complex password function I am a bit shaky on how classes work, but I think that it can be used here to make it more simple.

I am pretty new to Python and I would like some tips and criticism on my formatting style/code and what can be better organized.
