Code:
class GUI:
def __init__(self):
global app_lock2
self.wall=Image.open('e:\\GeM\\images\\wall.jpg')
self.tab_prev_message = u''
self.tab_description = u''
app_lock2 = e32.Ao_lock()
#this function gets an string, and prepares an image cutting the string in pieces to fit on the screen
def prepare_text(self, img, text, col=10, chars=40, colour=(255,255,255), space=20):
while len(text) > chars:
#I look for the furthest space in the first 40 characters
position2 = 0
position = 0
while (position2 < chars):
if position2 == -1:
break
position = position2
position2 = text.find(' ',position+1)
img.text((col,self.row), u"%s" %text[0:position],colour)
self.row += space
#I update the text to print with the rest of the string. We skip the space " " (position+1)
text = text[position+1:len(text)]
if len(text) > 0: #the last line needs to be printed directly
img.text((col,self.row), u"%s" %text,colour)
self.row += space
#The text has been splitet already
return img
def print_feedback(self):
global img2, canvas2
self.setRow(20)
img2=Image.new((screenSize[0],screenSize[1]))
img2.clear((0,0,0))
self.setRow(40)
img2=self.prepare_text(img2, self.tab_prev_message)
# define your redraw function (still belonging to app 3)
def handle_redraw(rect):
global img2, canvas2
canvas2.blit(img2)
# define the canvas, include the redraw callback function
canvas2 =appuifw.Canvas(event_callback=None, redraw_callback=handle_redraw)
appuifw.app.body = canvas2
e32.ao_sleep(2)
def exit_handler2():
global app_lock2
app_lock2.signal()
print_activity_description = appuifw.Listbox([u"Stefan", u"Holger", u"Emil", u"Ludger"], exit_handler2)
def handle_tab(self, index):
if index == 0:
appuifw.app.body = self.print_feedback()
if index == 1:
appuifw.app.body = self.print_description
def createTabs(self, titles,tabs_menu):
global app_lock2
appuifw.app.screen='normal'
appuifw.app.set_tabs(titles,self.handle_tab)
appuifw.app.body = self.print_feedback()
app_lock2.wait()
audio.say('exiting createTabs')