[Sugar-devel] How to start the Browse activity from my own activity?

Behavior Vehikel b.vehikel at googlemail.com
Sat Feb 6 14:15:10 EST 2010


Addendum to my question about starting the Browse activity from my own activity.

In a reply to my question Gonzalo Odiard wrote: “Can't you use hulahop
like SocialCalc?”
I tried it today. Used a few lines of code from Browse and now I can
display the HTML inside my activity. Think this will improve
usability. The user can switch between tabs in my activity. No need to
switch between different activities.

Thomas



2010/2/3, Gonzalo Odiard <godiard at gmail.com>:
> Can't you use hulahop like SocialCalc?
>
> Gonzalo
>
> On Mon, Feb 1, 2010 at 4:58 PM, Behavior Vehikel
> <b.vehikel at googlemail.com>wrote:
>
>> How to start the Browse activity from my own activity?
>>
>> My Kandid activity can dump internal states as a HTML files. For
>> example this information is written to
>> ~/.sugar/default/net.sourceforge.kandid/tmp/_znuaxz_169/index.html
>>
>> Now I am searching for a possibility to launch the Brows activity
>> displaying this HTML file.
>> First I tried using  the webbrowser.open() method from Python. But no
>> effect when running under SoaS release 2 (Bluberry) Sugar 0.86.3
>>
>> def on_explain_activate(self, *args):
>>    ka_debug.info('on_explain_activate [%s]' % args[0].get_name())
>>    protozoon = self.model.protozoans[name_to_index(args[0].get_name())]
>>    folder = os.path.join(self._activity_root, 'tmp')
>>    file_path = 'file://' + self.explain('html', protozoon, 'index',
>> folder)
>>    #Start up a new instance of the Web activity.
>>    result = webbrowser.open(file_path)
>>    ka_debug.info('webbrowser.open: [%s] %s' % (file_path, str(result)))
>>
>>
>> My second try and error version is using the
>> activityfactory.create_with_uri() method.
>> But it will produce an exception when running with SoaS Bluberry.
>>
>> def on_explain_activate(self, *args):
>>    ka_debug.info('on_explain_activate [%s]' % args[0].get_name())
>>    protozoon = self.model.protozoans[name_to_index(args[0].get_name())]
>>    folder = os.path.join(self._activity_root, 'tmp')
>>    file_path = 'file://' + self.explain('html', protozoon, 'index',
>> folder)
>>    #Start up a new instance of the Web activity.
>>     ka_debug.info('webbrowser.open: [%s]' % (file_path))
>>     activityfactory.create_with_uri('org.laptop.WebActivity', file_path)
>>
>> 1265051065.540251 DEBUG Kandid: on_explain_activate [exportpng_menuitem_2]
>>
>> 1265051069.314681 DEBUG Kandid: webbrowser.open:
>>
>> [file:///home/liveuser/.sugar/default/net.sourceforge.kandid/tmp/_xjwwqo_43/index.html]
>>
>> Traceback (most recent call last):
>>
>>  File "/home/liveuser/Activities/Kandid.activity/ka_controller.py",
>> line 340, in on_explain_activate
>>
>>    activityfactory.create_with_uri('org.laptop.WebActivity', file_path)
>>
>>  File
>> "/usr/lib/python2.6/site-packages/sugar/activity/activityfactory.py",
>> line 332, in create_with_uri
>>
>>    return ActivityCreationHandler(bundle, activity_handle)
>>
>>  File
>> "/usr/lib/python2.6/site-packages/sugar/activity/activityfactory.py",
>> line 206, in __init__
>>
>>    self._service_name = bundle.get_bundle_id()
>>
>> AttributeError: 'str' object has no attribute 'get_bundle_id'
>>
>> 1265051112.422281 DEBUG Kandid: write_file
>> [/home/liveuser/.sugar/default/net.sourceforge.kandid/instance/1265051112]
>>
>>
>>
>> How can I start a browser to display a HTML page? Please add more
>> information to
>> http://wiki.sugarlabs.org/go/Development_Team/Almanac/sugar.activity.activityfactory
>>
>> Thanks, Thomas
>> _______________________________________________
>> Sugar-devel mailing list
>> Sugar-devel at lists.sugarlabs.org
>> http://lists.sugarlabs.org/listinfo/sugar-devel
>>
>
>
>
> --
> Gonzalo Odiard
> Responsable de Desarrollo
> Sistemas Australes
>


-- 
http://digital-defect.org


More information about the Sugar-devel mailing list