python for Symbian s60:短信搜索程序(smsearch)
2010-08-30 00:08:00 来源:WEB开发网if self.results:
# order following unix time and remove it after
lst.sort(reverse=True)
lst = map(lambda x: x[1:],lst)
self.body = Listbox(lst,self.lst_cbk)
app.screen = 'normal' # avoid wrong screen redraw
self.refresh()
else:
note(u"No results for " + self.terms,"info")
def get_pattern(self):
pattern = query(u"Search terms:", "text", self.terms)
if pattern is not None:
if pattern:
pattern = pattern.strip()
self.terms = pattern
self.search(pattern)
if __name__ == "__main__":
sms = SMSearch()
sms.run()
from window import *
from appuifw import *
import inbox
import time
class ShowSMS(Dialog):
def __init__(self,cbk,title,msg):
Dialog.__init__(self,cbk,title,Text(msg))
class SMSearch(Application):
def __init__(self):
self.dlg = None
self.results = [u""]
self.terms = u""
body = Canvas()
menu = [(u"Search", self.get_pattern),
(u"About", self.about),
(u"Exit", self.close_app)]
Application.__init__(self,u"SMSearch",body,menu)
def about(self):
note( u"SMSearch. Marcelo Barros de Almeida marcelobarrosalmeida@gmail.com", "info" )
def lst_cbk(self):
idx = self.body.current()
(sms_id,txt,tmr,addr,fn) = self.results[idx]
msg = u"Address: " + addr +
u" Date: " + tmr +
u" Box: " + fn +
u" " + txt
self.dlg = ShowSMS(lambda:self.refresh(),unicode(sms_id),msg)
self.dlg.run()
def bmh_search(self, pattern, text):
# http://code.activestate.com/recipes/117223/
m = len(pattern)
n = len(text)
更多精彩
赞助商链接