Add all the A tasks

This commit is contained in:
Ingy döt Net 2013-04-10 14:58:50 -07:00
parent 2dd7375f96
commit 051504d65b
1608 changed files with 18584 additions and 0 deletions

View file

@ -0,0 +1,55 @@
import pygame, sys
from pygame.locals import *
pygame.init()
YSIZE = 40
XSIZE = 150
TEXT = "Hello World! "
FONTSIZE = 32
LEFT = False
RIGHT = True
DIR = RIGHT
TIMETICK = 180
TICK = USEREVENT + 2
TEXTBOX = pygame.Rect(10,10,XSIZE,YSIZE)
pygame.time.set_timer(TICK, TIMETICK)
window = pygame.display.set_mode((XSIZE, YSIZE))
pygame.display.set_caption("Animation")
font = pygame.font.SysFont(None, FONTSIZE)
screen = pygame.display.get_surface()
def rotate():
index = DIR and -1 or 1
global TEXT
TEXT = TEXT[index:]+TEXT[:index]
def click(position):
if TEXTBOX.collidepoint(position):
global DIR
DIR = not DIR
def draw():
surface = font.render(TEXT, True, (255,255,255), (0,0,0))
global TEXTBOX
TEXTBOX = screen.blit(surface, TEXTBOX)
def input(event):
if event.type == QUIT:
sys.exit(0)
elif event.type == MOUSEBUTTONDOWN:
click(event.pos)
elif event.type == TICK:
draw()
rotate()
while True:
input(pygame.event.wait())
pygame.display.flip()

View file

@ -0,0 +1,23 @@
import Tkinter as tki
def scroll_text(s, how_many):
return s[how_many:] + s[:how_many]
direction = 1
tk = tki.Tk()
var = tki.Variable(tk)
def mouse_handler(point):
global direction
direction *= -1
def timer_handler():
var.set(scroll_text(var.get(),direction))
tk.after(125, timer_handler)
var.set('Hello, World! ')
tki.Label(tk, textvariable=var).pack()
tk.bind("<Button-1>", mouse_handler)
tk.after(125, timer_handler)
tk.title('Python Animation')
tki.mainloop()