本文整理匯總了Python中sugar.graphics.toolbarbox.ToolbarBox.get_activity_toolbar方法的典型用法代碼示例。如果您正苦於以下問題:Python ToolbarBox.get_activity_toolbar方法的具體用法?Python ToolbarBox.get_activity_toolbar怎麽用?Python ToolbarBox.get_activity_toolbar使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sugar.graphics.toolbarbox.ToolbarBox
的用法示例。
在下文中一共展示了ToolbarBox.get_activity_toolbar方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: TamTamSynthLab
# 需要導入模塊: from sugar.graphics.toolbarbox import ToolbarBox [as 別名]
# 或者: from sugar.graphics.toolbarbox.ToolbarBox import get_activity_toolbar [as 別名]
class TamTamSynthLab(activity.Activity):
def __init__(self, handle):
activity.Activity.__init__(self, handle)
color = gtk.gdk.color_parse(Config.WS_BCK_COLOR)
self.modify_bg(gtk.STATE_NORMAL, color)
self.set_title('TamTam SynthLab')
self.set_resizable(False)
self.trackpad = Trackpad(self)
self.preloadTimeout = None
self.connect('notify::active', self.onActive)
self.connect('destroy', self.onDestroy)
#load the sugar toolbar
if Config.HAVE_TOOLBOX:
# no sharing
self.max_participants = 1
self.toolbox = ToolbarBox()
self.toolbox.toolbar.insert(widgets.ActivityToolbarButton(self), 0)
self.toolbox.toolbar.insert(gtk.SeparatorToolItem(), -1)
else:
self.toolbox = activity.ActivityToolbox(self)
self.set_toolbox(self.toolbox)
# no sharing
self.activity_toolbar = self.toolbox.get_activity_toolbar()
self.activity_toolbar.share.hide()
self.activity_toolbar.keep.hide()
self.toolbox.show()
self.trackpad.setContext('synthLab')
self.synthLab = SynthLabMain(self)
self.connect('key-press-event', self.synthLab .onKeyPress)
self.connect('key-release-event', self.synthLab .onKeyRelease)
self.connect("key-press-event", self.synthLab.onKeyPress)
self.connect("key-release-event", self.synthLab.onKeyRelease)
self.set_canvas(self.synthLab)
self.synthLab.onActivate(arg=None)
if Config.HAVE_TOOLBOX:
separator = gtk.SeparatorToolItem()
separator.props.draw = False
separator.set_expand(True)
self.toolbox.toolbar.insert(separator, -1)
self.toolbox.toolbar.insert(widgets.StopButton(self), -1)
self.toolbox.toolbar.show_all()
self.show()
def onPreloadTimeout(self):
if Config.DEBUG > 4:
print "TamTam::onPreloadTimeout", self.preloadList
t = time.time()
if self.preloadList[0].load(t + 0.100): # finished preloading this object
self.preloadList.pop(0)
if not len(self.preloadList):
if Config.DEBUG > 1:
print "TamTam::finished preloading", time.time() - t
self.preloadTimeout = False
return False # finished preloading everything
if Config.DEBUG > 4:
print "TamTam::preload returned after", time.time() - t
return True
def onActive(self, widget=None, event=None):
if widget.props.active == False:
logging.debug('TamTamSynthLab.onActivate disconnecting csound')
csnd = new_csound_client()
csnd.connect(False)
else:
logging.debug('TamTamSynthLab.onActivate connecting csound')
csnd = new_csound_client()
csnd.connect(True)
def onKeyPress(self, widget, event):
pass
def onKeyRelease(self, widget, event):
pass
def onDestroy(self, arg2):
if Config.DEBUG:
print 'DEBUG: TamTam::onDestroy()'
self.synthLab.onDestroy()
csnd = new_csound_client()
csnd.connect(False)
csnd.destroy()
#.........這裏部分代碼省略.........
示例2: TamTamEdit
# 需要導入模塊: from sugar.graphics.toolbarbox import ToolbarBox [as 別名]
# 或者: from sugar.graphics.toolbarbox.ToolbarBox import get_activity_toolbar [as 別名]
class TamTamEdit(activity.Activity):
def __init__(self, handle):
activity.Activity.__init__(self, handle)
# for snd in ['mic1','mic2','mic3','mic4','lab1','lab2','lab3','lab4', 'lab5', 'lab6']:
# if not os.path.isfile(os.path.join(Config.DATA_DIR, snd)):
# shutil.copyfile(Config.SOUNDS_DIR + '/' + snd , Config.DATA_DIR + '/' + snd)
# os.system('chmod 0777 ' + Config.DATA_DIR + '/' + snd + ' &')
color = gtk.gdk.color_parse(Config.WS_BCK_COLOR)
self.modify_bg(gtk.STATE_NORMAL, color)
self.trackpad = Trackpad(self)
self.preloadTimeout = None
self.connect('notify::active', self.onActive)
self.connect('destroy', self.onDestroy)
#load the sugar toolbar
if Config.HAVE_TOOLBOX:
# no sharing
self.max_participants = 1
self.toolbox = ToolbarBox()
self.toolbox.toolbar.insert(widgets.ActivityToolbarButton(self), -1)
else:
self.toolbox = activity.ActivityToolbox(self)
self.set_toolbox(self.toolbox)
self.activity_toolbar = self.toolbox.get_activity_toolbar()
self.toolbox.show()
self.trackpad.setContext('edit')
self.edit = MainWindow(self)
self.connect('key-press-event', self.edit.onKeyPress)
self.connect('key-release-event', self.edit.onKeyRelease)
#self.modeList[mode].regenerate()
self.set_canvas(self.edit)
self.edit.onActivate(arg=None)
if Config.HAVE_TOOLBOX:
separator = gtk.SeparatorToolItem()
separator.props.draw = False
separator.set_expand(True)
self.toolbox.toolbar.insert(separator, -1)
self.toolbox.toolbar.insert(widgets.StopButton(self), -1)
self.toolbox.toolbar.show_all()
else:
self.activity_toolbar.share.hide()
self.show()
def onPreloadTimeout(self):
if Config.DEBUG > 4:
print "TamTam::onPreloadTimeout", self.preloadList
t = time.time()
if self.preloadList[0].load(t + 0.100): # finished preloading this object
self.preloadList.pop(0)
if not len(self.preloadList):
if Config.DEBUG > 1:
print "TamTam::finished preloading", time.time() - t
self.preloadTimeout = False
return False # finished preloading everything
if Config.DEBUG > 4:
print "TamTam::preload returned after", time.time() - t
return True
def onActive(self, widget=None, event=None):
if widget.props.active == False:
csnd = new_csound_client()
csnd.connect(False)
else:
csnd = new_csound_client()
csnd.connect(True)
def onKeyPress(self, widget, event):
pass
def onKeyRelease(self, widget, event):
pass
def onDestroy(self, arg2):
if Config.DEBUG:
print 'DEBUG: TamTam::onDestroy()'
self.edit.onDestroy()
csnd = new_csound_client()
csnd.connect(False)
csnd.destroy()
gtk.main_quit()
#.........這裏部分代碼省略.........