Skip to content

A small, polished Python desktop GUI that generates random programming jokes using Tkinter and the pyjokes library. Built as a focused example of event-driven UI design, third-party integration, and clean, readable Python code in a single-file application.

Notifications You must be signed in to change notification settings

FrankJamison/2026PythonJokes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Python Joke Generator (Desktop GUI)

I built this project as a small, polished Python desktop application that generates a random programming joke at the click of a button. It’s intentionally simple in scope so the design, code clarity, and user experience are easy to evaluate quickly.

If you’re an employer/recruiter: this is a compact example of my ability to ship a working GUI app, integrate a third‑party dependency, and document my design and development decisions.

If you’re a developer: everything is straightforward and hackable—one file, minimal dependencies, and clear extension points.

At a glance

  • Type: Desktop GUI
  • Language: Python
  • UI framework: Tkinter
  • Dependency: pyjokes (joke source)
  • Entry point: pythonjokegenerator.py

What the app does

  • Launches a small window titled “Python Joke Generator”.
  • Displays a friendly starter prompt.
  • On Generate Joke, fetches a random programming joke via pyjokes.get_joke().
  • Updates the UI in-place (no extra windows, no console interaction).

Design goals (why I built it this way)

  • Fast to run and review: one file, no framework overhead.
  • Clean event-driven design: the UI reacts to a button click.
  • Readable code over clever code: small functions, obvious naming.
  • User-friendly presentation: centered text + wrapping to fit the window.

Architecture and implementation details

This project is intentionally a single-file application to keep the logic transparent.

Key components

  • Tk root window (root)

    • Sets the title to "Python Joke Generator".
    • Sets a fixed initial window size with root.geometry("400x200").
  • Joke display (joke_label)

    • Uses wraplength=380 so jokes don’t run off-screen.
    • Uses justify="center" for an approachable, poster-style layout.
    • Starts with: “Click the button to generate a joke!”
  • Action button (generate_button)

    • Uses Tkinter’s command= binding to connect the button click to application logic.

Event-driven flow

  1. The program creates the window and widgets.
  2. root.mainloop() starts the Tkinter event loop.
  3. When the user clicks Generate Joke, Tkinter invokes generate_joke().
  4. generate_joke() calls pyjokes.get_joke() and updates the label via joke_label.config(text=joke).

State management

The “state” of the app is the currently displayed joke text in joke_label. For this scale, storing state directly in the widget keeps the implementation small and understandable.

Dependency choice: pyjokes

I chose pyjokes because it provides a simple, deterministic API (get_joke) that’s perfect for demonstrating third-party integration without introducing a heavy web stack.

Tradeoffs and how I’d evolve it

This version favors clarity and minimalism. If I expanded it, I would likely:

  • Wrap the UI in a small App class to avoid relying on module-level variables.
  • Add basic error handling (try/except) around joke retrieval.
  • Add options like “joke category,” “copy to clipboard,” and “history.”

Project structure

2026PythonJokes/
  pythonjokegenerator.py
  README.md

Getting started

Prerequisites

  • Python 3.x
  • Tkinter (typically included with Python on Windows/macOS)
  • pyjokes

Set up (recommended: virtual environment)

Windows (PowerShell):

python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install pyjokes

macOS / Linux:

python3 -m venv .venv
source .venv/bin/activate
pip install pyjokes

Run

python pythonjokegenerator.py

Quality considerations

UX

  • Low friction: one button, immediate feedback.
  • Readable layout: centered text + wrapping tuned to the window width.
  • Responsive UI: relies on Tkinter’s event loop (no blocking loops).

Maintainability

  • Minimal surface area: one dependency and one file.
  • Simple separation of concerns: UI widgets are created once; joke generation happens in generate_joke().

Portability

  • Tkinter is widely available.
  • The app should run anywhere Python + Tkinter are available.

Troubleshooting

  • ModuleNotFoundError: No module named 'pyjokes'

    • Install it in the same environment you run: pip install pyjokes.
  • Tkinter missing (common on some Linux distros)

    • Debian/Ubuntu: sudo apt-get install python3-tk

Roadmap / improvement ideas

  • Add joke category/language selection (if supported by the pyjokes API).
  • Add Copy button (clipboard integration).
  • Add history (keep last N jokes).
  • Add keyboard shortcuts (e.g., Enter to generate).
  • Add basic tests by isolating joke selection behind an interface and mocking the provider.
  • Add packaging instructions (e.g., PyInstaller) for distributing an .exe.

About me

I’m [Your Name]. I’m building a portfolio of small, well-documented projects that demonstrate:

  • practical Python skills,
  • good engineering habits (clarity, simplicity, reproducibility), and
  • a focus on user experience—even in small apps.

If you’d like, I can tailor this README to your specific role targets (e.g., junior SWE, automation, data, QA) and add a “Why this matters” section aligned to that job family.

About

A small, polished Python desktop GUI that generates random programming jokes using Tkinter and the pyjokes library. Built as a focused example of event-driven UI design, third-party integration, and clean, readable Python code in a single-file application.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages