diff options
Diffstat (limited to 'ElementsActivity.py')
-rw-r--r-- | ElementsActivity.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/ElementsActivity.py b/ElementsActivity.py index 62bee1d..36f6f21 100644 --- a/ElementsActivity.py +++ b/ElementsActivity.py @@ -12,6 +12,9 @@ class ElementsActivity (activity.Activity): activity.Activity.__init__(self, handle) self.set_title('Elements') + act_root = self.get_activity_root() + path_data = os.path.join(act_root, "data") + self.file_name = os.path.join(path_data,"datos.js") # The XOCom object helps us communicate with the browser # This uses web/index.html as the default page to load self.xocom = XOCom("file://"+os.path.join(os.path.dirname(os.path.abspath(__file__)),"web/allelements.xml")) @@ -22,11 +25,11 @@ class ElementsActivity (activity.Activity): self.set_canvas( self.xocom.create_webview() ) - #self.read_file(os.path.join(os.path.dirname(os.path.abspath(__file__)),"datos.txt")) + self.read_file(self.file_name) def write_file(self, filename): - filename = os.path.join(os.path.dirname(os.path.abspath(__file__)),"web/datos.js") + print "Grabando", filename content = self.xocom.send_to_browser('write') if content: @@ -35,8 +38,12 @@ class ElementsActivity (activity.Activity): fh.close() def read_file(self, filename): - fh = open(filename, 'r') - content = fh.read() + print "Leyendo", filename + content = "textos = new Array();" + if os.path.exists(filename): + fh = open(filename, 'r') + content = fh.read() + print content def send_delayed_read(): self.xocom.send_to_browser('read', content) return False |