Code:
import os
import appuifw
import e32
import dir_iter
class 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)[1] == '.py':
i = appuifw.popup_menu([u"execfile()", u"Delete"])
else:
i = appuifw.app.menu = [(u"Send",Send(item)]
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)
def Send(item):
from socket import *
import appuifw
import e32
addr,services=bt_obex_discover()
print "Discovered: %s, %s"%(addr,services)
if len(services)>0:
choices=services.keys()
choices.sort()
choice=appuifw.popup_menu([unicode(services[x])+": "+x
for x in choices],u'Choose port:')
port=services[choices[choice]]
else:
port=services[services.keys()[0]]
address=(addr,port)
#print "Sending file %s to host %s port %s"%(send_path, address[0], address[1])
bt_obex_send_file(address[0], address[1], item)
print "File sent."
if __name__ == '__main__':
Filebrowser().run()
I wish that it is ok right now am really very sorry for that
about the problem when executing this code said that socket.error
2,'No such file or directory')
and the file didnot sent
thank you very much and sorry for annoying