Giter VIP home page Giter VIP logo

tkshapes's Introduction

Latest Version

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

Running the Demo

The demo.py can be downloaded by itself, or you can clone this repo and find it at the top level.

git clone https://github.com/bentlema/tkshapes.git

Assuming you've already activated your virtual environment and installed the tkapp and tkshapes modules within it (as shown above), you should now be able to run the demo.py:

./tkshapes/demo.py

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.

tkshapes's People

Contributors

bentlema avatar mbentley-2w avatar

Stargazers

Jeff Tsai avatar Neeraj Kanhere avatar Shams Kitz avatar

Watchers

 avatar  avatar

Forkers

zhiyix2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.