当前位置: 首页>>代码示例>>Python>>正文


Python ToolbarButton.set_page方法代码示例

本文整理汇总了Python中sugar3.graphics.toolbarbox.ToolbarButton.set_page方法的典型用法代码示例。如果您正苦于以下问题:Python ToolbarButton.set_page方法的具体用法?Python ToolbarButton.set_page怎么用?Python ToolbarButton.set_page使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sugar3.graphics.toolbarbox.ToolbarButton的用法示例。


在下文中一共展示了ToolbarButton.set_page方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add_view

# 需要导入模块: from sugar3.graphics.toolbarbox import ToolbarButton [as 别名]
# 或者: from sugar3.graphics.toolbarbox.ToolbarButton import set_page [as 别名]
    def add_view(self, widget):
        if len(self._view_icons) >= 5:
            for x in self.activity._alerts:
                self.activity.remove_alert(x)
            alert = NotifyAlert(10)
            alert.props.title = _('Limit reached')
            alert.props.msg = _('You have reached the maximum limit of '
                                'favorites views, please delete some before '
                                'continuing.')
            self.activity.add_alert(alert)
            alert.connect('response',
                          lambda x, y: self.activity.remove_alert(x))
            return

        current = len(self._view_buttons) + 1
        label = _('Favorites view %d') % current
        button = ToolbarButton(label=label, icon_name='view-radial')
        page = FavoritePage(button, self, 'view-radial', 'emblem-favorite',
                            label)
        button.set_page(page)

        self._view_icons[button] = 'view-radial'
        self._favorite_icons[button] = 'emblem-favorite'
        self._view_buttons[button] = button
        if self.favorite_names_enabled:
            self._favorite_names[button] = label

        self.insert(button, -1)
        self.save_to_gconf()
        self.show_all()
开发者ID:svineet,项目名称:manage-homeviews,代码行数:32,代码来源:homeviews.py

示例2: __init__

# 需要导入模块: from sugar3.graphics.toolbarbox import ToolbarButton [as 别名]
# 或者: from sugar3.graphics.toolbarbox.ToolbarButton import set_page [as 别名]
    def __init__(self, handle):

        if not hasattr(self, 'confvars'):
            self.confvars = read_conf_from_info(get_bundle_path())

        logging.error("Starting server database: %s port: %s" %
                      (self.confvars['path'], self.confvars['port']))

        os.chdir(os.environ['SUGAR_BUNDLE_PATH'])

        self.confvars['ip'] = '0.0.0.0'

        server.run_server(self.confvars)

        handle.uri = 'http://%s:%s%s' % (
            self.confvars['ip'], self.confvars['port'],
            self.confvars['home_page'])

        webactivity.WebActivity.__init__(self, handle)

        if USE_GTK2:
            # Use xpcom to set a RAM cache limit.  (Trac #7081.)
            from xpcom import components
            from xpcom.components import interfaces
            cls = components.classes['@mozilla.org/preferences-service;1']
            pref_service = cls.getService(interfaces.nsIPrefService)
            branch = pref_service.getBranch("browser.cache.memory.")
            branch.setIntPref("capacity", "5000")

            # Use xpcom to turn off "offline mode" detection, which disables
            # access to localhost for no good reason.  (Trac #6250.)
            ios_class = components.classes["@mozilla.org/network/io-service;1"]
            io_service = ios_class.getService(interfaces.nsIIOService2)
            io_service.manageOfflineStatus = False

        self.searchtoolbar = SearchToolbar(self)
        search_toolbar_button = ToolbarButton()
        search_toolbar_button.set_page(self.searchtoolbar)
        search_toolbar_button.props.icon_name = 'search-wiki'
        search_toolbar_button.props.label = _('Search')
        self.get_toolbar_box().toolbar.insert(search_toolbar_button, 1)
        search_toolbar_button.show()
        # Hide add-tabs button
        if hasattr(self._primary_toolbar, '_add_tab'):
            self._primary_toolbar._add_tab.hide()

        self.searchtoolbar.show()
开发者ID:godiard,项目名称:wikipedia-activity,代码行数:49,代码来源:activity.py

示例3: load_views

# 需要导入模块: from sugar3.graphics.toolbarbox import ToolbarButton [as 别名]
# 或者: from sugar3.graphics.toolbarbox.ToolbarButton import set_page [as 别名]
    def load_views(self):
        client = GConf.Client.get_default()
        options = client.get(_FAVORITE_KEY)
        options2 = client.get(_VIEW_KEY)
        options3 = client.get(_FAVORITE_NAME_KEY)

        view_icons = []
        favorites_icons = []
        favorite_names = []

        if options is not None and options2 is not None and \
                options3 is not None:
            for gval in options.get_list():
                favorites_icons.append(gval.get_string())

            for gval in options2.get_list():
                view_icons.append(gval.get_string())

            for gval in options3.get_list():
                favorite_names.append(gval.get_string())

        current = 0
        for view_icon in view_icons:
            if self.favorite_names_enabled:
                try:
                    label = favorite_names[current]
                except IndexError:
                    label = _('Favorites view %d') % (current + 1)
            else:
                label = _('Favorites view %d') % (current + 1)

            button = ToolbarButton(label=label, icon_name=view_icon)
            page = FavoritePage(button, self, view_icon,
                                favorites_icons[current], label)
            button.set_page(page)
            self.insert(button, -1)
            self._view_icons[button] = view_icon
            self._favorite_icons[button] = favorites_icons[current]
            self._view_buttons[button] = button
            self._favorite_names[button] = label
            current += 1
开发者ID:svineet,项目名称:manage-homeviews,代码行数:43,代码来源:homeviews.py

示例4: load_views

# 需要导入模块: from sugar3.graphics.toolbarbox import ToolbarButton [as 别名]
# 或者: from sugar3.graphics.toolbarbox.ToolbarButton import set_page [as 别名]
    def load_views(self):
        settings = Gio.Settings(_DESKTOP_CONF_DIR)
        data = settings.get_value('homeviews').unpack()

        current = 0
        for view in data:
            label = _('Favorites view %d') % (current + 1)

            print view, data
            view_icon = view['view-icon']
            favorite_icon = view['favorite-icon']

            button = ToolbarButton(label=label, icon_name=view_icon)
            page = FavoritePage(button, self, view_icon, favorite_icon, label)
            button.set_page(page)
            self.insert(button, -1)
            self._view_icons[button] = view_icon
            self._favorite_icons[button] = favorite_icon
            self._view_buttons[button] = button
            self._favorite_names[button] = label
            current += 1
开发者ID:Daksh,项目名称:manage-homeviews,代码行数:23,代码来源:homeviews.py

示例5: AbiWordActivity

# 需要导入模块: from sugar3.graphics.toolbarbox import ToolbarButton [as 别名]
# 或者: from sugar3.graphics.toolbarbox.ToolbarButton import set_page [as 别名]

#.........这里部分代码省略.........
        self.joined = False

        self.connect('shared', self._shared_cb)

        if self.shared_activity:
            # we are joining the activity
            logger.error('We are joining an activity')
            # display a icon while joining
            self._connecting_box.show()
            # disable the abi widget
            self.abiword_canvas.set_sensitive(False)
            self._new_instance = False
            self.connect('joined', self._joined_cb)
            self.shared_activity.connect('buddy-joined',
                                         self._buddy_joined_cb)
            self.shared_activity.connect('buddy-left', self._buddy_left_cb)
            if self.get_shared():
                self._joined_cb(self)
        else:
            # we are creating the activity
            logger.error("We are creating an activity")

        self.abiword_canvas.zoom_width()
        self.abiword_canvas.show()
        self.connect_after('map-event', self.__map_activity_event_cb)

        self.abiword_canvas.connect('size-allocate', self.size_allocate_cb)

    def _init_speech(self):
        import speech
        from speechtoolbar import SpeechToolbar
        if speech.supported:
            self.speech_toolbar = SpeechToolbar(self)
            self.speech_toolbar_button.set_page(self.speech_toolbar)
            self.speech_toolbar_button.show()

    def size_allocate_cb(self, abi, alloc):
        GObject.idle_add(abi.queue_draw)

    def __map_activity_event_cb(self, event, activity):
        # set custom keybindings for Write
        # we do it later because have problems if done before - OLPC #11049
        logger.error('Loading keybindings')
        keybindings_file = os.path.join(get_bundle_path(), 'keybindings.xml')
        self.abiword_canvas.invoke_ex(
            'com.abisource.abiword.loadbindings.fromURI',
            keybindings_file, 0, 0)
        # set default font
        if self._new_instance:
            self.abiword_canvas.select_all()
            logging.error('Setting default font to %s %d in new documents',
                          self._default_font_face, self._default_font_size)
            self.abiword_canvas.set_font_name(self._default_font_face)
            self.abiword_canvas.set_font_size(str(self._default_font_size))
            self.abiword_canvas.moveto_bod()
            self.abiword_canvas.select_bod()
        if hasattr(self.abiword_canvas, 'toggle_rulers'):
            # this is not available yet on upstream abiword
            self.abiword_canvas.view_print_layout()
            self.abiword_canvas.toggle_rulers(False)

        self.abiword_canvas.grab_focus()

    def get_preview(self):
        if not hasattr(self.abiword_canvas, 'render_page_to_image'):
            return activity.Activity.get_preview(self)
开发者ID:AbrahmAB,项目名称:write-activity,代码行数:70,代码来源:AbiWordActivity.py

示例6: __init__

# 需要导入模块: from sugar3.graphics.toolbarbox import ToolbarButton [as 别名]
# 或者: from sugar3.graphics.toolbarbox.ToolbarButton import set_page [as 别名]
    def __init__(self, handle):
        """Set up the HelloWorld activity."""
        activity.Activity.__init__(self, handle)

        self.connect('realize', self.__realize_cb)

        self.max_participants = 1  # No sharing

        self._font_name = None
        self._layout = LAYOUT_RANDOM
        self._xo_colors = (_rgb(profile.get_color().to_string().split(',')[0]),
                           _rgb(profile.get_color().to_string().split(',')[1]))
        self._color_scheme = self._xo_colors
        self._repeat_tags = False

        self._toolbox = ToolbarBox()

        self.activity_button = ActivityToolbarButton(self)
        self._toolbox.toolbar.insert(self.activity_button, 0)
        self.activity_button.show()

        self.set_toolbar_box(self._toolbox)
        self._toolbox.show()
        self.toolbar = self._toolbox.toolbar

        self._edit_toolbar = EditToolbar()
        button = ToolbarButton()
        button.set_page(self._edit_toolbar)
        button.props.icon_name = 'toolbar-edit'
        button.props.label = _('Edit')
        self._toolbox.toolbar.insert(button, -1)
        button.show()
        self._edit_toolbar.show()

        # self._edit_toolbar.undo.connect('clicked', self._undo_cb)
        # self._edit_toolbar.redo.connect('clicked', self._redo_cb)
        self._edit_toolbar.undo.hide()
        self._edit_toolbar.redo.hide()
        self._edit_toolbar.copy.connect('clicked', self._copy_cb)
        self._edit_toolbar.paste.connect('clicked', self._paste_cb)

        go_button = ToolButton('generate-cloud')
        self._toolbox.toolbar.insert(go_button, -1)
        go_button.set_tooltip(_('Create the cloud'))
        go_button.show()
        go_button.connect('clicked', self._go_cb)

        self._text_item = TextItem(self)
        self._toolbox.toolbar.insert(self._text_item, -1)
        self._text_item.show()
        text = self._read_metadata('text')
        if text is not None:
            self._text_item.set_text(text)

        self._repeat_button = ToggleToolButton('repeat-cloud')
        self._toolbox.toolbar.insert(self._repeat_button, -1)
        self._repeat_button.set_tooltip(_('Repeat words'))
        self._repeat_button.show()
        self._repeat_button.connect('clicked', self._repeat_cb)

        self.font_palette_content, self.font_palette_dict = \
            set_palette_list(
                self._setup_font_palette(), 3, 7,
                style.SMALL_ICON_SIZE + style.DEFAULT_SPACING +
                style.DEFAULT_PADDING, return_dict=True)
        self._font_button = FontToolItem(self)
        self.font_palette_content.show()
        self._toolbox.toolbar.insert(self._font_button, -1)
        self._font_button.show()

        self.color_palette_content, self.color_palette_dict = \
            set_palette_list(
                self._setup_color_palette(), 3, 5,
                style.GRID_CELL_SIZE + style.DEFAULT_SPACING +
                style.DEFAULT_PADDING, return_dict=True)
        self._color_button = ColorToolItem(self)
        self.color_palette_content.show()
        self._toolbox.toolbar.insert(self._color_button, -1)
        self._color_button.show()

        self.layout_palette_content, self.layout_palette_dict = \
            set_palette_list(self._setup_layout_palette(), 1, 5,
                             style.GRID_CELL_SIZE + style.DEFAULT_SPACING +
                             style.DEFAULT_PADDING, return_dict=True)
        self._layout_button = LayoutToolItem(self)
        self.layout_palette_content.show()
        self._toolbox.toolbar.insert(self._layout_button, -1)
        self._layout_button.show()

        separator = Gtk.SeparatorToolItem()
        separator.props.draw = False
        separator.set_expand(True)
        self._toolbox.toolbar.insert(separator, -1)
        separator.show()

        stop_button = StopButton(self)
        stop_button.props.accelerator = '<Ctrl>q'
        self._toolbox.toolbar.insert(stop_button, -1)
        stop_button.show()

#.........这里部分代码省略.........
开发者ID:sugarlabs,项目名称:wordcloud,代码行数:103,代码来源:activity.py

示例7: Record

# 需要导入模块: from sugar3.graphics.toolbarbox import ToolbarButton [as 别名]
# 或者: from sugar3.graphics.toolbarbox.ToolbarButton import set_page [as 别名]
class Record(activity.Activity):
    
    def __init__(self, handle):
        
        super(Record, self).__init__(handle)

        self.toolbox = ToolbarBox()
        self.toolbar = self.toolbox.toolbar
        self.activitybutton = ActivityToolbarButton(self)
        
        self._photo = None
        self._video = None
        self._audio = None
        
        self._timer = None
        self._timer_2 = None
        
        self._preferencias = None
        
        self.view = None
        self.tray = None
        
        self._set_toolbar()
        self._set_canvas()
        
        self.show_all()
        
        #self._photo.connect("clicked", self._click, "Photo")
        #self._video.connect("clicked", self._click, "Video")
        #self._audio.connect("clicked", self._click, "Audio")

    def _set_canvas(self):
        
        basebox = Gtk.Box(orientation = Gtk.Orientation.VERTICAL)
        
        self.view = View()
        self.tray = Tray()
        
        basebox.pack_start(self.view, True, True, 0)
        basebox.pack_start(self.tray, False, False, 0)
        
        self.set_canvas(basebox)
        
    def _set_toolbar(self):
        
        separator = Gtk.SeparatorToolItem()
        separator.props.draw = False
        separator.set_expand(True)

        stop = StopButton(self)

        # Buttons #
        self._photo = RadioToolButton()
        self._photo.props.icon_name = 'media-photo'
        self._photo.props.label = _('Photo')

        self._video = RadioToolButton()
        self._video.props.group = self._photo
        self._video.props.icon_name = 'media-video'
        self._video.props.label = _('Video')

        self._audio = RadioToolButton()
        self._audio.props.group = self._photo
        self._audio.props.icon_name = 'media-audio'
        self._audio.props.label = _('Audio')
        # End of Buttons #

        self._timer = TimerCombo()
        self._timer_2 = DurationCombo()
        #self._timer_2.combo.set_sensitive(False)

        self._preferencias = ToolbarButton()
        
        toolbar = Gtk.Toolbar()
        combo = QualityCombo()
        #combo.set_sensitive(False)
        self.calidad = ToolComboBox(combo=combo, label_text=_('Quality:'))
        self.calidad.show_all()
        toolbar.insert(self.calidad, -1)
        toolbar.show_all()
        
        self._preferencias.set_page(toolbar)
        
        self._preferencias.props.icon_name = 'preferences-system'
        self._preferencias.props.label = _('Preferences')

        self.toolbar.insert(self.activitybutton, -1)

        self.toolbar.insert(self._photo, -1)
        self.toolbar.insert(self._video, -1)
        self.toolbar.insert(self._audio, -1)

        self.toolbar.insert(Gtk.SeparatorToolItem(), -1)

        self.toolbar.insert(self._timer, -1)
        self.toolbar.insert(self._timer_2, -1)
        self.toolbar.insert(self._preferencias, -1)

        self.toolbar.insert(separator, -1)
        self.toolbar.insert(stop, -1)
#.........这里部分代码省略.........
开发者ID:i5o,项目名称:record-gtk3,代码行数:103,代码来源:RecordActivity.py


注:本文中的sugar3.graphics.toolbarbox.ToolbarButton.set_page方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。