Development Team/Almanac/sugar.activity.activity: Difference between revisions
m moved Walter is a wanker 12/Almanac/sugar.activity.activity to Development Team/Almanac/sugar.activity.activity over redirect: revert |
|||
| (14 intermediate revisions by 8 users not shown) | |||
| Line 1: | Line 1: | ||
{{ | {{Almanac}} | ||
{{ | {{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 40: | Line 40: | ||
#print out the name of this activity | #print out the name of this activity | ||
print activity.get_bundle_name() | print activity.get_bundle_name() | ||
=== How do I get the version number of my activity? === | |||
#print out the version number of this activity | |||
print os.environ['SUGAR_BUNDLE_VERSION'] | |||
= Class: Activity = | = Class: Activity = | ||
| Line 210: | Line 215: | ||
</pre> | </pre> | ||
= Class: ActivityToolbox ([[ | === 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? === | ||