[Sugar-devel] opening a url with WebActivity

Erik Blankinship erikb at mediamods.com
Fri Aug 12 10:40:13 EDT 2011


I am trying to figure out how to open a URL in the browse activity from my
own python sugar activity.  What is the best way to do this?

I was hacking around on an xo running 860, sugar 84)

[1]

import webbrowser
webbrowser.open( "http;//google.com" )

This launches firefox in its own floating window (which was an interesting
thing to see in sugar, sort of like an easter egg).
Is it easy for a pythonista to change this to opening WebActivity?

[2]
After some chat on IRC, I was able to hobble this together:

bus = dbus.SessionBus()
proxy = bus.get_object('org.laptop.Shell', '/org/laptop/Shell')
path = dbus.Interface(proxy, 'org.laptop.Shell').GetBundlePath(
'org.laptop.WebActivity')
activity = ActivityBundle(path)
de_args = activityfactory.get_command(activity, None, None, "
http://google.com")
os.execvpe( de_args[0], de_args, activityfactory.get_environment(activity) )

This opens a new instance of browse to the requested URL.
But it skips the pulsating launch sequence, and seems to lock up the
activity which launched it.

If WebActivity is already running, is there a way to open a URL in that
instance?
If WebActivity is not already running, can it be launched normally (showing
the pulsating icon)?
How do I prevent locking up the activity which opened the URL?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20110812/c3b15264/attachment.html>


More information about the Sugar-devel mailing list