Мое первая работа с canvas. Проблема: когда self.state=='game' при нажатии в области 315, 0 (левый верхний угол) 315, 640 (правый нижний угол) скрипт завершается и закрывает консоль(все пишу и тестю на 5228)
Также пытаюсь нарисовать эллипс но ничего не рисуется. Может кто-нибуть подсказать где собака зарыта?
Вот код:
import sys
import e32
from appuifw import *
from graphics import *
from key_codes import *

app_path=app.full_name()[0]+u':\\data\\python\\'


class Main:


def __init__(self):
#a=touch_enabled()
#note(unicode(a))
self.state='mainmenu'
app.screen='full'
app.directional_pad=False
app.orientation='portrait'
self.splash=Image.open(app_path+'wait.png')
self.img_2=Image.open(app_path+'button.jpg')
self.img_3=Image.open(app_path+'trava.jpg')
self.canvas=Canvas(redraw_callback=self.redraw)
app.body=self.canvas
self.old_move=[]
#self.canvas.bind(EButton1Down,self.init_game,((0,0),(360,640)))
self.old_move.append(10)
self.old_move.append(20)
self.bindkey()
def bindkey(self):
#note(u"bindkey ok")
self.canvas.bind(EButton1Down, self.empty((0,0),(360,640)))
self.canvas.bind(EButton1Down, None)
if self.state=='mainmenu':
self.canvas.bind(EButton1Down,self.init_game,((40,40),(191,101)))
self.canvas.bind(EButton1Down,self.exit,((100,220),(170,290)))
if self.state=='loading':
#note(u"bind loading")
self.canvas.bind(EButton1Down, self.exit,((0,0),(360,640)))
if self.state=='game':
#note(u"find state game")
#self.canvas.bind(EButton1Down, None,((0,0),(360,640)))
self.canvas.bind(EButton1Down, self.exit,((330,610),(360,640)))
#note(u"bind for exit")
self.canvas.bind(EButton1Down,self.action,((0,0),(330,610)))
#note(u"game binded")
if self.state=='action':
#self.canvas.bind(EButton1Down, self.move, (()()))
pass
self.redraw(rect=self.canvas.size)
def redraw(self,rect):
if self.state=='mainmenu':
self.canvas.blit(self.splash)
self.canvas.blit(self.img_2, target=(40,40))
self.canvas.blit(self.img_3, target=(100,220))
if self.state=='loading': self.canvas.blit(self.loading_img)
#self.canvas.blit(self.splash)
if self.state=='game':
self.canvas.blit(self.local_map)
if self.state =='action':
#note(u"redraw action")
self.canvas.blit(self.local_map)
self.canvas.blit(self.actmenu_img, target=(270,0))
def init_game(self, event):
#note(u"saces"+unicode(event))
self.state='loading'
self.loading_img=Image.open(app_path+'load.jpg')
self.bindkey()
#note(u"before game")

self.game()
def game(self):
self.local_map= Image.open(app_path+'big.jpg')
self.buf_img=self.local_map
#note(u"load img")
self.state='game'
self.local_map.text((self.old_move[0],self.old_move[1]), u'@', fill=0)
#note(u"before bind game")
self.bindkey()
self.redraw(rect=self.canvas.size)
def action(self, event):
buf1=self.old_move[0]+5- event[0]
buf2=self.old_move[1]-4-event[1]
buf1=buf1/5
buf2=buf2/4
#note(unicode(buf1)+u" "+unicode(buf2))
#self.state='action'
#note(u"action"+unicode(event))
b1=self.old_move[0]-(buf1*5)
b2=self.old_move[1]-8- (buf2*4)
note(unicode(b1)+u" "+unicode(b2))
self.local_map.ellipse((100,100,110,92), outline=0,fill=0, width= 2)
self.local_map.point((110,110),wigth=10, outline=0)
self.move=event
#self.actmenu_img=Image.open(app_path+'actmenu.jpg')
#note(u"load actmenu")
#self.local_map.blit(self.actmenu_img, target=)
#note(unicode(self.canvas.size))
self.redraw(rect=self.canvas.size)
#self.bindkey()
def empty(self, event, mod):
pass

def exit(self, event):
#self.lock=e32.Ao_lock()
lock.signal()
os.abort()
lock=e32.Ao_lock()

app.exit_key_handler=lock.signal
a=Main()
lock.wait()