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


Python RadioToolButton.connect方法代码示例

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


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

示例1: __init__

# 需要导入模块: from sugar.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar.graphics.radiotoolbutton.RadioToolButton import connect [as 别名]
    def __init__(self, owner):
        gtk.Toolbar.__init__(self)

        self.owner = owner

        self._insert_separator(True)

        self.desktop = []

        btn = RadioToolButton(group=None)
        btn.set_named_icon('jam-preset1')
        btn.connect('toggled', self.setDesktop, 0)
        btn.set_tooltip(_('Desktop 1'))
        self.insert(btn, -1)
        self.desktop.append(btn)

        for i in range(2, 11):
            btn = RadioToolButton(group=self.desktop[0])
            btn.set_named_icon('jam-preset%d' % i)
            btn.connect('toggled', self.setDesktop, i - 1)
            btn.set_tooltip(_('Desktop %d' % i))
            self.insert(btn, -1)
            self.desktop.append(btn)

        self._insert_separator(True)

        self.show_all()
开发者ID:fdanesse,项目名称:TamTam,代码行数:29,代码来源:Toolbars.py

示例2: _radio_button_factory

# 需要导入模块: from sugar.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar.graphics.radiotoolbutton.RadioToolButton import connect [as 别名]
 def _radio_button_factory(name='', toolbar=None, cb=None, arg=None,
                           tooltip=None, group=None):
     ''' Add a radio button to a toolbar '''
     button = RadioToolButton(group=group)
     button.set_named_icon(name)
     if cb is not None:
         if arg is None:
             button.connect('clicked', cb)
         else:
             button.connect('clicked', cb, arg)
     if toolbar is not None:
         toolbar.insert(button, -1)
     button.show()
     if tooltip is not None:
         button.set_tooltip(tooltip)
     return button
开发者ID:leonardcj,项目名称:tamtam,代码行数:18,代码来源:SynthLabToolbars.py

示例3: __init__

# 需要导入模块: from sugar.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar.graphics.radiotoolbutton.RadioToolButton import connect [as 别名]
    def __init__(self, title, bundle_path, document_path):
        gtk.Toolbar.__init__(self)

        self._add_separator()

        activity_bundle = ActivityBundle(bundle_path)
        file_name = activity_bundle.get_icon()

        if document_path is not None and os.path.exists(document_path):
            document_button = DocumentButton(file_name, document_path, title)
            document_button.connect('toggled', self.__button_toggled_cb, 
                                    document_path)
            self.insert(document_button, -1)
            document_button.show()
            self._add_separator()

        if bundle_path is not None and os.path.exists(bundle_path):
            activity_button = RadioToolButton()
            icon = Icon(file=file_name,
                        icon_size=gtk.ICON_SIZE_LARGE_TOOLBAR,
                        fill_color=style.COLOR_TRANSPARENT.get_svg(),
                        stroke_color=style.COLOR_WHITE.get_svg())
            activity_button.set_icon_widget(icon)
            icon.show()
            if document_path is not None:
                activity_button.props.group = document_button
            activity_button.props.tooltip = _('Activity Bundle Source')
            activity_button.connect('toggled', self.__button_toggled_cb, 
                                    bundle_path)
            self.insert(activity_button, -1)
            activity_button.show()
            self._add_separator()

        text = _('View source: %r') % title
        label = gtk.Label()
        label.set_markup('<b>%s</b>' % text)
        label.set_alignment(0, 0.5)
        self._add_widget(label)

        self._add_separator(True)
        
        stop = ToolButton(icon_name='dialog-cancel')
        stop.set_tooltip(_('Close'))
        stop.connect('clicked', self.__stop_clicked_cb)
        stop.show()
        self.insert(stop, -1)
        stop.show()
开发者ID:lucian1900,项目名称:Webified,代码行数:49,代码来源:viewsource.py

示例4: _add_button

# 需要导入模块: from sugar.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar.graphics.radiotoolbutton.RadioToolButton import connect [as 别名]
    def _add_button(self, icon_name, label, accelerator, zoom_level):
        if self.get_children():
            group = self.get_children()[0]
        else:
            group = None

        button = RadioToolButton(named_icon=icon_name, group=group, accelerator=accelerator)
        button.connect("clicked", self.__level_clicked_cb, zoom_level)
        self.add(button)
        button.show()

        palette = Palette(glib.markup_escape_text(label))
        palette.props.invoker = FrameWidgetInvoker(button)
        palette.set_group_id("frame")
        button.set_palette(palette)

        return button
开发者ID:nemesiscodex,项目名称:jarabe,代码行数:19,代码来源:zoomtoolbar.py

示例5: radio_factory

# 需要导入模块: from sugar.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar.graphics.radiotoolbutton.RadioToolButton import connect [as 别名]
def radio_factory(button_name, toolbar, callback, cb_arg=None, tooltip=None,
                  group=None):
    ''' Add a radio button to a toolbar '''
    button = RadioToolButton(group=group)
    button.set_named_icon(button_name)
    if callback is not None:
        if cb_arg is None:
            button.connect('clicked', callback)
        else:
            button.connect('clicked', callback, cb_arg)
    if hasattr(toolbar, 'insert'):  # Add button to the main toolbar...
        toolbar.insert(button, -1)
    else:  # ...or a secondary toolbar.
        toolbar.props.page.insert(button, -1)
    button.show()
    if tooltip is not None:
        button.set_tooltip(tooltip)
    return button
开发者ID:walterbender,项目名称:bulletinboard,代码行数:20,代码来源:toolbar_utils.py

示例6: get_toolbar

# 需要导入模块: from sugar.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar.graphics.radiotoolbutton.RadioToolButton import connect [as 别名]
 def get_toolbar(self):
     toolbar = gtk.Toolbar()
     
     radio_adv = RadioToolButton()
     radio_adv.set_active(True)
     radio_adv.set_label("Avanzada")
     radio_adv.set_tooltip("Mostrar biblioteca avanzada")
     radio_adv.connect("clicked", self.switch, "advanced")
     toolbar.insert(radio_adv, -1)
     radio_adv.show()
     
     radio_bas = RadioToolButton(group=radio_adv)
     radio_bas.set_label("Simple")
     radio_bas.set_tooltip("Mostrar biblioteca sencilla")
     radio_bas.connect("clicked", self.switch, "basic")
     toolbar.insert(radio_bas, -1)
     
     toolbar.show_all()
     
     return toolbar
开发者ID:pmoleri,项目名称:saludame,代码行数:22,代码来源:content_window.py

示例7: build_toolbar

# 需要导入模块: from sugar.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar.graphics.radiotoolbutton.RadioToolButton import connect [as 别名]
    def build_toolbar(self):        
        # make a toolbox
        toolbox = activity.ActivityToolbox(self)
         
        # modify the Activity tab
        activity_toolbar = toolbox.get_activity_toolbar()
        activity_toolbar.share.props.visible = False
        self.blocklist = [] 
        # make a 'create' toolbar
        create_toolbar = gtk.Toolbar()
        
        # make + add the component buttons
        self.radioList = {}
        for c in tools.allTools:                             
            button = RadioToolButton(named_icon=c.icon)
            button.set_tooltip(_(c.toolTip))
            button.connect('clicked',self.radioClicked)
            create_toolbar.insert(button,-1)    
            button.show()
            self.radioList[button] = c.name

        # add the toolbars to the toolbox
        toolbox.add_toolbar("Create",create_toolbar)
        create_toolbar.show()

        # add a ILF specific toolbar which gives feedback about problems
        #ilf_toolbar = gtk.Toolbar()
        #self.ilf_label = gtk.Label("test")
        #ilf_toolbar.insert_widget(self.ilf_label, "testlabel", None, -1)
        #self.ilf_label.show()
        #toolbox.add_toolbar("ILF", ilf_toolbar)
        #ilf_toolbar.show()
       
        
        toolbox.show()
        self.set_toolbox(toolbox)
        toolbox.set_current_toolbar(1)
        return activity_toolbar
开发者ID:kaserf,项目名称:PhysicsILF,代码行数:40,代码来源:activity.py

示例8: __init__

# 需要导入模块: from sugar.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar.graphics.radiotoolbutton.RadioToolButton import connect [as 别名]
    def __init__(self):
        RadioToolButton.__init__(self)

        self.props.tooltip = _('Pathway view')
        self.props.accelerator = _('<Ctrl>3')
        self.props.group = None

        favorites_settings = favoritesview.get_settings()
        self._layout = favorites_settings.layout
        self._update_icon()

        # someday, this will be a gtk.Table()
        layouts_grid = gtk.HBox()
        layout_item = None
        for layoutid, layoutclass in sorted(favoritesview.LAYOUT_MAP.items()):
            layout_item = RadioToolButton(icon_name=layoutclass.icon_name,
                                          group=layout_item, active=False)
            if layoutid == self._layout:
                layout_item.set_active(True)
            layouts_grid.pack_start(layout_item, fill=False)
            layout_item.connect('toggled', self.__layout_activate_cb,
                                layoutid)
        layouts_grid.show_all()
        self.props.palette.set_content(layouts_grid)
开发者ID:davidmason,项目名称:glycogen,代码行数:26,代码来源:pathwaybutton.py

示例9: ShareButton

# 需要导入模块: from sugar.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar.graphics.radiotoolbutton.RadioToolButton import connect [as 别名]
class ShareButton(RadioMenuButton):

    def __init__(self, activity, **kwargs):
        palette = RadioPalette()

        self.private = RadioToolButton(
                icon_name='zoom-home')
        palette.append(self.private, _('Private'))

        self.neighborhood = RadioToolButton(
                icon_name='zoom-neighborhood',
                group=self.private)
        self._neighborhood_handle = self.neighborhood.connect(
                'clicked', self.__neighborhood_clicked_cb, activity)
        palette.append(self.neighborhood, _('My Neighborhood'))

        activity.connect('shared', self.__update_share_cb)
        activity.connect('joined', self.__update_share_cb)

        RadioMenuButton.__init__(self, **kwargs)
        self.props.palette = palette
        if activity.max_participants == 1:
            self.props.sensitive = False

    def __neighborhood_clicked_cb(self, button, activity):
        activity.share()

    def __update_share_cb(self, activity):
        self.neighborhood.handler_block(self._neighborhood_handle)
        try:
            if activity.shared_activity is not None and \
                    not activity.shared_activity.props.private:
                self.private.props.sensitive = False
                self.neighborhood.props.sensitive = False
                self.neighborhood.props.active = True
            else:
                self.private.props.sensitive = True
                self.neighborhood.props.sensitive = True
                self.private.props.active = True
        finally:
            self.neighborhood.handler_unblock(self._neighborhood_handle)
开发者ID:Daksh,项目名称:sugar-toolkit,代码行数:43,代码来源:widgets.py

示例10: __init__

# 需要导入模块: from sugar.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar.graphics.radiotoolbutton.RadioToolButton import connect [as 别名]
    def __init__(self, parent):
        gtk.Toolbar.__init__(self)
        self._parent = parent

        text_mode_btn = RadioToolButton(named_icon='text-mode')
        text_mode_btn.set_tooltip(_('Text mode'))
        text_mode_btn.set_accelerator(_('<ctrl>t'))
        text_mode_btn.set_group(None)
        text_mode_btn.connect('clicked', self._parent.mode_cb,
                              MMapArea.MODE_TEXT)
        self._parent.btn_group = text_mode_btn
        self.insert(text_mode_btn, -1)

        image_mode_btn = RadioToolButton(named_icon='image-mode')
        image_mode_btn.set_group(text_mode_btn)
        image_mode_btn.set_tooltip(_('Image add mode'))
        image_mode_btn.set_accelerator(_('<ctrl>i'))
        image_mode_btn.connect('clicked', self._parent.mode_cb,
                               MMapArea.MODE_IMAGE)
        self.insert(image_mode_btn, -1)

        draw_mode_btn = RadioToolButton(named_icon='draw-mode')
        draw_mode_btn.set_group(text_mode_btn)
        draw_mode_btn.set_tooltip(_('Drawing mode'))
        draw_mode_btn.set_accelerator(_('<ctrl>d'))
        draw_mode_btn.connect('clicked', self._parent.mode_cb,
                              MMapArea.MODE_DRAW)
        self.insert(draw_mode_btn, -1)

        label_mode_btn = RadioToolButton(named_icon='label-mode')
        label_mode_btn.set_tooltip(_('Label mode'))
        label_mode_btn.set_accelerator(_('<ctrl>a'))
        label_mode_btn.set_group(text_mode_btn)
        label_mode_btn.connect('clicked', self._parent.mode_cb,
                               MMapArea.MODE_LABEL)
        self.insert(label_mode_btn, -1)

        self.show_all()
开发者ID:Daksh,项目名称:Labyrinth,代码行数:40,代码来源:labyrinthactivity.py

示例11: ActionButtons

# 需要导入模块: from sugar.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar.graphics.radiotoolbutton.RadioToolButton import connect [as 别名]
class ActionButtons():

    ''' This class manages the action buttons that move among toolsbars '''

    def __init__(self, parent):
        self._main_toolbar = parent.get_toolbar_box().toolbar
        self._main_area = parent._main_area
        self._erase_button = parent.edit_toolbar.erase_button
        self._sw = parent._sw

        if HASTOOLBARBOX:
            target_toolbar = self._main_toolbar
        else:
            target_toolbar = self.parent.edit_toolbar

        self._mods = RadioToolButton(named_icon='select-mode')
        self._mods.set_tooltip(_('Select thoughts'))
        self._mods.set_group(parent.btn_group)
        self._mods.set_accelerator(_('<ctrl>e'))
        self._mods.connect('clicked', parent.mode_cb, MMapArea.MODE_NULL)
        target_toolbar.insert(self._mods, -1)

        self._link_button = RadioToolButton(named_icon='link')
        self._link_button.set_tooltip(_('Link/unlink two selected thoughts'))
        self._link_button.set_group(parent.btn_group)
        self._link_button.set_accelerator(_('<ctrl>l'))
        self._link_button.connect('clicked', self.__link_cb)
        target_toolbar.insert(self._link_button, -1)

        self.move_button = RadioToolButton(named_icon='move')
        self.move_button.set_tooltip(_('Move selected thoughs'))
        self.move_button.set_group(parent.btn_group)
        self.move_button.set_accelerator(_('<ctrl>m'))
        self.move_button.connect('clicked', self.__move_cb)
        target_toolbar.insert(self.move_button, -1)

        self.drag_button = RadioToolButton(named_icon='drag')
        self.drag_button.set_tooltip(_('Scroll the screen'))
        self.drag_button.set_group(parent.btn_group)
        self.drag_button.connect('clicked', self.__drag_cb)
        target_toolbar.insert(self.drag_button, -1)

        if HASTOOLBARBOX:
            self._separator_2 = gtk.SeparatorToolItem()
            self._separator_2.props.draw = False
            # self._separator_2.set_size_request(0, -1)
            self._separator_2.set_expand(True)
            self._separator_2.show()
            target_toolbar.insert(self._separator_2, -1)

            self._stop_button = StopButton(parent)
            target_toolbar.insert(self._stop_button, -1)

    def stop_dragging(self):
        if self._main_area.is_dragging():
            self._main_area.drag_menu_cb(self._sw, False)

    def _stop_moving(self):
        self._main_area.move_mode = False

    def __link_cb(self, widget):
        self._stop_moving()
        self.stop_dragging()
        self._main_area.link_menu_cb()

    def __move_cb(self, widget):
        self.stop_dragging()
        if self._main_area.move_mode:
            self._main_area.stop_moving()
        else:
            self._main_area.start_moving(self.move_button)
        self._erase_button.set_sensitive(False)

    def __drag_cb(self, widget):
        # If we were moving, stop
        self._stop_moving()
        if not self._main_area.is_dragging():
            self._main_area.drag_menu_cb(self._sw, True)
        else:
            self.stop_dragging()
        self._erase_button.set_sensitive(False)

    def reconfigure(self):
        ''' If screen width has changed, we may need to reconfigure
        the toolbars '''
        if not HASTOOLBARBOX:
            return

        if hasattr(self, '_separator_2'):
            if gtk.gdk.screen_width() / 13 > style.GRID_CELL_SIZE:
                if self._separator_2.get_parent() is None:
                    self._main_toolbar.remove(self._stop_button)
                    self._main_toolbar.insert(self._separator_2, -1)
                    self._main_toolbar.insert(self._stop_button, -1)
            else:
                self._main_toolbar.remove(self._separator_2)
开发者ID:Daksh,项目名称:Labyrinth,代码行数:98,代码来源:labyrinthactivity.py

示例12: __init__

# 需要导入模块: from sugar.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar.graphics.radiotoolbutton.RadioToolButton import connect [as 别名]
        def __init__(self, handle):
                activity.Activity.__init__(self, handle, True)

                self.max_participants = 1

                # ****** Editor ******

                self.editor = Editor()
                self.editor.connect("pep8-aviable", self.enable_pep8)
                self.editor.connect('language-changed', self.language_changed)
                
                self.editor.set_size_request(800, 790)
                scroll = gtk.ScrolledWindow()
                scroll.set_policy(gtk.POLICY_AUTOMATIC,
                                  gtk.POLICY_AUTOMATIC)
                scroll.add(self.editor)

                vbox = gtk.VBox()
                vpaned = gtk.VPaned()
                vbox.pack_start(vpaned, True, True, 0)
                vpaned.show()
                vpaned.pack1(scroll, resize=True)
                scroll.show_all()

                self.set_canvas(vbox)

                # ****** Toolbars ******

                self.toolbar_box = options.OptionWidget(self, self.editor.get_pango_context())
                self.toolbar_box.connect('open-from-journal', file_choosers.open_from_journal, None, self)
                self.toolbar_box.connect('open-file', self.open_file)
                self.toolbar_box.connect('save-file', self.save_file)
                self.toolbar_box.connect('save-as', self.save_file_as)
                self.toolbar_box.connect('new-file', self.new)
                self.toolbar_box.connect('pep8-check', self.pep8_check)
                self.toolbar_box.connect('insert-datetime', self.editor._insert_date_time)
                self.toolbar_box.connect('copy', self.editor._copy_cb)
                self.toolbar_box.connect('paste', self.editor._paste_cb)
                self.toolbar_box.connect('undo', self.editor._undo_cb)
                self.toolbar_box.connect('redo', self.editor._redo_cb)
                self.toolbar_box.connect('cut', self.editor._cut_cb)
                self.toolbar_box.connect('search-text', self._search_text)
                self.toolbar_box.connect('search-prev', self.editor._search_prev_cb)
                self.toolbar_box.connect('search-next', self.editor._search_next_cb)
                self.toolbar_box.connect('show-line-numbers', self.editor._set_show_line_numbers)
                self.toolbar_box.connect('language-changed', self.change_language)
                self.toolbar_box.connect('style-changed', self.change_style)
                self.toolbar_box.connect('font-changed', self.change_font)
                self.toolbar_box.show_all()
                self.set_toolbar_box(self.toolbar_box)
                
                # Barra de estado de PEP8 / PEP8 status bar
                self.pep8 = PEP8_Check()
                
                self.pep8_bar = gtk.Statusbar()
                self.pep8.connect("show-bar", (lambda w, bar: bar.show_all()), self.pep8_bar)
                self.pep8.connect("hide-bar", (lambda w, bar: bar.hide()), self.pep8_bar)
                self.pep8_bar.label = gtk.Label()
                self.pep8.connect("bar-text", (lambda w, t, l: l.set_text(t)), self.pep8_bar.label)
                self.pep8_bar.add(self.pep8_bar.label)
                vbox.pack_end(self.pep8_bar, False, True, 0)
                
                tray = VTray()
                self.test_notebook = gtk.Notebook()
                self.test_notebook.set_show_tabs(False)
                terminal = consoles.Terminal()
                terminal.show()
                terminal_item = RadioToolButton()
                terminal_item.set_named_icon("console-terminal")
                terminal_item.set_tooltip("Terminal")
                terminal_item.connect("toggled", self.page_changed, 0)
                terminal_item.show()
                self.test_notebook.append_page(terminal, None)
                tray.add_item(terminal_item)
                python_console = consoles.PythonConsole()
                python_console.show()
                python_item = RadioToolButton()
                python_item.set_named_icon("console-python")
                python_item.set_tooltip("Python Console")
                python_item.set_group(terminal_item)
                python_item.connect("toggled", self.page_changed, 1)
                python_item.show()
                self.test_notebook.append_page(python_console)
                tray.add_item(python_item)
                hbox = gtk.HBox()
                hbox.pack_start(tray, False, True, 0)
                hbox.pack_start(self.test_notebook)
                self.test_notebook.show()
                vpaned.pack2(hbox, resize=True)
                vpaned.show_all()
                tray.show()
                hbox.show()
                vbox.show_all()
开发者ID:aguzubiaga,项目名称:sugar-jamedit,代码行数:95,代码来源:activity.py

示例13: __init__

# 需要导入模块: from sugar.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar.graphics.radiotoolbutton.RadioToolButton import connect [as 别名]
    def __init__(self, handle):
        activity.Activity.__init__(self, handle, True)

        # ToolbarBox:

        toolbarbox = ToolbarBox()
        activitybutton = ActivityButton(self)
        toolbarbox.toolbar.insert(activitybutton, 0)

        separator = gtk.SeparatorToolItem()
        toolbarbox.toolbar.insert(separator, -1)

        explorer_btn = RadioToolButton()
        explorer_btn.set_tooltip('Explorador')
        explorer_btn.props.icon_name = 'activity-explorer'
        toolbarbox.toolbar.insert(explorer_btn, -1)

        self._goup = ToolButton('to-subjects')
        self._goup.connect('clicked', self._go_up_clicked)
        self._goup.set_tooltip('Ver Materias')
        self._goup.set_accelerator("<Shift><M>")
        self._goup.set_sensitive(False)
        toolbarbox.toolbar.insert(self._goup, -1)

        self._select_all = ToolButton('select-all')
        self._select_all.set_tooltip('Seleccionar todo')
        self._select_all.connect("clicked", self._select_all_clicked)
        self._select_all.set_sensitive(False)
        toolbarbox.toolbar.insert(self._select_all, -1)

        self._download = ToolButton('download')
        self._download.set_tooltip('Descargar')
        self._download.set_sensitive(False)
        toolbarbox.toolbar.insert(self._download, -1)

        separator = gtk.SeparatorToolItem()
        toolbarbox.toolbar.insert(separator, -1)

        homework_btn = RadioToolButton()
        homework_btn.set_tooltip('Tareas Domiciliarias')
        homework_btn.props.icon_name = 'homework'
        homework_btn.props.group = explorer_btn

        toolbarbox.toolbar.insert(homework_btn, -1)

        open_btn = ToolButton()
        open_btn.set_tooltip('Seleccionar tarea')
        open_btn.props.icon_name = 'open-from-journal'
        open_btn.set_sensitive(False)
        open_btn.connect("clicked", self._select_hw_from_journal)
        toolbarbox.toolbar.insert(open_btn, -1)

        self._send = ToolButton()
        self._send.set_tooltip('Enviar tarea')
        self._send.connect('clicked', self._send_hw_to_server)
        self._send.props.icon_name = 'document-send'
        self._send.set_sensitive(False)
        toolbarbox.toolbar.insert(self._send, -1)

        homework_btn.connect('clicked', self.homework_btn_cb, open_btn)
        explorer_btn.connect('clicked', self.explorer_btn_cb, open_btn)

        separator = gtk.SeparatorToolItem()
        separator.set_expand(True)
        separator.set_draw(False)
        toolbarbox.toolbar.insert(separator, -1)

        stopbtn = StopButton(self)
        toolbarbox.toolbar.insert(stopbtn, -1)

        self.set_toolbar_box(toolbarbox)
        self._one_alert = None

        # Canvas
        self._canvas = gtk.EventBox()
        self._name = ''
        self._last_name = ''
        self._hw_title = ''
        self._hw_description = ''
        self._hw_path = ''
        self._hw_mimetype = ''

        self.set_canvas(self._canvas)
        self.show_all()
        if not utils.get_group():
            self.choose_group()
        else:
            self._do_canvas()
开发者ID:aulavirtual,项目名称:explorador,代码行数:90,代码来源:activity.py

示例14: HomeToolbar

# 需要导入模块: from sugar.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar.graphics.radiotoolbutton.RadioToolButton import connect [as 别名]
class HomeToolbar(gtk.Toolbar):
    __gtype_name__ = 'SugarHomeToolbar'

    __gsignals__ = {
        'query-changed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
                          ([str])),
        'view-changed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
                         ([object])),
    }

    def __init__(self):
        gtk.Toolbar.__init__(self)

        self._query = None
        self._autosearch_timer = None

        self._add_separator()

        tool_item = gtk.ToolItem()
        self.insert(tool_item, -1)
        tool_item.show()

        self.search_entry = iconentry.IconEntry()
        self.search_entry.set_icon_from_name(iconentry.ICON_ENTRY_PRIMARY,
                                              'system-search')
        self.search_entry.add_clear_button()
        self.search_entry.set_width_chars(25)
        self.search_entry.connect('activate', self.__entry_activated_cb)
        self.search_entry.connect('changed', self.__entry_changed_cb)
        tool_item.add(self.search_entry)
        self.search_entry.show()

        self._add_separator(expand=True)

        favorites_button = FavoritesButton()
        favorites_button.connect('toggled', self.__view_button_toggled_cb,
                                 _FAVORITES_VIEW)
        self.insert(favorites_button, -1)
        favorites_button.show()

        self._list_button = RadioToolButton(named_icon='view-list')
        self._list_button.props.group = favorites_button
        self._list_button.props.tooltip = _('List view')
        self._list_button.props.accelerator = _('<Ctrl>2')
        self._list_button.connect('toggled', self.__view_button_toggled_cb,
                            _LIST_VIEW)
        self.insert(self._list_button, -1)
        self._list_button.show()

        self._add_separator()

    def __view_button_toggled_cb(self, button, view):
        if button.props.active:
            self.search_entry.grab_focus()
            self.emit('view-changed', view)

    def _add_separator(self, expand=False):
        separator = gtk.SeparatorToolItem()
        separator.props.draw = False
        if expand:
            separator.set_expand(True)
        else:
            separator.set_size_request(style.GRID_CELL_SIZE,
                                       style.GRID_CELL_SIZE)
        self.insert(separator, -1)
        separator.show()

    def __entry_activated_cb(self, entry):
        if self._autosearch_timer:
            gobject.source_remove(self._autosearch_timer)
        new_query = entry.props.text
        if self._query != new_query:
            self._query = new_query

            self.emit('query-changed', self._query)

    def __entry_changed_cb(self, entry):
        if not entry.props.text:
            entry.activate()
            return

        if self._autosearch_timer:
            gobject.source_remove(self._autosearch_timer)
        self._autosearch_timer = gobject.timeout_add(_AUTOSEARCH_TIMEOUT,
            self.__autosearch_timer_cb)

    def __autosearch_timer_cb(self):
        self._autosearch_timer = None
        self.search_entry.activate()
        return False
开发者ID:nemesiscodex,项目名称:JukyOS-sugar,代码行数:92,代码来源:homebox.py

示例15: size_allocate_cb

# 需要导入模块: from sugar.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar.graphics.radiotoolbutton.RadioToolButton import connect [as 别名]
    def size_allocate_cb(self, widget, event):
        """
        Builds the tag star around the center where the selected
        category is shown.
        """
        self._logger.debug('size_allocate_cb()')
        x, y, width, height = self.fixed.get_allocation()
        self._logger.debug('x: %s, y: %s, w: %s, h: %s', x, y, width, height)
        self.set_size_request(width, height)

        ######################################################################
        # place togglebuttons around the current position in a radio group

        color_fill = profile.get_color().get_fill_color()
        color_stroke = profile.get_color().get_stroke_color()
        button_width, button_height = self.BUTTON_SIZE
        cat_names = get_categories()

        radius = 300 # px
        x_center = width / 2 - 40
        y_center = height / 2 - 40
        step_angle = math.radians(360 / (len(cat_names) + 1)) # plus reset btn

        # add a reset button
        self.reset_selected_btn = RadioToolButton()
        img_name = os.path.join(GeoTag.ICONS_PATH, 'reset.svg')
        icon = gtk.image_new_from_pixbuf(utils.load_svg_image(img_name,
                                                   color_stroke,
                                                   color_fill,
                                                   self.IMG_SIZE))
        self.reset_selected_btn.set_icon_widget(icon)
        self.reset_selected_btn.set_tooltip(_('Reset selected tag.'))
        self.reset_selected_btn.connect('clicked', self.reset_toggled)
        self.reset_selected_btn.show_all()
        self.reset_selected_btn.set_size_request(button_width, button_height)
        self.fixed.put(self.reset_selected_btn,
                       x_center,          # + int(radius * math.sin(i * step_angle)),
                       y_center + radius) # + int(radius * math.cos(i * step_angle)))
        self.reset_selected_btn.set_active(False)

        # read all available categories dynamically
        for i, category in enumerate(cat_names):
            button = RadioToolButton(group=self.reset_selected_btn)
            img_name = os.path.join(GeoTag.ICONS_PATH, category)
            icon = get_gtkimage_from_plugin(img_name, color_stroke, color_fill, self.IMG_SIZE)
            button.set_icon_widget(icon)
            button.set_tooltip(_('Tag some %s.' % category))            # XXX check translation here!!
            button.connect('clicked', self.set_toggled, category)
            button.show_all()
            button.set_size_request(button_width, button_height)
            self.fixed.put(button,
                           x_center + int(radius * math.sin((i + 1) * step_angle)),
                           y_center + int(radius * math.cos((i + 1) * step_angle)))
            button.set_active(False)

        img_name = os.path.join(GeoTag.ICONS_PATH, NONE_CATEGORY)
        self._set_selected(get_gtkimage_from_plugin(img_name, color_stroke,color_fill, self.IMG_SIZE))

        ###################################################################

        self._logger.debug("size_allocation done")
        self.disconnect(self.size_cb) ## use only once
开发者ID:52North,项目名称:glaps,代码行数:64,代码来源:geotagplugin.py


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