Tkinter Canvas Shapes
Note: This is a Python 3.6+ module.
The tkshapes module adds a GCanvas widget which can contain user-configurable shapes. The GCanvas widget supports the standard Tk canvas shapes, as well as some others useful in diagrams. (Not all implemented yet.)
- GObjects can be constructed from GItems
- GObjects are displayed on the GCanvas
- GObjects can be dragged around individually, or selected and dragged together
- GObjects can have GNodes
- GNodes can be connected by a GConnection (visualized by a GWire)
Controls
The GCanvas Keyboard and Mouse controls are as follows:
-
Control + MouseClickHold-and-Drag or Two-finger swipe to Pan the canvas
-
Control + MouseWheel or Control + Two-finger Vertical swipe to Zoom In/Out
-
Click-Drag a single shape to move it around on the canvas
-
Command + Click to toggle selection of a single shape
-
Click-Drag on the canvas to mark out a Selection Box
- Selected shapes can highlight themselves if configured to do so (default)
- Click-Drag one of the selected shapes to move them all together
- Click anywhere on the canvas to de-select all shapes
- Command + Click individual shapes to add/remove shapes from the selected set (toggle)
-
To make a connection between two "Connectable" shapes:
- Click and Hold on an "Output" Node of a shape (such as one of the Logic Gates in the Demo)
- Begin to Drag and a wire will appear
- Drag the wire to an "Input" Node of another shape and release to complete the connection
Installation
Create your Python 3.6+ virtual environment
python3.6 -m venv env
Activate your virtual env
source env/bin/activate
Install tkapp and tkshapes (The demo.py depends on the tkapp module as well.)
pip install tkapp tkshapes
Alpha - In-Development
This library is being developed so that I can use it to build a Digital Logic Simulator app. I wasn't able to find a Tkinter library that did what I need, so decided to try and write one from scratch.
At this time, the only documentation is this README, the code itself, as well as a demo.py which shows the basic usage.
I'm developing and testing ONLY on macOS.
Known Issues
-
when the Tkinter window is put in full-screen mode using the full-screen green dot button at the top left of the window, mouse position is incorrectly calculated. You'll notice that the calculated mouse position on the GCanvas is slightly off. This appears to be a Tkinter bug, but I'm not 100% sure. Instead of using full-screen mode, you may click Option-GreenDot to maximize the window to use the full screen without actually entering full-screen mode.
FIXED: this issue has been fixed with Python 3.7 releases. I've tested both the standard CPython and Anaconda distributions, and this issue is no longer present. It appears that "Fullscreen Mode" simply does a window maximize now, automatically accomplishing the workaround mentioned above.
Metadata
Release files for tkshapes 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tkshapes-0.0.4.tar.gz | 27.2 kB | Without provenance | Details for tkshapes-0.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tkshapes-0.0.4-py36-none-any.whl | Python 3.6 | none | any | Details for tkshapes-0.0.4-py36-none-any.whl |
Total release size: 77.6 kB
Release files / tkshapes-0.0.4.tar.gz
| Download URL | tkshapes-0.0.4.tar.gz |
|---|---|
| Size | 27.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
207a7375ed5e4f76a868c9612eb215a7e81c97201036e3577e988b3a7370c719
|
|
BLAKE2b-256 checksum How to use checksums |
caad9e02dee252680e55c96e3e5d6f8b43cc5e18a42b801b5817a3a953a3294b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
|
Release files / tkshapes-0.0.4-py36-none-any.whl
| Download URL | tkshapes-0.0.4-py36-none-any.whl |
|---|---|
| Size | 50.4 kB |
| Tags | Python 3.6 |
|
SHA-256 checksum How to use checksums |
74b67d3505c866a7589c1f64417a6a65b0128aff99b68382ebdc2c8e4c8c88f0
|
|
BLAKE2b-256 checksum How to use checksums |
674d6f8df1497a8d98b8fdc39b567f5f6534293451c5e08b00d9dd6da6872e6e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
|
Security for tkshapes 0.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.