16/04/2017
# wavtoznd.py
# by
# Watt-Soft (Book)
# Anggota
# Sarman
import struct, zut, os, appuifw
import TopWindow,sys,e32
from graphics import*
sys.setdefaultencoding('utf-8')
mydir=os.path.dirname(appuifw.app.full_name())+'\\'
def put(x,p=u'e://',y=0):
global path
p = (y and appuifw.query(unicode("ÐÑÑÑ"), "text",unicode(p))) or p
p = p[-1] != '/' and p+'/' or p
fo=open(mydir+'dir',x and 'r' or 'w')
path = (x and fo.read() ) or fo.write(p) or p
fo.close()
return 1
os.path.exists(mydir+'dir') and put(1) or put(0)
app_lock = e32.Ao_lock()
z=zut.sound()
so=z.load_znd(mydir+'win.znd')
do=z.load_znd(mydir+'din.znd')
er=z.load_znd(mydir+'er.znd')
img=Image.new((176,208))
def handle_redraw(rect):
canvas.blit(img)
class Buf:
def __init__(self):
self.buf=[]
buf=Buf()
class Top:
def __init__(self):
self.win=TopWindow.TopWindow()
self.win.size = (170,40)
self.win.position = (3,40)
self.win.shadow = 2
self.win.corner_type = 'corner1'
self.top = Image.new((170,40))
self.t=0; self.p=1
self.vis()
def pause(self,x):
self.p=x
if self.p and self.t: self.win.show()
else: self.win.hide()
def vis(self):
self.top.rectangle((0,0,170,40),0,fill=0x007700)
self.top.rectangle((10,15,160,35),0,fill=0xffffff)
self.top.text((62,12),unicode('ÐÑогÑеÑÑ'),0xffffff)
self.win.add_image(self.top,(0,0))
self.pause(self.p)
def progress(self,p):
self.win.remove_image(self.top)
self.vis()
x=(159-11)*p/100+11
self.top.rectangle((11,16,x+2,20),fill=0x9999ff)
self.top.rectangle((11,20,x+2,34),fill=0x2222dd)
self.win.add_image(self.top, (0,0))
e32.ao_yield()
if p>98: self.win.hide();self.t=0
return 0
def note(self,text,x=1):
self.win.remove_image(self.top)
self.t=1; self.vis()
self.top.rectangle((0,0,170,40),0,fill=x and 0x007700 or 0xaa0000)
for t,y in zip(text,[13,25,37]):
self.top.text((84- img.measure_text(t, font=u'LatinBold12')[1]/2,y),unicode(t),0xffffff,u'LatinBold12')
self.win.add_image(self.top, (0,0))
x and z.play_znd(do) or not x and z.play_znd(er)
e32.ao_sleep(3)
self.win.hide(); self.t=0
top_w=Top()
appuifw.app.focus=top_w.pause
def format_w(f):
fo=open(mydir+'formatw','r')
format=fo.read()
fo.close()
format=eval(format)
top_w.note(['ФоÑмаÑ',format[f]+' ',' ÐеподдеÑживаеÑÑÑ'],0)
# ÑпÑавление
class Use:
def __init__(self,fm):
self.mar_r=0; self.mar_l=-1
self.xr=0; self.xl=175
self.key=0; self.pix_xr=0
self.pix_xl=0; self.trig=1
self.list=[]; self.un=0
self.name=fm.split('/')[-1][-20:]
self.fm=fm; self.open_s(fm)
self.func=lambda e,xt: ((e==63496 and (xt0)) and -1)
def trigger(self):
self.trig=~self.trig+2
self.key=0; self.linact()
def tobuf(self,c=0):
a=self.choice()
buf.buf=self.num[a[0]:a[1]]
if c:
self.undo(a[0],a[0],self.num[a[0]:a[1]])
self.num=self.num[:a[0]]+self.num[a[1]:]
self.graph(0)
tab.tab(self.name)
self.foot(); self.key=0
# ÐгÑаниÑиÑели
def line(self,e='xl',x=0):
if self.trig: e='xr'
x=self.func(self.key,self.__dict__[e])
self.__dict__[e]+=x
if self.xr == self.xl: self.__dict__[e]-=x; return
if self.__dict__['pix_'+e] :
[img.point((self.__dict__[e]-x,i),self.__dict__['pix_'+e][i][0]) for i in range(20,180)]
self.__dict__['pix_'+e]=[img.getpixel((self.__dict__[e],i)) for i in range(0,180)]
self.linact()
def linact(self):
n=self.trig and 'xr' or 'xl'
ne=self.trig and 'xl' or 'xr'
if (not self.trig and self.xr) or (self.trig and self.xl100 and 100 or vol0 and 00 and self.mem+1