jamiesun 发表于 2013-1-28 19:30:07

搭建python for s60开发环境(含模拟器)

目标平台: s60 第三版
python for s60版本:1.9.4,这个版本已支持python2.5.x

需要准备的:

1,ActivePerl-5.6.1.638-MSWin32-x86.msi,从http://www.activestate.com/下载
2,S60-SDK-200634-3.1-Cpp-f.1090b.zip从http://www.forum.nokia.com/下载
3,Python_1.9.4.sis,PythonScriptShell_1.9.4_3rdEd.sis,PythonForS60_1.9.4_Setup.exe,Python_1.9.4_SDK_3rdEd_with_OpenC.zip 从https://garage.maemo.org/frs/?group_id=854下载

pc端安装

首先安装ActivePerl-5.6.1.638-MSWin32-x86.msi,按默认next直到完成

接着解压安装S60-SDK-200634-3.1-Cpp-f.1090b.zip,(试用22天,22天后需要一个序列号,注册一个nokia forum帐号,免费获得)安装完成后,C盘有两个目录C:\Symbian和C:\Nokia

解压Python_1.9.4_SDK_3rdEd_with_OpenC.zip,拷贝Epoc32目录至C:\Symbian\9.2\S60_3rd_FP1\Epoc32

安装PythonForS60_1.9.4_Setup.exe,安装后会有一个图形界面工具,可以将py脚本转换为sis

运行模拟器C:\Symbian\9.2\S60_3rd_FP1\Epoc32\Release\Winscw\Udeb\Epoc.exe 进入应用程序管理即可进行测试,python脚本存放路径C:\Symbian\9.2\S60_3rd_FP1\Epoc32\winscw\c\python

(注意,在模拟器上安装sis受限)

手机安装

首先您需要一个蓝牙或数据线

安装Python_1.9.4.sis,PythonScriptShell_1.9.4_3rdEd.sis即可,在应用程序目录中有个PythonScriptShell图标,在手机存储器下会有一个python目录,这是你的脚本存放的位置

上传您的脚本,用PythonScriptShell进行测试



例子:

import osimport appuifwimport e32import dir_iterclass Filebrowser:    def __init__(self):      self.script_lock = e32.Ao_lock()      self.dir_stack = []      self.current_dir = dir_iter.Directory_iter(e32.drive_list())    def run(self):      from key_codes import EKeyLeftArrow      entries = self.current_dir.list_repr()      if not self.current_dir.at_root:            entries.insert(0, (u"..", u""))      self.lb = appuifw.Listbox(entries, self.lbox_observe)      self.lb.bind(EKeyLeftArrow, lambda: self.lbox_observe(0))      old_title = appuifw.app.title      self.refresh()      self.script_lock.wait()      appuifw.app.title = old_title      appuifw.app.body = None      self.lb = None    def refresh(self):      appuifw.app.title = u"File browser"      appuifw.app.menu = []      appuifw.app.exit_key_handler = self.exit_key_handler      appuifw.app.body = self.lb    def do_exit(self):      self.exit_key_handler()    def exit_key_handler(self):      appuifw.app.exit_key_handler = None      self.script_lock.signal()    def lbox_observe(self, ind = None):      if not ind == None:            index = ind      else:            index = self.lb.current()      focused_item = 0      if self.current_dir.at_root:            self.dir_stack.append(index)            self.current_dir.add(index)      elif index == 0:                              # ".." selected            focused_item = self.dir_stack.pop()            self.current_dir.pop()      elif os.path.isdir(self.current_dir.entry(index-1)):            self.dir_stack.append(index)            self.current_dir.add(index-1)      else:            item = self.current_dir.entry(index-1)            if os.path.splitext(item) == '.py':                i = appuifw.popup_menu()            else:                i = appuifw.popup_menu()            if i == 0:                if os.path.splitext(item).lower() == u'.py':                  execfile(item, globals())                  self.refresh()                  #appuifw.Content_handler().open_standalone(item)                else:                  try:                        appuifw.Content_handler().open(item)                  except:                        import sys                        type, value = sys.exc_info() [:2]                        appuifw.note(unicode(str(type)+'\n'+str(value)), "info")                return            elif i == 1:                os.remove(item)                focused_item = index - 1      entries = self.current_dir.list_repr()      if not self.current_dir.at_root:            entries.insert(0, (u"..", u""))      self.lb.set_list(entries, focused_item)if __name__ == '__main__':    Filebrowser().run()
页: [1]
查看完整版本: 搭建python for s60开发环境(含模拟器)