Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # multiselect checkbox
- import appuifw as A
- import graphics as G
- run=1
- def exit():
- global run
- run=0
- A.app.exit_key_handler=exit
- img=G.Image.new(G.sysinfo.display_pixels())
- class CSelect:
- def __init__(self,items=[]):
- self.cur=0
- self.items=items
- self.tmp=[]
- self.c = A.Canvas(redraw_callback=self.redraw)
- A.app.screen='full'
- A.app.body=self.c
- def redraw(self,rect):
- if img:
- self.c.blit(img)
- def down(self):
- self.cur+=1
- if self.cur>len(self.items)-1:
- self.cur=0
- def up(self):
- self.cur-=1
- if self.cur<0:
- self.cur=len(self.items)-1
- def select(self):
- if self.cur not in self.tmp:
- self.tmp.append(self.cur)
- else:
- self.tmp.remove(self.cur)
- def show(self):
- self.c.bind(63497,self.up)
- self.c.bind(63498,self.down)
- self.c.bind(63557,self.select)
- px,py,th=20,20,14
- while run:
- img.clear(0)
- for i in range(len(self.items)):
- tc=(0xffffff,0x00ff00)[i==self.cur]
- fc=(None,0x00ff00)[i in self.tmp]
- img.text((px,py+(i*th)),self.items[i],tc,'legend')
- img.rectangle((px-15,py+(i*th)-10,px-5,py+(i*th)),0xdadada)
- img.rectangle((px-14,py+(i*th)-9,px-6,py+(i*th)-1),fill=fc)
- img.text((px,160),u'Multiselect Test - Joe',0xdadada)
- img.text((px,180),u'Sel: %s' %repr(self.tmp),0xdadada)
- self.c.blit(img)
- A.e32.ao_sleep(1E-08)
- menu=[u'Item 1',u'Item 2',u'Item 3',u'Item 4',u'Item 5',u'Item 6']
- kk=CSelect(menu)
- kk.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement