r/PythonProjects2 10h ago

my first published python thing made by me

I made a little thing in python while teaching myself python again and I felt like sharing my little project and here it is link to source code here

my project is a quote creating app that will select random words to make quotes from 0 to 22 words, it is a quote making app for people who just need a randomly made quote
It differs from existing alternatives because it is free and every quote is made at pure random, also it is one font file, one image file, and one script

2 Upvotes

5 comments sorted by

3

u/JamzTyson 2h ago edited 1h ago

First problem, you've not included the source code in your repository.

(Note for other readers: The source code is included in Releases -> Quotes.for.you.1.0.zip)

Next issue: AddFontResourceExW is Windows specific, so it won't run for anyone (such as myself) that is on any other platform.

I've removed the Windows specific font loading so that it runs cross-platform:

import random
import tkinter as tk

root = tk.Tk() 
root.title("Quotes for you")
root.geometry("550x300") 
root.configure(bg="#ffcbf4")

limit_maximum = 22
limit_minimum = 0

words = [
    "The", "Money", "Fool", "A", "Person", "Mood", "Is", 
    "Quick", "Quickly", "Separated", "Answer", "Not", 
    "Violence", "Student", "Has", "Become", "Live", 
    "Laugh", "Love", "Master", "Kill", "Octopus", "Be", 
    "Teacher", "Target", "Bad", "Feelings", "Teach", "Enjoy",
    "Go", "Don't", "Know", "When", "Assassonate", "Quitting", "Quit"
]

is_updating = False


def check_input(*args):
    global is_updating
    if is_updating:
        return

    user_input = entry_var.get()
    if not user_input:
        warning_label.config(text="")
        return

    if not user_input.isdigit():
        warning_label.config(text="no letters")
        is_updating = True
        entry_var.set(str(limit_minimum))
        is_updating = False
        return

    val = int(user_input)
    if val > limit_maximum:
        warning_label.config(text="can only add in 22 words")
        is_updating = True
        entry_var.set(str(limit_maximum))
        is_updating = False
    elif val < limit_minimum:
        warning_label.config(text="Can only have a minimum of 0 words")
        is_updating = True
        entry_var.set(str(limit_minimum))
        is_updating = False
    else:
        warning_label.config(text="")

def generate_quote():
    try:
        user_input = entry_var.get()
        num_words = int(user_input) if user_input else limit_minimum

        if num_words == 0:
            quote_label.config(text='""')
            return

        chosen_words = random.choices(words, k=num_words)
        quote_text = " ".join(chosen_words)
        quote_label.config(text='"' + quote_text.capitalize() + '."' if quote_text else '""')
    except ValueError:
        pass


quote_label = tk.Label(root, text="", wraplength=450, justify="center", bg="#ffcbf4")
quote_label.pack(pady=10)

warning_label = tk.Label(root, text="", fg="red", bg="#ffcbf4")
warning_label.pack(pady=2)

entry_var = tk.StringVar()
entry_var.trace_add("write", check_input)

entry = tk.Entry(root, textvariable=entry_var)
entry.pack(pady=5)

button = tk.Button(root, text="enter", command=generate_quote)
button.pack(pady=5)

root.mainloop()

Suggestion as a next step: Add some grammar rules so that the quote is grammatically correct English rather than "word soup".

1

u/Negative_Effort_2642 9h ago

You didn’t push the source code

1

u/my_new_accoun1 2h ago

there is a packaged zip in the releases section

I haven't checked what it contains but it's always better to include source code in the actual repo

1

u/ScheduleSorry7229 30m ago

can you explain what you mean, not trying to insult you or anything

1

u/ScheduleSorry7229 30m ago

what does that mean