Skip to main content

Extra objects for the graphics.py package

Project description

graphics.py-extra

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)

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)

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

graphics.py-extra-0.0.5.tar.gz (4.3 kB view hashes)

Uploaded Source

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