Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello ā I'm @olemoritz on Twitter.
[SOLVED!] Help with uncallable error
-
Please help with the uncallable error.
Thank's in advance!
Here's the code:
<pre><code>
#coding: utf-8
import random, motion
from scene import *
from PIL import Image
class Particle(object):
def init(self, wh):
self.w = wh.w
self.h = wh.h
self.x = random.randint(0, self.w)
self.y = random.randint(0, self.h)
self.vx = random.randint(-10, 20)
self.vy = random.randint(-10, 20)
self.colour = Color(random.random(), random.random(), random.random())def update(self): self.x += self.vx self.y += self.vy self.vx *= 0.98 self.vy *= 0.98 if self.x > self.w: self.x = self.w self.vx *= -1 if self.x < 0: self.x = 0 self.vx *= -1 if self.y > self.h: self.y = self.h self.vy *= -1 if self.y < 0: self.y = 0 self.vy *= -1 def draw(self): fill(*self.colour) rect(self.x, self.y, 8, 8)
class MyScene(Scene):
def setup(self):
self.particles = []
for p in xrange(200):
self.particles.append(Particle(self.size))def draw(self): background(0.00, 0.05, 0.20) for p in self.particles: p.update() p.draw() for t in self.touches.values(): for p in self.particles: tx, ty = t.location.x, t.location.y d = (p.x - tx)*(p.x - tx)+(p.y - ty)*(p.y - ty) d = sqrt(d) p.vx = p.vx - 5/d*(p.x-tx) p.vy = p.vy - 5/d*(p.y-ty) p.colour = Color(random.random(), random.random(), random.random()) s = 49 if self.size.w > 100 else 7 text('Welcome to\n Jitter Click\n\n\n', 'Futura', s, *self.bounds.center().as_tuple()) t = 100 if self.size.w > 100 else 7 text('\nš“', 'Futura', t, *self.bounds.center().as_tuple()) s = 27 if self.size.w > 100 else 7 text('\n\n\n\n\n\n\n\n\n\n\n\nBy: Adedayo Ogunnoiki', 'Futura', s, *self.bounds.center().as_tuple()) def touch_ended(self, touch): run(Help())
use_motion = True
class Help(Scene):
def setup(self):
self.particles = []
for p in xrange(200):
self.particles.append(Particle(self.size))def draw(self): background(0.00, 0.05, 0.20) for p in self.particles: p.update() p.draw() for t in self.touches.values(): for p in self.particles: tx, ty = t.location.x, t.location.y d = (p.x - tx)*(p.x - tx)+(p.y - ty)*(p.y - ty) d = sqrt(d) p.vx = p.vx - 5/d*(p.x-tx) p.vy = p.vy - 5/d*(p.y-ty) p.colour = Color(random.random(), random.random(), random.random()) s = 35 if self.size.w > 100 else 7 text('You will have 10\nseconds to click\nthe button as\nmany times as\nyou can. Then\nyour number of\nclicks and the\nspeed at which\nyou were clicking\nwill be displayed.', 'Futura', s, *self.bounds.center().as_tuple()) def touch_ended(self, touch): run(Help2())
class Help2(Scene):
def setup(self):
self.particles = []
for p in xrange(200):
self.particles.append(Particle(self.size))def draw(self): background(0.00, 0.05, 0.20) for p in self.particles: p.update() p.draw() for t in self.touches.values(): for p in self.particles: tx, ty = t.location.x, t.location.y d = (p.x - tx)*(p.x - tx)+(p.y - ty)*(p.y - ty) d = sqrt(d) p.vx = p.vx - 5/d*(p.x-tx) p.vy = p.vy - 5/d*(p.y-ty) p.colour = Color(random(), random(), random()) s = 45 if self.size.w > 100 else 7 text('Also, you can\nclick the ā\nat the top\nright of the\nscreen to exit.', 'Futura', s, *self.bounds.center().as_tuple()) def touch_ended(self, touch): run(JitterClick())
class JitterClick(Scene):
def setup(self):
self.button = Button(Rect(self.size.w/2-100, self.size.h/2-140, 200, 200))
self.button.background = Color(0,0,0)
self.button.stroke = Color(1,1,1)
self.button.action = self.points
img = Image.open('Red_Circle').transpose(Image.FLIP_LEFT_RIGHT)
self.clicks=0def points(self): self.clicks += 1 def draw(self): self.button.draw() no_tint() text("Clicks: ", x=self.size.w/2, y=self.size.h/4*3, font_size=64)
import time
from scene import *
from PIL import Image
clicks = 0
class JitterClick(Scene):
def init(self):
self.start_time = 0
self.finish_time = 0
def setup(self):
self.button = Button(Rect(self.size.w/2-100, self.size.h/2-140, 200, 200))
self.button.background = Color(0,0,0)
self.button.stroke = Color(0,0,0)
self.button.image = 'Red_Circle'
self.button.action = self.add_clicks
self.add_layer(self.button)def add_clicks( sender): global clicks clicks += 1 if clicks == 1: sender.start_time = time.time() def draw(self): background(0,0,0) self.button.background = Color(0,0,0) self.button.draw() text('Taps: %i' % clicks, x=self.size.w/2, y=self.size.h/3.8*3, font_size=57) if clicks == 100: self.finish_time = time.time() run(desp(clicks, self.finish_time - self.start_time))
class desp(Scene):
def init(self, xclicks, duration):
self.xclicks = xclicks
self.duration = duration
self.duration = "%.3f" % self.duration
self.speed = duration/xclicks
self.speed = "%.3f" % self.speeddef setup(self): self.show_instructions = True self.p_size = 64 if self.size.w > 700 else 32 def draw(self): background(0, 0, 0) text('\n\n\n\n\n\nIt took you \n{} seconds \nto tap {} \ntimes. You were\ntapping at \n{} taps a\nsecond.'.format(self.duration, self.xclicks, self.speed), x=self.size.w/2, y=self.size.h/3.8*3, font_size=42) def touch_ended(self, touch): pass
run(MyScene())
</code></pre>