Skip to main content

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

Project description

logo

forthebadge made-with-python
GitHub release PyPI version shields.io GitHub license PyPI pyversions Workflow Status Workflow Status
code style Codacy Badge code maintainability

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

To start, make sure you have CanvasPlus installed or cloned. You can do this with one of two methods.

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
Clone the latest stable Release
GitHub release
Screen Shot 2020-04-15 at 11 26 54 PM

Importing

It is advised that you do not import the entire module.

from CanvasPlus import CanvasPlus
CanvasPlus()
import CanvasPlus
CanvasPlus.CanvasPlus()

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

#set up canvas
root = Tk()
canvas = CanvasPlus(root, width=800, height=800, background = "white")
canvas.pack()
#create circle function
canvas.create_circle(300, 600, 100, fill = "black", outline = "green", width = 3)

#create rounded rectangle function
canvas.create_round_rectangle(
    400, 550, 500, 650, 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, 550, 200, 650, fill = "#f7a8c6", width = 0)
canvas.clone(rect)
rect = canvas.poly(rect)
canvas.rotate(rect, 150, 600, 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("This is CanvasPlus %s" % _canvasPlusVersion)

#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 = "By Luke-zhang-04", anchor = "nw"
)

#flip example
aPrime = canvas.create_polygon(500, 10, 500, 20, 550, 25, 600, 20, 600, 10, fill = "yellow", outline = "black")
a = canvas.clone(aPrime)
canvas.flip(a, m = .5, b = -200)

canvas.update()
canvas.mainloop()

demo

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.4.1.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

canvasplus-1.4.1-py3-none-any.whl (20.6 kB view details)

Uploaded Python 3

File details

Details for the file canvasplus-1.4.1.tar.gz.

File metadata

  • Download URL: canvasplus-1.4.1.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

File hashes

Hashes for canvasplus-1.4.1.tar.gz
Algorithm Hash digest
SHA256 d99f152d6e26ebe17972edca427bcdc8b5c659d54bd6f4457f006bc456ee6547
MD5 46345f9493e1779dd6d7aa852131a4c2
BLAKE2b-256 a8e41572e05782082a8608e5976269afce040dcce385f846f7aee5e71cb27bb2

See more details on using hashes here.

File details

Details for the file canvasplus-1.4.1-py3-none-any.whl.

File metadata

  • Download URL: canvasplus-1.4.1-py3-none-any.whl
  • Upload date:
  • Size: 20.6 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/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

File hashes

Hashes for canvasplus-1.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 52b7607546f41a27bf0ef0914e03483339a4d11e7983a56845b4ae17598a54e0
MD5 b2dc5cab9c8ff63b57c9e74cb7dd0cc7
BLAKE2b-256 212a9fb8e5ffe17d8f50f9a580bb5324c5b5c6c9b5f0f295699189b5fc83a5ae

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