<span class="Apple-style-span" style="font-family: arial, sans-serif; background-color: rgb(255, 255, 255); ">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?<br>
<br><div>I was hacking around on an xo running 860, sugar 84)<br><div><br><div>[1]</div><div><br><div><font face="'courier new', monospace">import webbrowser</font></div><div><font face="'courier new', monospace">webbrowser.open( "http;//<a href="http://google.com/" target="_blank" style="color: rgb(0, 0, 204); ">google.com</a>" )</font><br>
<br></div><div>This launches firefox in its own floating window (which was an interesting thing to see in sugar, sort of like an easter egg). </div><div>Is it easy for a pythonista to change this to opening WebActivity?</div>
<div><br></div><div>[2]</div><div>After some chat on IRC, I was able to hobble this together:<br><br><blockquote style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 40px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">
<font face="'courier new', monospace">bus = dbus.SessionBus()<br>proxy = bus.get_object('org.laptop.Shell', '/org/laptop/Shell')<br>path = dbus.Interface(proxy, 'org.laptop.Shell').GetBundlePath( 'org.laptop.WebActivity')<br>
activity = ActivityBundle(path)<br>de_args = activityfactory.get_command(activity, None, None, "<a href="http://google.com/" target="_blank" style="color: rgb(0, 0, 204); ">http://google.com</a>")<br>os.execvpe( de_args[0], de_args, activityfactory.get_environment(activity) )</font><br>
<br></blockquote>This opens a new instance of browse to the requested URL.</div><div>But it skips the pulsating launch sequence, and seems to lock up the activity which launched it.</div></div><div><br></div><div>If WebActivity is already running, is there a way to open a URL in that instance?</div>
</div></div></span><span class="Apple-style-span" style="font-family: arial, sans-serif; background-color: rgb(255, 255, 255); ">If WebActivity is not already running, can it be launched normally (showing the pulsating icon)?</span><span class="Apple-style-span" style="font-family: arial, sans-serif; background-color: rgb(255, 255, 255); "><div>
<div><div>How do I prevent locking up the activity which opened the URL? </div></div></div></span>