Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Added word's entry, centered the window and the word_entry accepts only numbers #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 25 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
from tkinter import *
from random import randint
import screeninfo

screenWidth = screeninfo.get_monitors()[0].width
screenHeight = screeninfo.get_monitors()[0].height

root = Tk()
root.geometry("500x300")
root.geometry(f"500x450+{int(screenWidth/2-500/2)}+{int(screenHeight/2-450/2)}")
root.title("Password generator")
root.resizable(False, False)

def new_rand():
pw_entry.delete(0, END)
pw_length = int(my_entry.get())

try:
pw_length = int(characters_entry.get())
except:
characters_entry.delete(0, END)
characters_entry.insert(0, "Only numbers")

return

my_password = ''

for x in range(pw_length):
my_password += chr(randint(33,126))

pw_entry.insert(0, my_password)
pw_entry.insert(0, word_entry.get() + my_password)

def clipper():
root.clipboard_clear()
Expand All @@ -21,8 +35,14 @@ def clipper():
lf = LabelFrame(root, text="How Many Characters?")
lf.pack(pady=20)

my_entry = Entry(lf, font=("Helvetica", 24))
my_entry.pack(pady=20, padx=20)
characters_entry = Entry(lf, font=("Helvetica", 24))
characters_entry.pack(pady=20, padx=20)

word_lf = LabelFrame(root, text="Write a Word")
word_lf.pack(pady=20)

word_entry = Entry(word_lf, font=("Helvetica", 24))
word_entry.pack(pady=20, padx=20)

pw_entry = Entry(root, text='', font=("Helvetica", 24), bd=0, bg="systembuttonface")
pw_entry.pack(pady=20)
Expand Down