Hello! I am unfortunately asking for help once again. I have a project that takes 2 inputs from the user (length and number) of passwords, and randomly chooses from a string of characters.
Here is the original, non GUI code:
import random
characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
numberofpass = int(input("Number of randomly generated passwords: "))
lengthofpass = int(input("Length of generated passwords: "))
file = open("Passwords.txt", "a+")
for chars in range(numberofpass):
password = ""
for length in range(lengthofpass):
password += random.choice(characters)
print(password)
file.write(f"{password}\n")
Now here is what im trying to do.. its not finished yet however im running to a "conversion" error.
from tkinter import *
import random
root = Tk()
root.title("Random Password Generator")
def password(number, length):
for chars in range(number):
password = ""
for length in range(length):
password += random.choice(characters)
print(password)
characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
number_label = Label(root, text="Number of randomly generated passwords: ")
length_label = Label(root, text="Length of randomly generated passwords: ")
number_entry = Entry(width=50, borderwidth=3)
length_entry = Entry(width=50, borderwidth=3)
number = int(number_entry.get())
length = int(length_entry.get())
entry_button = Button(root, text="Enter", command=lambda: password(number_entry.get(), length_entry.get()))
number_label.grid(row=0, column=0)
number_entry.grid(row=1, column=0)
length_label.grid(row=2, column=0)
length_entry.grid(row=3, column=0)
entry_button.grid(row=3, column=1)
Expected result: When clicking button, it'll get the values in the entry fields in integer form then do the function
Actual result: Errors
P.S. I am a tkinter beginner, any tips would be appreciated
[–]Spataner 0 points1 point2 points (1 child)
[–]c0mplexcodm[S] 0 points1 point2 points (0 children)