Skip to main content

graphics.py-extra

http://img.shields.io/pypi/v/graphics.py-extra.svg https://img.shields.io/github/last-commit/yurihs/graphics_extra.svg

Esse pacote fornece mais formas para se desenhar com o pacote graphics.py.

Os objetos gráficos incluídos são:

  • RoundedRectangle (um retângulo com os cantos arredondados)

  • FreeText (desenhar texto sem limites sobre a fonte usada)

  • Triangle (triângulo de qualquer tipo: definido pelas medidas dos lados e ângulos)

Exemplos

Exemplo 1: Desenhar um retângulo com os cantos arredondados.

import graphics
from graphics_extra import RoundedRectangle

win = graphics.GraphWin('Exemplo do RoundedRectangle', 400, 300)

rect = RoundedRectangle(
    graphics.Point(50, 50),
    graphics.Point(350, 250),
    radius=100
)
rect.setFill('light sky blue')

rect.draw(win)

Exemplo 2: Mostrar texto com uma fonte qualquer.

import graphics
import tkinter.font
from graphics_extra import FreeText

win = graphics.GraphWin('Exemplo do FreeText', 400, 300)

open_sans_font = tkinter.font.Font(family='Open Sans', weight='normal', size=46)
txt = FreeText(graphics.Point(200, 150), 'Lorem ipsum', open_sans_font)

# txt.setAlignment('SW')  # esse é o padrão do FreeText
txt.setAlignment('CENTER')  # esse é o padrão do graphics.Text

# Mostrar o espaço (largura, altura) que o texto ocupará
print('Text width:', txt.getWidth(win))
print('Text height:', txt.getHeight(win))

txt.draw(win)

Exemplo 3: Desenhar um triânglo isósceles agudo.

import math
import graphics
from graphics_extra import Triangle

win = graphics.GraphWin('Exemplo do Triangle', 400, 300)

t = Triangle(
    graphics.Point(125, 200) , # Posição do vértice B
    angle_a=math.radians(55),  # Ângulo do vértice A (converter de graus para radianos)
    angle_b=math.radians(55),  # Ângulo do vértice B (converter de graus para radianos)
    side_c=150  # Comprimento do lado C
)
t.draw(win)

Metadata

Release files for graphics.py-extra 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for graphics.py-extra 0.2.0
File Size Uploaded
graphics.py-extra-0.2.0.tar.gz 6.1 kB Details

Release files / graphics.py-extra-0.2.0.tar.gz

Download URL graphics.py-extra-0.2.0.tar.gz
Size 6.1 kB
Tags Source
SHA-256 checksum
How to use checksums
6c3801ace7b5f3af92a83ce179938941d097457e359129da98090b8ded966a23
BLAKE2b-256 checksum
How to use checksums
1d433f2ebd8e6003284dc09767ba5b1b7c3cfd5237aab8430d1c58866566ad76
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.2.0 This release

1 release file

0.1.0

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page