Skip to main content

simple yet all you need for protyping

Project description

pysimpledraw

pysimpledraw is a simple drawing application built with Python, using FreeSimpleGUI for the graphical user interface and tkinter for canvas operations. It allows users to create and manipulate basic shapes, add text, import images, and perform common drawing operations.

Why pysimpledraw?

pysimpledraw aims to provide a lightweight and easy-to-use drawing tool for quick sketches, annotations, or simple diagrams. It serves as a demonstration of how to integrate FreeSimpleGUI with tkinter for creating interactive graphical applications.

Features

  • Drawing Tools: Rectangle, Circle, Line, Freehand, Triangle, Diamond.
  • Text Tool: Add and edit text on the canvas.
  • Color Palette: Predefined colors (Black, Red, Green) and a custom color chooser.
  • Line Thickness: Thin and Thick options.
  • Eraser: Remove objects from the canvas.
  • Object Manipulation:
    • Select and move objects.
    • Delete selected objects.
    • Resize text (Small, Medium, Large via context menu).
    • Resize imported images (via context menu with preset ratios).
  • Image Import:
    • Import an image as a background.
    • Import pictures as draggable and resizable objects.
  • Canvas Operations:
    • Clear All: Resets the canvas.
    • Undo/Redo: Revert and reapply actions.
    • Save: Save the current canvas content as an image (e.g., PNG).
    • Pan: Right-click and drag on empty canvas space.
  • Context Menus:
    • Middle-click on text objects for size options.
    • Middle-click on image objects for resize options.
  • Keyboard Shortcuts: Quick access to tools and actions.

Installation

  1. Clone the repository (if applicable):
    git clone <your-repository-link>
    cd pysimpledraw
    
  2. Ensure Python is installed. (Python 3.6+ recommended)
  3. Install dependencies: The application relies on FreeSimpleGUI, Pillow (PIL), and pyperclip. You can install them using pip:
    pip install FreeSimpleGUI Pillow pyperclip
    
    Or, if a requirements.txt file is provided:
    pip install -r requirements.txt
    
    (Note: A pyproject.toml is present, which might be used with tools like Poetry or Hatch for dependency management. If so, follow their respective installation procedures.)

Usage

As a Standalone Script

Navigate to the directory containing main.py (e.g., pysimpledraw) and run:

python main.py

As a Package (using -m)

If pysimpledraw is structured as a runnable package (e.g., with an __main__.py or if main.py is intended to be run this way), you might be able to run it from the parent directory (pysimpledraw):

python -m pysimpledraw.main

(This assumes pysimpledraw is in your Python path or you are in the pysimpledraw directory which contains pysimpledraw.)

GUI Features and Operations

The application window is divided into sections: Instructions, Tools, and the Canvas.

Instructions Panel

  • Mouse:
    • Left Button: Draw shapes or add text (double-click).
    • Middle Button: Access context menus for text (size) or images (resize).
    • Right Button: Select objects, move selected objects, or pan the canvas (if clicking on empty space).
  • Double Click:
    • On an existing text object: Edit the text.
    • On an empty area: Place new text.
  • Shortcuts: See the "Keyboard Shortcuts" section below.

Tools Panel

Shape Tools:

  • r ectangle: Selects the rectangle drawing tool.
  • c ircle: Selects the circle drawing tool.
  • t line: Selects the line drawing tool.
  • f ree: Selects the freehand drawing tool.
  • T riangle: Selects the triangle drawing tool.
  • d iamond: Selects the diamond drawing tool.
  • e rase: Selects the eraser tool (click on an object to delete it).

Color Tools:

  • Black, Red, Green: Set the current drawing color.
  • ... (Custom Color): Opens a color chooser dialog.

Thickness Tools:

  • 1 Thin: Sets line thickness to thin.
  • 2 Thick: Sets line thickness to thick.

Action Buttons:

  • Clear All: Clears all drawings from the canvas.
  • Undo: Reverts the last action.
  • Redo: Reapplies the last undone action.
  • Save: Opens a dialog to save the canvas content as an image file.
  • Import Background: Imports an image to set as the canvas background.
  • Import Picture: Imports an image as a movable and resizable object on the canvas.

Canvas

  • The main drawing area.
  • Supports panning by right-clicking and dragging on an empty area.
  • Objects can be selected by right-clicking on them. Multiple objects can be selected by right-clicking and dragging a selection box (though this feature might depend on the exact implementation details for multi-select).

Keyboard Shortcuts

The application supports the following keyboard shortcuts:

  • Shape Selection:
    • r: Rectangle
    • c: Circle
    • t: Line
    • f: Freehand
    • T (Shift + t): Triangle
    • d: Diamond
    • e: Eraser
  • Color Selection:
    • B (Shift + b): Black
    • R (Shift + r): Red
    • G (Shift + g): Green
  • Thickness Selection:
    • 1: Thin
    • 2: Thick
  • Object Deletion:
    • Delete: Deletes the currently selected object(s).

Contributing

Found a bug or have a feature request? Please open an issue on the GitHub repository.

GitHub Repository: [https://github.com/fxyzbtc/pysimpledraw]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pysimpledraw-0.1.0.tar.gz (20.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pysimpledraw-0.1.0-py3-none-any.whl (19.2 kB view details)

Uploaded Python 3

File details

Details for the file pysimpledraw-0.1.0.tar.gz.

File metadata

  • Download URL: pysimpledraw-0.1.0.tar.gz
  • Upload date:
  • Size: 20.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.25

File hashes

Hashes for pysimpledraw-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bfdd84b6a142d1b1070a0772ff365dc78ee451994974f6997babeada99da576a
MD5 e1707ae30c9c6d11d5d0201babc1c5ef
BLAKE2b-256 9cd3e8bb1725123fbb25df217f832e9064077a0028282a86e83aadb9eb08cc2f

See more details on using hashes here.

File details

Details for the file pysimpledraw-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pysimpledraw-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fa29c147d01bd9cf401f030e2088b397503c011ec05d6668d8a4a009a33ea31a
MD5 2fc035074928a486f2864e61b274fc7a
BLAKE2b-256 2b907e82c7e4c5a82b932a9c6489ccb0d966da0fc3cdbbbf6d221e7c396196c3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page