Development Team/Almanac/sugar.activity.activity: Difference between revisions

m Robot: Automated text replacement (-{{Sugar Almanac}} +{{Almanac}})
 
(10 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{Almanac}}
{{Almanac}}
{{Sugar Almanac TOC}}
{{Almanac TOC}}
The sugar.activity.activity package includes several important classes that are needed to run a basic activity.  
The sugar.activity.activity package includes several important classes that are needed to run a basic activity.  


Line 215: Line 215:
</pre>
</pre>


= Class: ActivityToolbox ([[Sugar.graphics.toolbox|Toolbox]])=
=== How do I know if my activity is being started from the Journal? ===
 
You can check handle.object_id in the constructor of your Activity class:
 
<pre>
from sugar.activity import activity
...
class AnnotateActivity(activity.Activity):
    #### Method: __init__, initialize this AnnotateActivity instance
    def __init__(self, handle):
        ...
        if handle.object_id is None:
            print "Activity is started anew (from the home view)"
        else:
            print "Activity is started from the journal and the object id is %s" % handle.object_id
        ...
</pre>
 
= Class: ActivityToolbox ([[Development Team/Almanac/sugar.graphics.toolbox|Toolbox]])=


=== What is the standard toolbox needed in most activities and how do I create it? ===
=== What is the standard toolbox needed in most activities and how do I create it? ===