[Tutor PyCZ] Canas.scale()
Pavel Kosina
geon na post.cz
Sobota Leden 13 19:49:35 CET 2007
Jakub Vojacek napsal(a):
> Ahoj
>
> dělám na jednom prográmku co využívá canvas a potřeboval bych občas
> oddáli obsah... na to by měla být funkce scale().
> Ale já nevím jak ji použít na oddálení. vždy se mi podařilio pouze
> přiblížit. děkuju
trochu upravený
http://mail.python.org/pipermail/python-bugs-list/1999-November/000302.html
(hledal jsem "tkinter canvas scale)
from Tkinter import
*
#
# Create
widgets
#
root =
Tk()
canvas = Canvas( root, width = 300, height = 300
)
canvas.pack()
canvas.create_rectangle( (-100,-100,100,100), outline = "#008000",
fill="#800000", width = 3 )
canvas.create_line( (-100,-100,100,100),fill="blue", width=3
)
canvas.create_line( (-100,100,100,-100),fill="blue", width=3
)
canvas.config( scrollregion = canvas.bbox( ALL )
)
#
# Zoom the canvas until it's bounds get toasted because they exceed
MAXINT
#
def TimerCB( canvas=canvas
):
old = canvas.bbox( ALL
)
canvas.scale( ALL, 0.0, 0.0, 0.5, 0.5
)
new = canvas.bbox( ALL
)
print "Old = %s, New = %s" % ( old, new
)
if new ==
None:
raise SystemError, "canvas's bbox is toast (exceeds signed
MAXINT)"
canvas.after( 300, TimerCB )
print "CANVAS ZOOM BLOW-UP
TEST:\n"
canvas.after( 1500, TimerCB
)
root.mainloop()
--
geon
Pavel Kosina
Další informace o konferenci Tutor