Skip to content

Instantly share code, notes, and snippets.

@adamantonio
Last active December 18, 2022 22:21
Show Gist options
  • Save adamantonio/1d2bf43a8d245a164526cd2aee0c0025 to your computer and use it in GitHub Desktop.
Save adamantonio/1d2bf43a8d245a164526cd2aee0c0025 to your computer and use it in GitHub Desktop.
Correct Horse Battery Staple Password Generator - https://www.youtube.com/watch?v=7rT_kqxOCXw
import gooeypie as gp
from random import choice
nouns = open('words-nouns.txt').read().splitlines()
adjectives = open('words-adjectives.txt').read().splitlines()
def generate_password(event):
"""Generates and displays a new random password"""
word1 = choice(adjectives)
word2 = choice(nouns + adjectives)
word3 = choice(nouns + adjectives)
word4 = choice(nouns)
password_lbl.text = f'{word1} {word2} {word3} {word4}'
def show_about_window(event):
"""Opens the 'About' window"""
about_window.show()
# Create the main window
app = gp.GooeyPieApp('Correct Horse Battery Staple Password Generator')
app.width = 600
app.resizable_vertical = False
# Create widgets for main window
password_lbl = gp.StyleLabel(app, 'correct horse battery staple')
password_lbl.font_size = 20
new_password_btn = gp.Button(app, "You've already memorized it", generate_password)
# Add widgets to main window
app.set_grid(2, 1)
app.add(password_lbl, 1, 1, align='center')
app.add(new_password_btn, 2, 1, align='center')
# Add the Help -> About menu to the main window
app.add_menu_item('Help', 'About', show_about_window)
# Create the 'About' window
about_window = gp.Window(app, 'About Correct Horse Battery Staple')
# Create widgets for the 'About' window
description_lbl = gp.Label(about_window, 'This app is based on the following comic by xkcd')
xkcd_img = gp.Image(about_window, 'password_strength.png')
xkcd_lnk = gp.Hyperlink(about_window, 'Comic by xkcd', 'https://xkcd.com/936/')
# Add widgets to the 'About' window
about_window.set_grid(3, 1)
about_window.add(description_lbl, 1, 1, align='center')
about_window.add(xkcd_img, 2, 1)
about_window.add(xkcd_lnk, 3, 1, align='center')
app.run()
@adamantonio
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment