Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Korakot Chaovavanich http://korakot.stumbleupon.com

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Random rectangle demo

A good short demo for pys60.
   1  
   2  # random rectangle
   3  # modify from http://mtg.lcc.gatech.edu/class/rectangles.py
   4  
   5  from appuifw import *
   6  import e32
   7  from random import randrange
   8  
   9  running = 1
  10  def quit():
  11  	global running
  12  	running = 0
  13  app.exit_key_handler = quit
  14  
  15  app.screen = 'large'
  16  app.body = canvas = Canvas()
  17  res_x, res_y = canvas.size
  18  
  19  while running:
  20  	x1 = randrange(res_x)
  21  	x2 = randrange(x1, res_x)
  22  	y1 = randrange(res_y)
  23  	y2 = randrange(y1, res_y)
  24  	color = randrange(0xffffff)
  25  	canvas.rectangle((x1, y1, x2, y2), fill=color)
  26  	e32.ao_yield()
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS