Skip to main content

Improved Canvas widget for tkinter with more functionality to display graphical elements like lines or text.

Project description

Canvas Plus

V1.1.1

forthebadge made-with-python PyPI version shields.io GitHub release GitHub license PyPI pyversions

An improved Canvas widget for tkinter with more functionality to display graphical elements like lines or text.

Tkinter's Canvas widget has some limitations which are adressed in this package.

Simmilar to the default tkinter Canvas widget, e.g canvas.create_rectangle, other canvas objects can be created.

Availability

Option 1: Pip

Pip install this package

pip install CanvasPlus

Option 2: Github

Download a zip file containing all files.

git clone https://github.com/Luke-zhang-04/CanvasPlus.git

or
Screen Shot 2020-03-31 at 2 48 23 PM

Usage

Usage is very simple, especially for those with experience using tkinter canvas.

For complete documentation, head over the the wiki

Example:

#Imports
from CanvasPlus import CanvasPlus
from tkinter import Tk, StringVar, DoubleVar
import math

#set up canvas
root = Tk()
canvas = CanvasPlus(root, width=800, height=800, background = "white")
canvas.pack()

#create circle function
canvas.create_circle(300, 300, 100, fill = "black", outline = "green", width = 3)

#create rounded rectangle function
canvas.create_round_rectangle(
    400, 400, 500, 500, radius = 75, fill = "blue", outline = "orange", width = 5
)   

#create arrow function and rotate it to by 310 degrees clockwise
arrow = canvas.create_arrow(600, 600, 50, 50, 150, 20, fill = "grey", outline = "black")
canvas.rotate(arrow, 600, 600, 310, unit="deg")

#create a rectangle and convert it to a polygon; then rotate it by pi/4 radians (45 degrees)
rect = canvas.create_rectangle(100, 100, 200, 200, fill = "#f7a8c6", width = 0)
rect = canvas.poly(rect)
canvas.rotate(rect, 150, 150, math.pi/4)

#create an entry and set it's default value
content = StringVar()
canvas.create_entry(0, 0, anchor = "nw", textvariable = content, fg = "blue", bg = "gold")
content.set("a default value")

#create button to print the value in the previously cretaed entry
canvas.create_button(
    5, 25, anchor = "nw", text = "button", width = 50, highlightbackground = "red",
    command = lambda e = content: print(e.get())
)

#create checkbutton and toggle it
_, checkbutton = canvas.create_checkbutton(
    5, 50, anchor = "nw", bg = "brown", fg = "white", text = "My Checkbutton"
)
checkbutton.toggle()

#create a label
canvas.create_label(
    5, 75, font = ("Times", "24"), fg = "black", bg = "green", text = "Hello World!", anchor = "nw"
)

#create a scale
canvas.create_scale(
    5, 100, anchor = "nw", bg = "yellow", activebackground = "gold", from_ = 0, to = 100
)

canvas.update()
canvas.mainloop()

Screen Shot 2020-03-31 at 2 44 02 PM

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

CanvasPlus-1.1.1.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

CanvasPlus-1.1.1-py3-none-any.whl (18.8 kB view details)

Uploaded Python 3

File details

Details for the file CanvasPlus-1.1.1.tar.gz.

File metadata

  • Download URL: CanvasPlus-1.1.1.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.7.6

File hashes

Hashes for CanvasPlus-1.1.1.tar.gz
Algorithm Hash digest
SHA256 f46d11fdcb01e9795ff473da80262e8a53c49f1992f34490300b6892ab8d6d8a
MD5 47cd7b5acfce8179ae133584d3c424b6
BLAKE2b-256 baa1314ae3dc9e33b186bb88864ce36232225fdbc41b91b6304f871609212998

See more details on using hashes here.

File details

Details for the file CanvasPlus-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: CanvasPlus-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 18.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.7.6

File hashes

Hashes for CanvasPlus-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 31353268cf92f5efb531fefb8757bae60501288bf8eab19d146814026122bf2c
MD5 d46f3e3b5acb1aaa68b164f92479d6b7
BLAKE2b-256 324d436b380c35a36b722a81aabbbfe6f5a0c02b2a800d1a630de67b4feaf042

See more details on using hashes here.

Supported by

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