def __init__(self, handle): activity.Activity.__init__(self, handle) self.set_title('SocialCalc') self._logger = logging.getLogger('OnePageWiki-Activity') # The XOCom object helps us communicate with the browser # This uses web/index.html as the default page to load self.xocom = XOCom(self.control_sending_text) #REMEMBER THAT I HAVE STILL TO SEND THE ARGUMENT IN THE XOCOM CLASS toolbox = ToolbarBox() activity_button = ActivityButton(self) toolbox.toolbar.insert(activity_button, 0) activity_button.show() title_entry = TitleEntry(self) toolbox.toolbar.insert(title_entry, -1) title_entry.show() separator = Gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbox.toolbar.insert(separator, -1) separator.show() stop_button = ShareButton(self) toolbox.toolbar.insert(stop_button, -1) stop_button.show() self.set_toolbar_box(toolbox) toolbox.show() stop_button = StopButton(self) toolbox.toolbar.insert(stop_button, -1) stop_button.show() self.set_toolbar_box(toolbox) toolbox.show() ##self.xocom.send_to_browser_localize(['initlocalize']) self.set_canvas( self.xocom.create_webview() ) self.hellotube = None # Shared session #REQUIRED self.initiating = False self.pservice = presenceservice.get_instance() owner = self.pservice.get_owner() self.owner = owner self.connect('shared', self._shared_cb) self.connect('joined', self._joined_cb) self.filename='' #ADDED SPECIFICALLY TO CALL WRITE AND READ METHODS self.content='' #calling to initialize strings in localization #should wait for init complete from browser GObject.timeout_add(4000, self.xocom.send_to_browser_localize,['initlocalize'])
def __init__(self, handle): activity.Activity.__init__(self, handle) self.set_title('MapStats') # The XOCom object helps us communicate with the browser # This uses web/index.html as the default page to load self.xocom = XOCom() toolbox = activity.ActivityToolbox(self) self.set_toolbox(toolbox) toolbox.show() self.set_canvas(self.xocom.create_webview())
def __init__(self, handle): 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")) toolbox = activity.ActivityToolbox(self) self.set_toolbox(toolbox) toolbox.show() self.set_canvas(self.xocom.create_webview()) self.read_file(self.file_name)
import os import gtk import time import hulahop hulahop.startup(os.path.expanduser('~/.test-hulahop')) from XOCom import XOCom # The XOCom object helps us communicate with the browser uri = "file:///home/olpc/src/socialcalc-xocom/web/index.html" xocom = XOCom(uri) # This is just a simple way to trigger events from python for testing # Handler for keypresses in the GTK Application # r - call the javascript 'read' hook with a dummy string # w - call the javascript 'write' hook and print out the result def keypress(window, event): key = event.string if key == 'w': result = xocom.send_to_browser('write') if result: print "Result from browser - '%s'"%result else: print "No data received in the browser's response" if key == 'r': message = "I am a monkey - %s"%time.time() print "Sending '%s'"%message result = xocom.send_to_browser('read', message) if key == 'q': quit(None)