Activity Team/Compatibility Tips: Difference between revisions
| Line 76: | Line 76: | ||
Sugar toolbars changed in Sucrose v0.86. You can detect which version you are running by checking for an ImportError: | Sugar toolbars changed in Sucrose v0.86. You can detect which version you are running by checking for an ImportError: | ||
try: # 0.86 toolbar widgets | try: # 0.86 toolbar widgets | ||
from sugar.activity.widgets import ActivityToolbarButton, StopButton | |||
from sugar.graphics.toolbarbox import ToolbarBox, ToolbarButton | |||
has_toolbarbox = True | |||
except ImportError: | except ImportError: | ||
has_toolbarbox = False | |||
Use the flag to determine whether to create old-style or new toolbars: | Use the flag to determine whether to create old-style or new toolbars: | ||
if | if has_toolbarbox: | ||
# Use 0.86+ toolbar design | # Use 0.86+ toolbar design | ||
toolbar_box = ToolbarBox() | toolbar_box = ToolbarBox() | ||