-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodename_generator.py
More file actions
87 lines (69 loc) · 3.45 KB
/
codename_generator.py
File metadata and controls
87 lines (69 loc) · 3.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/python3
import tkinter as tk
from tkinter import messagebox
import os
import random
import csv
# Predefined lists of words for generating code names
adjectives = ["Silent", "Crimson", "Shadow", "Swift", "Mighty", "Stealthy", "Lone", "Iron",
"Agile", "Bold", "Bright", "Brilliant", "Calm", "Clever", "Cold","Courageous", "Daring",
"Dazzling", "Deep", "Diligent", "Divine", "Dynamic", "Elegant", "Fierce", "Fiery",
"Gentle", "Glorious", "Golden", "Graceful", "Grand", "Hardy", "Heavenly", "Heroic",
"Keen", "Luminous", "Majestic", "Noble", "Peaceful", "Powerful", "Pristine", "Radiant",
"Regal", "Resilient", "Robust", "Sacred", "Serene", "Sharp", "Shining", "Silent", "Stalwart",
"Strong", "Tenacious", "Tranquil", "True", "Unyielding", "Vibrant", "Vivid", "Wise"]
nouns = ["Falcon", "Wolf", "Tiger", "Phantom", "Eagle", "Raven", "Panther", "Sword",
"Archer", "Arrow","Bear", "Blaze", "Blossom", "Boulder", "Breeze", "Bull",
"Canyon","Champion", "Comet", "Crest", "Crown", "Dagger", "Dragon", "Ember",
"Fang", "Flame", "Glacier", "Griffin", "Guardian", "Hawk", "Horizon",
"Hunter", "Kraken", "Lantern", "Lion", "Lynx", "Mammoth", "Meteor",
"Moon", "Mountain", "Ocean", "Oracle", "Phoenix", "Pillar", "River",
"Saber", "Sentinel", "Shield", "Sky", "Spear", "Spirit", "Stag",
"Star", "Storm", "Tempest", "Thunder", "Trail", "Warden" ]
# Function to generate a random codename
def generate_codename():
adjective = random.choice(adjectives)
noun = random.choice(nouns)
return f"{adjective} {noun}"
# Function to save the codename and additional details into a .csv file
def save_to_csv(codename, details):
filename = "codenames.csv"
# Check if the file exists
file_exists = os.path.exists(filename)
# Open the file in append mode
with open(filename, mode='a', newline='', encoding='utf-8') as file:
writer = csv.writer(file)
# Write headers if the file is new
if not file_exists:
writer.writerow(["Codename", "Details"])
# Write the new codename and details
writer.writerow([codename, details])
# Function to handle the button click event
def on_generate_and_save():
codename = generate_codename()
details = details_entry.get()
if details.strip() == "":
messagebox.showerror("Error", "Details cannot be empty.")
return
save_to_csv(codename, details)
messagebox.showinfo("Success", f"Codename '{codename}' saved successfully!")
codename_label.config(text=f"Generated Codename: {codename}")
details_entry.delete(0, tk.END)
# Create the main tkinter window
root = tk.Tk()
root.title("Codename Generator")
root.geometry("400x300")
# Add a label for instructions
instruction_label = tk.Label(root, text="Enter details for the case, person, or investigation:")
instruction_label.pack(pady=10)
# Add an entry field for case details
details_entry = tk.Entry(root, width=50)
details_entry.pack(pady=5)
# Add a button to generate and save the codename
generate_button = tk.Button(root, text="Generate and Save Codename", command=on_generate_and_save)
generate_button.pack(pady=10)
# Add a label to display the generated codename
codename_label = tk.Label(root, text="")
codename_label.pack(pady=20)
# Run the tkinter event loop
root.mainloop()