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


Python ToggleToolButton.set_active方法代码示例

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


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

示例1: ViewToolbar

# 需要导入模块: from sugar3.graphics.toggletoolbutton import ToggleToolButton [as 别名]
# 或者: from sugar3.graphics.toggletoolbutton.ToggleToolButton import set_active [as 别名]
class ViewToolbar(Gtk.Toolbar):
    __gtype_name__ = 'ViewToolbar'

    __gsignals__ = {
        'go-fullscreen': (GObject.SignalFlags.RUN_FIRST,
                          None,
                          ([])),
        'toggle-playlist': (GObject.SignalFlags.RUN_FIRST,
                            None,
                            ([]))
    }

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

        self._show_playlist = ToggleToolButton('view-list')
        self._show_playlist.set_active(True)  # due to Activity.show_all()
        self._show_playlist.set_tooltip(_('Playlist'))
        self._show_playlist.set_accelerator('<ctrl>l')
        self._show_playlist.connect('toggled', self._playlist_toggled_cb)
        self.insert(self._show_playlist, -1)
        self._show_playlist.show()

        self._fullscreen = ToolButton('view-fullscreen')
        self._fullscreen.set_tooltip(_('Fullscreen'))
        self._fullscreen.set_accelerator('<ctrl>f')
        self._fullscreen.connect('clicked', self._fullscreen_cb)
        self.insert(self._fullscreen, -1)
        self._fullscreen.show()

    def _fullscreen_cb(self, button):
        self.emit('go-fullscreen')

    def _playlist_toggled_cb(self, button):
        self.emit('toggle-playlist')
开发者ID:sugarlabs,项目名称:jukebox-activity,代码行数:37,代码来源:viewtoolbar.py

示例2: __init__

# 需要导入模块: from sugar3.graphics.toggletoolbutton import ToggleToolButton [as 别名]
# 或者: from sugar3.graphics.toggletoolbutton.ToggleToolButton import set_active [as 别名]
    def __init__(self, conf):
        Gtk.Toolbar.__init__(self)

        self.button = ToolbarButton(page=self, icon_name="toolbar-view")

        combo_font = FontComboBox(conf["font"])
        combo_font.connect("changed", self.__font_changed_cb)
        self.insert(combo_font, -1)

        item_font_size = FontSize()
        item_font_size.set_font_size(conf["font-size"])
        item_font_size.connect("changed", self.__font_size_changed_cb)
        self.insert(item_font_size, -1)

        self.insert(utils.make_separator(False), -1)

        button_numbers = ToggleToolButton("show-numbers")
        button_numbers.props.accelerator = "<Ctrl><Mayus>N"
        button_numbers.set_tooltip(_("Show line numbers"))
        button_numbers.set_active(conf["show-line-numbers"])
        button_numbers.connect("toggled", self.__show_line_numbers_changed_cb)
        self.insert(button_numbers, -1)

        button_right_line = ToggleToolButton("show-right-line")
        button_right_line.props.accelerator = "<Ctrl>L"
        button_right_line.set_tooltip(_("Show a line in a specific position"))
        button_right_line.set_active(conf["show-right-line"])
        button_right_line.connect("toggled", self.__show_right_line_changed_cb)
        self.insert(button_right_line, -1)

        adjustement = Gtk.Adjustment(
            value=conf["right-line-pos"],
            lower=1,
            upper=150,
            step_increment=1,
            page_increment=5,
            page_size=0,
        )

        toolItem1 = Gtk.ToolItem()
        self.spinner_right_line = Gtk.SpinButton()
        self.spinner_right_line.set_margin_left(5)
        self.spinner_right_line.set_adjustment(adjustement)

        # Ensuring that the value is displayed when starting:
        self.spinner_right_line.set_value(conf["right-line-pos"])
        self.spinner_right_line.connect('notify::value',
            self.__right_line_pos_changed_cb)

        toolItem1.add(self.spinner_right_line)
        self.insert(toolItem1, -1)

        self.insert(utils.make_separator(False), -1)

        combo_styles = ComboStyles(conf["theme"])
        combo_styles.connect("theme-changed", self.__theme_changed_cb)
        self.insert(combo_styles, -1)

        self.show_all()
开发者ID:sugarlabs,项目名称:cedit-activity,代码行数:61,代码来源:toolbars.py

示例3: __init__

# 需要导入模块: from sugar3.graphics.toggletoolbutton import ToggleToolButton [as 别名]
# 或者: from sugar3.graphics.toggletoolbutton.ToggleToolButton import set_active [as 别名]
    def __init__(self, handle):
        activity.Activity.__init__(self, handle)

        logging.debug('Starting the IRC Activity')
        self.set_title(_('IRC Activity'))

        self.add_events(Gdk.EventMask.VISIBILITY_NOTIFY_MASK)
        self.connect('visibility-notify-event',
                     self.__visibility_notify_event_cb)

        self.is_visible = False

        self.client = purk.Client(self)
        if handle.object_id is None:
            self.default_config()
        self.client.show()
        widget = self.client.get_widget()

        # CANVAS
        self.set_canvas(widget)

        toolbar_box = ToolbarBox()
        self.activity_button = ActivityButton(self)
        toolbar_box.toolbar.insert(self.activity_button, 0)
        self.activity_button.show()

        title_entry = TitleEntry(self)
        toolbar_box.toolbar.insert(title_entry, -1)
        title_entry.show()

        connectionbtn = ToggleToolButton('connect')
        connectionbtn.set_active(True)
        connectionbtn.set_tooltip(_('Disconnect'))
        connectionbtn.connect('toggled', self._connection_cb)
        toolbar_box.toolbar.insert(connectionbtn, -1)
        connectionbtn.show()

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

        stop_button = StopButton(self)
        toolbar_box.toolbar.insert(stop_button, -1)
        stop_button.show()

        self.set_toolbar_box(toolbar_box)
        toolbar_box.show()
开发者ID:sugarlabs,项目名称:irc-activity,代码行数:51,代码来源:ircactivity.py

示例4: __init__

# 需要导入模块: from sugar3.graphics.toggletoolbutton import ToggleToolButton [as 别名]
# 或者: from sugar3.graphics.toggletoolbutton.ToggleToolButton import set_active [as 别名]
    def __init__(self, handle):
        activity.Activity.__init__(self, handle)
        self.set_title('FotoToon')

        self._max_participants = 1
        self.page = None

        toolbar_box = ToolbarBox()
        activity_button = ActivityToolbarButton(self)
        activity_toolbar = activity_button.page
        toolbar_box.toolbar.insert(activity_button, 0)

        edit_toolbar_btn = ToolbarButton()
        edit_toolbar = Gtk.Toolbar()
        edit_toolbar_btn.props.page = edit_toolbar
        edit_toolbar_btn.props.icon_name = 'toolbar-edit'
        edit_toolbar_btn.label = _('Edit')
        toolbar_box.toolbar.insert(edit_toolbar_btn, -1)

        view_toolbar_btn = ToolbarButton()
        view_toolbar = Gtk.Toolbar()
        view_toolbar_btn.props.page = view_toolbar
        view_toolbar_btn.props.icon_name = 'toolbar-view'
        view_toolbar_btn.label = _('View')
        toolbar_box.toolbar.insert(view_toolbar_btn, -1)

        slideview_btn = ToggleToolButton('slideshow')
        slideview_btn.set_tooltip(_('Slideshow'))
        slideview_btn.set_active(False)
        slideview_btn.connect('clicked', self._switch_view_mode, False)
        view_toolbar.insert(slideview_btn, -1)
        slideview_btn.show()

        slideview_timings_btn = ToggleToolButton('slideshow-stopwatch')
        slideview_timings_btn.set_tooltip(_('Slideshow with Timings'))
        slideview_timings_btn.set_active(False)
        slideview_timings_btn.connect('clicked', self._switch_view_mode, True)
        view_toolbar.insert(slideview_timings_btn, -1)
        slideview_timings_btn.show()

        time_button = ToolButton('stopwatch')
        time_button.set_tooltip(_('Set Image Duration in Slideshow (Seconds)'))
        view_toolbar.insert(time_button, -1)
        time_button.show()

        self._time_spin = Gtk.SpinButton.new_with_range(MIN_TIME, MAX_TIME, 1)
        self._time_spin.connect('value-changed', self.__time_spin_changed_cb)
        self._time_spin.props.value = DEFAULT_TIME
        self._time_spin.props.update_policy = \
            Gtk.SpinButtonUpdatePolicy.IF_VALID

        palette = time_button.get_palette()
        palette.connect('popup', self.__time_button_popup_cb)
        time_button.connect(
            'clicked', lambda *args:
            palette.popup(immediate=True, state=Palette.SECONDARY))

        alignment = Gtk.Alignment()
        alignment.set_padding(style.DEFAULT_PADDING, style.DEFAULT_PADDING,
                              style.DEFAULT_PADDING, style.DEFAULT_PADDING)
        alignment.add(self._time_spin)
        self._time_spin.show()
        palette.set_content(alignment)
        alignment.show()

        fullscreen_btn = ToolButton('view-fullscreen')
        fullscreen_btn.set_tooltip(_('Fullscreen'))
        fullscreen_btn.props.accelerator = '<Alt>Return'
        fullscreen_btn.connect('clicked', lambda w: self.fullscreen())
        view_toolbar.insert(fullscreen_btn, -1)
        fullscreen_btn.show()

        self.set_toolbar_box(toolbar_box)

        toolbar = toolbar_box.toolbar

        self.page = Page()

        self.globes_manager = GlobesManager(toolbar, edit_toolbar, self)

        # fonts
        self._text_button = ToolbarButton()
        self._text_button.props.page = TextToolbar(self.page)
        self._text_button.props.icon_name = 'format-text-size'
        self._text_button.props.label = _('Text')
        self._toolbar_box.toolbar.insert(self._text_button, -1)

        reorder_img_btn = ToolButton('thumbs-view')
        reorder_img_btn.set_icon_name('thumbs-view')
        reorder_img_btn.set_tooltip(_('Change image order'))
        reorder_img_btn.connect('clicked', self.__image_order_cb)
        edit_toolbar.insert(reorder_img_btn, -1)
        reorder_img_btn.show()

        bgchange = ToolButton(icon_name='contract-coordinates')
        bgchange.set_tooltip(_('Edit background image'))
        bgchange.connect('clicked', self.__bgchange_clicked_cb)
        edit_toolbar.insert(bgchange, -1)
        bgchange.show()

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

示例5: SpeechToolbar

# 需要导入模块: from sugar3.graphics.toggletoolbutton import ToggleToolButton [as 别名]
# 或者: from sugar3.graphics.toggletoolbutton.ToggleToolButton import set_active [as 别名]
class SpeechToolbar(Gtk.Toolbar):
    def __init__(self, activity):
        GObject.GObject.__init__(self)
        self._activity = activity
        if not speech.supported:
            return
        self.is_paused = False
        self._cnf_client = GConf.Client.get_default()
        self.load_speech_parameters()

        self.sorted_voices = [i for i in speech.voices()]
        self.sorted_voices.sort(self.compare_voices)
        default = 0
        for voice in self.sorted_voices:
            if voice[0] == speech.voice[0]:
                break
            default = default + 1

        # Play button
        self.play_btn = ToggleToolButton("media-playback-start")
        self.play_btn.show()
        self.play_toggled_handler = self.play_btn.connect("toggled", self.play_cb)
        self.insert(self.play_btn, -1)
        self.play_btn.set_tooltip(_("Play / Pause"))

        # Stop button
        self.stop_btn = ToolButton("media-playback-stop")
        self.stop_btn.show()
        self.stop_btn.connect("clicked", self.stop_cb)
        self.stop_btn.set_sensitive(False)
        self.insert(self.stop_btn, -1)
        self.stop_btn.set_tooltip(_("Stop"))

        self.voice_combo = ComboBox()
        for voice in self.sorted_voices:
            self.voice_combo.append_item(voice, voice[0])
        self.voice_combo.set_active(default)

        self.voice_combo.connect("changed", self.voice_changed_cb)
        combotool = ToolComboBox(self.voice_combo)
        self.insert(combotool, -1)
        combotool.show()
        speech.reset_cb = self.reset_buttons_cb
        speech.end_text_cb = self.reset_buttons_cb

    def compare_voices(self, a, b):
        if a[0].lower() == b[0].lower():
            return 0
        if a[0].lower() < b[0].lower():
            return -1
        if a[0].lower() > b[0].lower():
            return 1

    def voice_changed_cb(self, combo):
        speech.voice = combo.props.value
        speech.say(speech.voice[0])
        self.save_speech_parameters()

    def load_speech_parameters(self):
        speech_parameters = {}
        data_path = os.path.join(self._activity.get_activity_root(), "data")
        data_file_name = os.path.join(data_path, "speech_params.json")
        if os.path.exists(data_file_name):
            f = open(data_file_name, "r")
            try:
                speech_parameters = json.load(f)
                speech.voice = speech_parameters["voice"]
            finally:
                f.close()
        else:
            speech.voice = self.get_default_voice()
            logging.error("Default voice %s", speech.voice)

        self._cnf_client.add_dir("/desktop/sugar/speech", GConf.ClientPreloadType.PRELOAD_NONE)
        speech.pitch = self._cnf_client.get_int("/desktop/sugar/speech/pitch")
        speech.rate = self._cnf_client.get_int("/desktop/sugar/speech/rate")
        self._cnf_client.notify_add("/desktop/sugar/speech/pitch", self.__conf_changed_cb, None)
        self._cnf_client.notify_add("/desktop/sugar/speech/rate", self.__conf_changed_cb, None)

    def get_default_voice(self):
        """Try to figure out the default voice, from the current locale
           ($LANG)
           Fall back to espeak's voice called Default."""
        voices = speech.get_all_voices()

        locale = os.environ.get("LANG", "")
        language_location = locale.split(".", 1)[0].lower()
        language = language_location.split("_")[0]
        variant = ""
        if language_location.find("_") > -1:
            variant = language_location.split("_")[1]
        # if the language is es but not es_es default to es_la (latin voice)
        if language == "es" and language_location != "es_es":
            language_location = "es_la"

        best = voices.get(language_location) or voices.get(language) or "default"
        logging.debug("Best voice for LANG %s seems to be %s", locale, best)
        return [best, language, variant]

    def __conf_changed_cb(self, client, connection_id, entry, args):
#.........这里部分代码省略.........
开发者ID:i5o,项目名称:write-activity,代码行数:103,代码来源:speechtoolbar.py

示例6: ToolbarBox

# 需要导入模块: from sugar3.graphics.toggletoolbutton import ToggleToolButton [as 别名]
# 或者: from sugar3.graphics.toggletoolbutton.ToggleToolButton import set_active [as 别名]
from sugar3.graphics.toggletoolbutton import ToggleToolButton

import common


test = common.Test()
test.show()

box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
test.pack_start(box, True, True, 0)
box.show()

toolbar_box = ToolbarBox()
box.pack_start(toolbar_box, False, False, 0)
toolbar_box.show()

favorite_button = ToggleToolButton('emblem-favorite')
favorite_button.set_tooltip('Favorite')
toolbar_box.toolbar.insert(favorite_button, -1)
favorite_button.show()

favorite_button2 = ToggleToolButton('emblem-favorite')
favorite_button2.set_tooltip('Favorite')
toolbar_box.toolbar.insert(favorite_button2, -1)
favorite_button2.set_active(True)
favorite_button2.show()


if __name__ == '__main__':
    common.main(test)
开发者ID:i5o,项目名称:sugar-toolkit-gtk3,代码行数:32,代码来源:toggletoolbutton.py

示例7: __init__

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

        activity.Activity.__init__(self, handle)

        # avahi initialization
        self._service = None

        toolbar_box = ToolbarBox()

        self._vbox = Gtk.VBox()

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

        # get information from gconf
        client = GConf.Client.get_default()
        self._age = client.get_int('/desktop/sugar/user/age')
        self._gender = client.get_string('/desktop/sugar/user/gender')
        if self._gender is None:
            self._gender = 'male'
        teacher = (self._age >= 25)

        # if age is not configured age == 0

        if teacher or self._age == 0:
            teacher_button = ToggleToolButton('%s-7' % self._gender)
            teacher_button.set_tooltip(_('Teacher'))
            teacher_button.show()
            teacher_button.connect('toggled', self.__start_teacher_cb)
            toolbar_box.toolbar.insert(teacher_button, -1)
            if teacher:
                teacher_button.set_active(True)

        if not teacher or self._age == 0:
            student_button = ToggleToolButton('%s-2' % self._gender)
            student_button.set_tooltip(_('Student'))
            student_button.show()
            student_button.connect('toggled', self.__start_student_cb)
            toolbar_box.toolbar.insert(student_button, -1)
            if self._age > 0:
                # is a student
                student_button.set_active(True)

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

        stopbutton = StopButton(self)
        toolbar_box.toolbar.insert(stopbutton, -1)
        stopbutton.show()

        self.set_toolbar_box(toolbar_box)
        toolbar_box.show()

        self.scrolled = Gtk.ScrolledWindow()
        self.scrolled.add_with_viewport(self._vbox)

        self.scrolled.show_all()
        self.set_canvas(self.scrolled)

        self._inhibit_suspend()
开发者ID:godiard,项目名称:classroomexplore,代码行数:66,代码来源:activity.py

示例8: MemorizeActivity

# 需要导入模块: from sugar3.graphics.toggletoolbutton import ToggleToolButton [as 别名]
# 或者: from sugar3.graphics.toggletoolbutton.ToggleToolButton import set_active [as 别名]
class MemorizeActivity(Activity):

    def __init__(self, handle):
        Activity.__init__(self, handle)

        self.play_mode = None

        toolbar_box = ToolbarBox()
        self.set_toolbar_box(toolbar_box)

        self.activity_button = ActivityToolbarButton(self)
        toolbar_box.toolbar.insert(self.activity_button, -1)

        self._memorizeToolbarBuilder = \
            memorizetoolbar.MemorizeToolbarBuilder(self)

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

        self._edit_button = ToggleToolButton('view-source')
        self._edit_button.set_tooltip(_('Edit game'))
        self._edit_button.set_active(False)
        toolbar_box.toolbar.insert(self._edit_button, -1)

        self._createToolbarBuilder = \
            createtoolbar.CreateToolbarBuilder(self)

        separator = Gtk.SeparatorToolItem()
        separator.set_expand(True)
        separator.set_draw(False)
        separator.set_size_request(0, -1)
        toolbar_box.toolbar.insert(separator, -1)

        toolbar_box.toolbar.insert(StopButton(self), -1)

        self.game = game.MemorizeGame()
        # Play game mode
        self.table = cardtable.CardTable()
        self.scoreboard = scoreboard.Scoreboard()
        self.cardlist = cardlist.CardList()
        self.createcardpanel = createcardpanel.CreateCardPanel(self.game)
        self.cardlist.connect('pair-selected',
                              self.createcardpanel.pair_selected)
        self.cardlist.connect(
            'update-create-toolbar',
            self._createToolbarBuilder.update_create_toolbar)
        self.createcardpanel.connect('add-pair',
                                     self.cardlist.add_pair)
        self.createcardpanel.connect('update-pair',
                                     self.cardlist.update_selected)
        self.createcardpanel.connect('change-font',
                                     self.cardlist.change_font)
        self.createcardpanel.connect('pair-closed',
                                     self.cardlist.rem_current_pair)

        self._createToolbarBuilder.connect('create_new_game',
                                           self.cardlist.clean_list)
        self._createToolbarBuilder.connect('create_new_game',
                                           self.createcardpanel.clean)
        self._createToolbarBuilder.connect(
            'create_new_game',
            self._memorizeToolbarBuilder.reset)
        self._createToolbarBuilder.connect('create_equal_pairs',
                                           self.change_equal_pairs)

        self._edit_button.connect('toggled', self._change_mode_bt)

        self.connect('key-press-event', self.table.key_press_event)
        self.table.connect('card-flipped', self.game.card_flipped)
        self.table.connect('card-highlighted', self.game.card_highlighted)

        self.game.connect('set-border', self.table.set_border)
        self.game.connect('flop-card', self.table.flop_card)
        self.game.connect('flip-card', self.table.flip_card)
        self.game.connect('cement-card', self.table.cement_card)
        self.game.connect('highlight-card', self.table.highlight_card)
        self.game.connect('load_mode', self.table.load_msg)

        self.game.connect('msg_buddy', self.scoreboard.set_buddy_message)
        self.game.connect('add_buddy', self.scoreboard.add_buddy)
        self.game.connect('rem_buddy', self.scoreboard.rem_buddy)
        self.game.connect('increase-score', self.scoreboard.increase_score)
        self.game.connect('wait_mode_buddy', self.scoreboard.set_wait_mode)
        self.game.connect('change-turn', self.scoreboard.set_selected)
        self.game.connect('change_game', self.scoreboard.change_game)

        self.game.connect('reset_scoreboard', self.scoreboard.reset)
        self.game.connect('reset_table', self.table.reset)

        self.game.connect('load_game', self.table.load_game)
        self.game.connect('change_game', self.table.change_game)
        self.game.connect('load_game',
                          self._memorizeToolbarBuilder.update_toolbar)
        self.game.connect('change_game',
                          self._memorizeToolbarBuilder.update_toolbar)
        self.game.connect('change_game',
                          self.createcardpanel.update_font_combos)

        self._memorizeToolbarBuilder.connect('game_changed',
                                             self.change_game)

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

示例9: GetIABooksActivity

# 需要导入模块: from sugar3.graphics.toggletoolbutton import ToggleToolButton [as 别名]
# 或者: from sugar3.graphics.toggletoolbutton.ToggleToolButton import set_active [as 别名]

#.........这里部分代码省略.........
        width = int(Gdk.Screen.width() / 4)
        toolbar.search_entry.set_size_request(width, -1)
        book_search_item.add(toolbar.search_entry)
        toolbar.search_entry.show()
        toolbar.insert(book_search_item, -1)
        book_search_item.show()

        toolbar.source_combo = ComboBox()
        toolbar.source_combo.props.sensitive = True
        toolbar.source_changed_cb_id = \
            toolbar.source_combo.connect('changed', self.__source_changed_cb)
        combotool = ToolComboBox(toolbar.source_combo)
        toolbar.insert(combotool, -1)
        combotool.show()

        self.bt_catalogs = ToggleToolButton('books')
        self.bt_catalogs.set_tooltip(_('Catalogs'))
        toolbar.insert(self.bt_catalogs, -1)
        self.bt_catalogs.connect('toggled', self.__toggle_cats_cb)
        if len(self.catalogs) > 0:
            self.bt_catalogs.show()

        if len(self.languages) > 0:
            toolbar.config_toolbarbutton = ToolbarButton()
            toolbar.config_toolbarbutton.props.icon_name = 'preferences-system'
            toolbar.config_toolbarbox = Gtk.Toolbar()
            toolbar.config_toolbarbutton.props.page = toolbar.config_toolbarbox
            toolbar.language_combo = ComboBox()
            toolbar.language_combo.props.sensitive = True
            combotool = ToolComboBox(toolbar.language_combo)
            toolbar.language_combo.append_item('all', _('Any language'))
            for key in self.languages.keys():
                toolbar.language_combo.append_item(key, self.languages[key])
            toolbar.language_combo.set_active(0)
            toolbar.config_toolbarbutton.props.page.insert(combotool, -1)
            toolbar.insert(toolbar.config_toolbarbutton, -1)
            toolbar.config_toolbarbutton.show()
            combotool.show()
            toolbar.language_changed_cb_id = \
                toolbar.language_combo.connect('changed',
                self.__language_changed_cb)

        self._device_manager = devicemanager.DeviceManager()
        self._refresh_sources(toolbar)
        self._device_manager.connect('device-changed',
                self.__device_changed_cb)

        toolbar.search_entry.grab_focus()
        return toolbar

    def __bt_catalogs_clicked_cb(self, button):
        palette = button.get_palette()
        palette.popup(immediate=True, state=palette.SECONDARY)

    def __switch_catalog_cb(self, catalog_name):
        catalog_config = self.catalogs[catalog_name.decode('utf-8')]
        self.__activate_catalog_cb(None, catalog_config)

    def __activate_catalog_cb(self, menu, catalog_config):
        query_language = self.get_query_language()

        self.enable_button(False)
        self.clear_downloaded_bytes()
        self.book_selected = False
        self.listview.handler_block(self.selection_cb_id)
        self.listview.clear()
开发者ID:leonardcj,项目名称:get-books-activity,代码行数:70,代码来源:GetIABooksActivity.py

示例10: PhysicsActivity

# 需要导入模块: from sugar3.graphics.toggletoolbutton import ToggleToolButton [as 别名]
# 或者: from sugar3.graphics.toggletoolbutton.ToggleToolButton import set_active [as 别名]
class PhysicsActivity(activity.Activity):
    def __init__(self, handle):
        super(PhysicsActivity, self).__init__(handle)
        self._collab = CollabWrapper(self)
        self._collab.message.connect(self.__message_cb)
        self.metadata["mime_type"] = "application/x-physics-activity"
        self.add_events(Gdk.EventMask.ALL_EVENTS_MASK | Gdk.EventMask.VISIBILITY_NOTIFY_MASK)

        self.connect("visibility-notify-event", self._focus_event)
        self.connect("window-state-event", self._window_event)

        self.game_canvas = sugargame.canvas.PygameCanvas(self)
        self.game = physics.main(self)

        self.preview = None
        self._sample_window = None

        self._fixed = Gtk.Fixed()
        self._fixed.put(self.game_canvas, 0, 0)

        w = Gdk.Screen.width()
        h = Gdk.Screen.height() - 2 * GRID_CELL_SIZE

        self.game_canvas.set_size_request(w, h)

        self._constructors = {}
        self.build_toolbar()

        self.set_canvas(self._fixed)
        Gdk.Screen.get_default().connect("size-changed", self.__configure_cb)

        logging.debug(os.path.join(activity.get_activity_root(), "data", "data"))
        self.game_canvas.run_pygame(self.game.run)
        self.show_all()
        self._collab.setup()

    def __configure_cb(self, event):
        """ Screen size has changed """
        self.write_file(os.path.join(activity.get_activity_root(), "data", "data"))
        w = Gdk.Screen.width()
        h = Gdk.Screen.height() - 2 * GRID_CELL_SIZE
        pygame.display.set_mode((w, h), pygame.RESIZABLE)
        self.read_file(os.path.join(activity.get_activity_root(), "data", "data"))
        self.game.run(True)

    def read_file(self, file_path):
        self.game.read_file(file_path)

    def write_file(self, file_path):
        self.game.write_file(file_path)

    def get_preview(self):
        """ Custom preview code to get image from pygame. """
        return self.game_canvas.get_preview()

    def build_toolbar(self):
        self.max_participants = 4

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

        create_toolbar = ToolbarButton()
        create_toolbar.props.page = Gtk.Toolbar()
        create_toolbar.props.icon_name = "magicpen"
        create_toolbar.props.label = _("Create")
        toolbar_box.toolbar.insert(create_toolbar, -1)
        self._insert_create_tools(create_toolbar)

        color = ColorToolButton("Color Button")
        color.props.icon_name = "color"
        color.connect("notify::color", self.returnChosenColor)
        toolbar_box.toolbar.insert(color, -1)
        color.show()

        self.randomColor = ToggleToolButton("Random Color")
        self.randomColor.set_tooltip(_("Toggle random color"))
        self.randomColor.props.icon_name = "colorRandom"
        self.randomColor.connect("toggled", self.resetColors)
        toolbar_box.toolbar.insert(self.randomColor, -1)
        self.randomColor.set_active(True)
        self.randomColor.show()

        self._insert_stop_play_button(toolbar_box.toolbar)

        clear_trace = ToolButton("clear-trace")
        clear_trace.set_tooltip(_("Clear Trace Marks"))
        clear_trace.set_accelerator(_("<ctrl>x"))
        clear_trace.connect("clicked", self.clear_trace_cb)
        clear_trace.set_sensitive(False)
        toolbar_box.toolbar.insert(clear_trace, -1)
        clear_trace.show()
        self.clear_trace = clear_trace

        self._insert_clear_all_button(toolbar_box.toolbar)

        load_example = ToolButton("load-sample")
        load_example.set_tooltip(_("Show sample projects"))
        load_example.connect("clicked", self._create_store)
#.........这里部分代码省略.........
开发者ID:sugarlabs,项目名称:physics,代码行数:103,代码来源:activity.py

示例11: MazeActivity

# 需要导入模块: from sugar3.graphics.toggletoolbutton import ToggleToolButton [as 别名]
# 或者: from sugar3.graphics.toggletoolbutton.ToggleToolButton import set_active [as 别名]
class MazeActivity(activity.Activity):

    def __init__(self, handle):
        """Set up the Maze activity."""
        activity.Activity.__init__(self, handle)
        self._busy_count = 0
        self._unbusy_idle_sid = None

        self.build_toolbar()

        self.pservice = PresenceService()
        self.owner = self.pservice.get_owner()

        state = None
        if 'state' in self.metadata:
            state = json.loads(self.metadata['state'])
        self.game = game.MazeGame(self, self.owner, state)
        self.set_canvas(self.game)
        self.game.show()
        self.connect("key_press_event", self.game.key_press_cb)

        self.text_channel = None
        self.my_key = profile.get_pubkey()
        self._alert = None

        if self.shared_activity:
            # we are joining the activity
            self._add_alert(_('Joining a maze'), _('Connecting...'))
            self.connect('joined', self._joined_cb)
            if self.get_shared():
                # we have already joined
                self._joined_cb()
        else:
            # we are creating the activity
            self.connect('shared', self._shared_cb)

    def busy(self):
        if self._busy_count == 0:
            if self._unbusy_idle_sid is not None:
                GLib.source_remove(self._unbusy_idle_sid)
                self._unbusy_idle_sid = None
            self._old_cursor = self.get_window().get_cursor()
            self._set_cursor(Gdk.Cursor.new(Gdk.CursorType.WATCH))
        self._busy_count += 1

    def unbusy(self):
        self._unbusy_idle_sid = GLib.idle_add(self._unbusy_idle_cb)

    def _unbusy_idle_cb(self):
        self._unbusy_idle_sid = None
        self._busy_count -= 1
        if self._busy_count == 0:
            self._set_cursor(self._old_cursor)

    def _set_cursor(self, cursor):
        self.get_window().set_cursor(cursor)
        Gdk.flush()

    def build_toolbar(self):
        """Build our Activity toolbar for the Sugar system."""

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

        separator = Gtk.SeparatorToolItem()
        toolbar_box.toolbar.insert(separator, -1)
        separator.show()

        easier_button = ToolButton('create-easier')
        easier_button.set_tooltip(_('Easier level'))
        easier_button.connect('clicked', self._easier_button_cb)
        toolbar_box.toolbar.insert(easier_button, -1)

        harder_button = ToolButton('create-harder')
        harder_button.set_tooltip(_('Harder level'))
        harder_button.connect('clicked', self._harder_button_cb)
        toolbar_box.toolbar.insert(harder_button, -1)

        separator = Gtk.SeparatorToolItem()
        toolbar_box.toolbar.insert(separator, -1)
        separator.show()

        self.show_trail_button = ToggleToolButton('show-trail')
        self.show_trail_button.set_tooltip(_('Show trail'))
        self.show_trail_button.set_active(True)
        self.show_trail_button.connect('toggled', self._toggled_show_trail_cb)
        toolbar_box.toolbar.insert(self.show_trail_button, -1)

        separator = Gtk.SeparatorToolItem()
        separator.props.draw = False
        separator.set_size_request(0, -1)
        separator.set_expand(True)
        toolbar_box.toolbar.insert(separator, -1)
        separator.show()

        stop_button = StopButton(self)
        toolbar_box.toolbar.insert(stop_button, -1)
        stop_button.show()
#.........这里部分代码省略.........
开发者ID:godiard,项目名称:maze-activity,代码行数:103,代码来源:activity.py

示例12: __init__

# 需要导入模块: from sugar3.graphics.toggletoolbutton import ToggleToolButton [as 别名]
# 或者: from sugar3.graphics.toggletoolbutton.ToggleToolButton import set_active [as 别名]
    def __init__(self, handle):
        activity.Activity.__init__(self, handle)
        self.set_title('FotoToon')

        self._max_participants = 1

        toolbar_box = ToolbarBox()
        activity_button = ActivityToolbarButton(self)
        activity_toolbar = activity_button.page
        toolbar_box.toolbar.insert(activity_button, 0)

        edit_toolbar_btn = ToolbarButton()
        edit_toolbar = Gtk.Toolbar()
        edit_toolbar_btn.props.page = edit_toolbar
        edit_toolbar_btn.props.icon_name = 'toolbar-edit'
        edit_toolbar_btn.label = _('Edit')
        toolbar_box.toolbar.insert(edit_toolbar_btn, -1)

        view_toolbar_btn = ToolbarButton()
        view_toolbar = Gtk.Toolbar()
        view_toolbar_btn.props.page = view_toolbar
        view_toolbar_btn.props.icon_name = 'toolbar-view'
        view_toolbar_btn.label = _('View')
        toolbar_box.toolbar.insert(view_toolbar_btn, -1)

        slideview_btn = ToggleToolButton('slideshow')
        slideview_btn.set_tooltip(_('Slideshow'))
        slideview_btn.set_active(False)
        view_toolbar.insert(slideview_btn, -1)
        slideview_btn.show()

        fullscreen_btn = ToolButton('view-fullscreen')
        fullscreen_btn.set_tooltip(_('Fullscreen'))
        fullscreen_btn.props.accelerator = '<Alt>Return'
        fullscreen_btn.connect('clicked', lambda w: self.fullscreen())
        view_toolbar.insert(fullscreen_btn, -1)
        fullscreen_btn.show()

        self.set_toolbar_box(toolbar_box)

        toolbar = toolbar_box.toolbar

        self.page = Page()

        self.globes_manager = GlobesManager(toolbar, edit_toolbar, self)

        # fonts
        text_button = ToolbarButton()
        text_button.props.page = TextToolbar(self.page)
        text_button.props.icon_name = 'format-text-size'
        text_button.props.label = _('Text')
        slideview_btn.connect('clicked', self._switch_view_mode, text_button)
        toolbar_box.toolbar.insert(text_button, -1)

        reorder_img_btn = ToolButton('thumbs-view')
        reorder_img_btn.set_icon_name('thumbs-view')
        reorder_img_btn.set_tooltip(_('Change image order'))
        reorder_img_btn.connect('clicked', self.__image_order_cb)
        edit_toolbar.insert(reorder_img_btn, -1)
        reorder_img_btn.show()

        bgchange = ToolButton(icon_name='contract-coordinates')
        bgchange.set_tooltip(_('Edit background image'))
        bgchange.connect('clicked', self.__bgchange_clicked_cb)
        edit_toolbar.insert(bgchange, -1)
        bgchange.show()

        separator = Gtk.SeparatorToolItem()
        separator.props.draw = False
        separator.set_expand(True)

        toolbar_box.toolbar.insert(separator, -1)

        stop = StopButton(self)
        toolbar_box.toolbar.insert(stop, -1)

        toolbar_box.show_all()

        # add export button

        separator_2 = Gtk.SeparatorToolItem()
        separator_2.show()
        activity_toolbar.insert(separator_2, -1)

        self.bt_save_as_image = ToolButton()
        self.bt_save_as_image.props.icon_name = 'save-as-image'
        self.bt_save_as_image.connect('clicked', self.write_image)
        self.bt_save_as_image.set_tooltip(_('Save as Image'))
        activity_toolbar.insert(self.bt_save_as_image, -1)
        self.bt_save_as_image.show()

        save_as_pdf = ToolButton()
        save_as_pdf.props.icon_name = 'save-as-pdf'
        save_as_pdf.connect('clicked', self._save_as_pdf)
        save_as_pdf.set_tooltip(_('Save as a Book (PDF)'))
        activity_toolbar.insert(save_as_pdf, -1)
        save_as_pdf.show()

        activity_button.page.title.connect("focus-in-event", self.on_title)

#.........这里部分代码省略.........
开发者ID:samdroid-apps,项目名称:fototoon-activity,代码行数:103,代码来源:historietaactivity.py

示例13: ClockActivity

# 需要导入模块: from sugar3.graphics.toggletoolbutton import ToggleToolButton [as 别名]
# 或者: from sugar3.graphics.toggletoolbutton.ToggleToolButton import set_active [as 别名]
class ClockActivity(activity.Activity):
    """The clock activity displays a simple clock widget.
    """

    def __init__(self, handle):
        """Create and initialize the clock activity.
        """
        super(ClockActivity, self).__init__(handle)

        # TRANS: Title of the activity
        self.set_title(_('What Time Is It?'))

        # TRANS: The format used when writing the time in full
        # letters.  You must take care to use a font size large enough
        # so that kids can read it easily, but also small enough so
        # that all times combination fit on the screen, even when the
        # screen is rotated.  Pango markup:
        # http://www.pygtk.org/docs/pygtk/pango-markup-language.html
        self._TIME_LETTERS_FORMAT = _('<markup>\
<span lang="en" font_desc="Sans 20">%s</span></markup>')

        # TRANS: The format used to display the weekday and date
        # (example: Tuesday 10/21/2008) We recommend to use the same
        # font size as for the time display.  See
        # http://docs.python.org/lib/module-time.html for available
        # strftime formats.  xgettext:no-python-format
        self._DATE_SHORT_FORMAT = _('<markup>\
<span lang="en" font_desc="Sans 20">\
<span foreground="#B20008">%A</span>, \
<span foreground="#5E008C">%m</span>/\
<span foreground="#B20008">%d</span>/\
<span foreground="#9A5200">%Y</span></span></markup>')

        # Should we write the time in full letters?
        self._time_writer = None
        self._time_in_letters = self.get_title()
        self._time_letters = None
        self._date = None
        self._time_speaker = None

        self._write_time = False
        self._speak_time = False
        self._write_date = False
        self._display_mode_buttons = []

        self._make_display()
        self._make_toolbars()

        # Show the activity on the screen
        self.show_all()

        # We want to be notified when the minutes change
        self._clock.connect("time_minute", self._minutes_changed_cb)

        if not self.powerd_running():
            try:
                bus = dbus.SystemBus()
                proxy = bus.get_object('org.freedesktop.ohm',
                                       '/org/freedesktop/ohm/Keystore')
                self.ohm_keystore = dbus.Interface(
                    proxy, 'org.freedesktop.ohm.Keystore')
            except dbus.DBusException:
                self.ohm_keystore = None

    def write_file(self, file_path):
        self.metadata['write-time'] = str(self._write_time)
        self.metadata['write-date'] = str(self._write_date)
        self.metadata['speak-time'] = str(self._speak_time)
        self.metadata['clock-mode'] = str(self._clock._mode)
        logging.debug('Saving metadata %s', (self.metadata['write-time'],
                      self.metadata['write-date'], self.metadata['speak-time'],
                      self.metadata['clock-mode']))
        # Need write a empty file or the read_file is not called
        with open(file_path, 'w') as data:
            data.write('')

    def read_file(self, file_path):
        logging.debug('Reading metadata %s', (self.metadata['write-time'],
                      self.metadata['write-date'], self.metadata['speak-time'],
                      self.metadata['clock-mode']))
        if 'clock-mode' not in self.metadata.keys():
            display_mode = _MODE_SIMPLE_CLOCK
        else:
            display_mode = int(self.metadata['clock-mode'])

        if 'write-time' in self.metadata.keys():
            self._write_time = str(self.metadata['write-time']) == 'True'

        if 'speak-time' in self.metadata.keys():
            self._speak_time = str(self.metadata['speak-time']) == 'True'

        if 'write-date' in self.metadata.keys():
            self._write_date = str(self.metadata['write-date']) == 'True'

        logging.debug('Read values %s', (self._write_time,
                      self._speak_time, self._write_date,
                      display_mode))

        # apply the changes in the UI
        self._display_mode_buttons[display_mode].set_active(True)
#.........这里部分代码省略.........
开发者ID:leonardcj,项目名称:clock-activity,代码行数:103,代码来源:clock.py

示例14: CreateToolbarBuilder

# 需要导入模块: from sugar3.graphics.toggletoolbutton import ToggleToolButton [as 别名]
# 或者: from sugar3.graphics.toggletoolbutton.ToggleToolButton import set_active [as 别名]
class CreateToolbarBuilder(GObject.GObject):

    __gtype_name__ = 'CreateToolbar'

    __gsignals__ = {
        'create_new_game': (GObject.SignalFlags.RUN_FIRST, None, []),
        'create_equal_pairs': (GObject.SignalFlags.RUN_FIRST,
                               None, [GObject.TYPE_PYOBJECT]),
    }

    def __init__(self, activity):
        GObject.GObject.__init__(self)
        self.activity = activity
        self.toolbar = self.activity.get_toolbar_box().toolbar

        self._equal_pairs = ToggleToolButton('pair-non-equals')
        self._equal_pairs.set_tooltip(_('Match different tiles'))
        self._equal_pairs.connect('toggled', self._emit_equal_pairs)
        self.toolbar.insert(self._equal_pairs, -1)

        self._grouped = ToggleToolButton('grouped_game1')
        self._grouped.set_tooltip(_('Mixed tiles game'))
        self._grouped.connect('toggled', self._grouped_cb)
        self.toolbar.insert(self._grouped, -1)

        self._clear_button = ToolButton('edit-clear')
        self._clear_button.set_tooltip(_('Clear all tiles'))
        self._clear_button.connect('clicked', self._clear_game_bt)
        self.toolbar.insert(self._clear_button, -1)

        self.toolbar.show_all()

    def _add_widget(self, widget, expand=False):
        tool_item = Gtk.ToolItem()
        tool_item.set_expand(expand)
        tool_item.add(widget)
        widget.show()
        self.toolbar.insert(tool_item, -1)
        tool_item.show()

    def _clear_game_bt(self, button):
        if self.activity.game.model.is_demo or \
                len(self.activity.cardlist.pairs) == 0:
            self.clear_game()
        else:
            alert = Alert()
            alert.props.title = _('Clear all the tiles from the game?')
            icon = Icon(icon_name='dialog-ok')
            alert.add_button(1, _('Clear'), icon)
            icon = Icon(icon_name='dialog-cancel')
            alert.add_button(0, _('Do not clear'), icon)
            alert.connect('response', self._clear_game_alert_cb)
            self.activity.add_alert(alert)

    def _clear_game_alert_cb(self, alert, response_id):
        self.activity.remove_alert(alert)
        if response_id == 1:
            self.clear_game()

    def clear_game(self):
            self._equal_pairs.set_active(False)
            self._grouped.set_active(False)
            self.emit('create_new_game')

    def update_controls(self, active):
        self._equal_pairs.set_sensitive(active)
        self._grouped.set_sensitive(active)
        self._clear_button.set_sensitive(active)

    def _emit_equal_pairs(self, widget):
        if self._equal_pairs.get_active():
            self._equal_pairs.set_icon_name('pair-equals')
            self._equal_pairs.set_tooltip(_('Match identical tiles'))
            equal_pairs = '1'
        else:
            self._equal_pairs.set_icon_name('pair-non-equals')
            self._equal_pairs.set_tooltip(_('Match different tiles'))
            equal_pairs = '0'
        self.emit('create_equal_pairs', self._equal_pairs.get_active())
        logging.debug('createtoolbar._emit_equal_pairs')

        if self.activity.game.model.data['equal_pairs'] != equal_pairs:
            self.activity.game.model.data['equal_pairs'] = equal_pairs
            self.activity.game.model.mark_modified()

    def _grouped_cb(self, widget):
        if self._grouped.get_active():
            self._grouped.set_icon_name('grouped_game2')
            self._grouped.set_tooltip(_('Grouped tiles game'))
            divided = '1'
        else:
            self._grouped.set_icon_name('grouped_game1')
            self._grouped.set_tooltip(_('Mixed tiles game'))
            divided = '0'
        logging.debug('createtoolbar._grouped_cb')

        if self.activity.game.model.data['divided'] != divided:
            self.activity.game.model.data['divided'] = divided
            self.activity.game.model.mark_modified()

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

示例15: SpeechToolbar

# 需要导入模块: from sugar3.graphics.toggletoolbutton import ToggleToolButton [as 别名]
# 或者: from sugar3.graphics.toggletoolbutton.ToggleToolButton import set_active [as 别名]
class SpeechToolbar(Gtk.Toolbar):

    def __init__(self, activity):
        Gtk.Toolbar.__init__(self)
        self._activity = activity
        if not speech.supported:
            return
        self.is_paused = False

        self._cnf_client = GConf.Client.get_default()
        self.load_speech_parameters()

        self.sorted_voices = [i for i in speech.voices()]
        self.sorted_voices.sort(self.compare_voices)
        default = 0
        for voice in self.sorted_voices:
            if voice[0] == speech.voice[0]:
                break
            default = default + 1

        # Play button
        self.play_btn = ToggleToolButton('media-playback-start')
        self.play_btn.show()
        self.play_btn.connect('toggled', self.play_cb)
        self.insert(self.play_btn, -1)
        self.play_btn.set_tooltip(_('Play / Pause'))

        # Stop button
        self.stop_btn = ToolButton('media-playback-stop')
        self.stop_btn.show()
        self.stop_btn.connect('clicked', self.stop_cb)
        self.stop_btn.set_sensitive(False)
        self.insert(self.stop_btn, -1)
        self.stop_btn.set_tooltip(_('Stop'))

        self.voice_combo = ComboBox()
        for voice in self.sorted_voices:
            self.voice_combo.append_item(voice, voice[0])
        self.voice_combo.set_active(default)

        self.voice_combo.connect('changed', self.voice_changed_cb)
        combotool = ToolComboBox(self.voice_combo)
        self.insert(combotool, -1)
        combotool.show()
        speech.reset_buttons_cb = self.reset_buttons_cb

    def compare_voices(self,  a,  b):
        if a[0].lower() == b[0].lower():
            return 0
        if a[0] .lower() < b[0].lower():
            return -1
        if a[0] .lower() > b[0].lower():
            return 1

    def voice_changed_cb(self, combo):
        speech.voice = combo.props.value
        speech.say(speech.voice[0])
        self.save_speech_parameters()

    def load_speech_parameters(self):
        speech_parameters = {}
        data_path = os.path.join(self._activity.get_activity_root(), 'data')
        data_file_name = os.path.join(data_path, 'speech_params.json')
        if os.path.exists(data_file_name):
            f = open(data_file_name, 'r')
            try:
                speech_parameters = json.load(f)
                speech.voice = speech_parameters['voice']
            finally:
                f.close()

        self._cnf_client.add_dir('/desktop/sugar/speech',
                                 GConf.ClientPreloadType.PRELOAD_NONE)
        speech.pitch = self._cnf_client.get_int('/desktop/sugar/speech/pitch')
        speech.rate = self._cnf_client.get_int('/desktop/sugar/speech/rate')
        self._cnf_client.notify_add('/desktop/sugar/speech/pitch',
                                    self.__conf_changed_cb, None)
        self._cnf_client.notify_add('/desktop/sugar/speech/rate',
                                    self.__conf_changed_cb, None)

    def __conf_changed_cb(self, client, connection_id, entry, args):
        key = entry.get_key()
        value = client.get_int(key)
        if key == '/desktop/sugar/speech/pitch':
            speech.pitch = value
        if key == '/desktop/sugar/speech/rate':
            speech.rate = value

    def save_speech_parameters(self):
        speech_parameters = {}
        speech_parameters['voice'] = speech.voice
        data_path = os.path.join(self._activity.get_activity_root(), 'data')
        data_file_name = os.path.join(data_path, 'speech_params.json')
        f = open(data_file_name, 'w')
        try:
            json.dump(speech_parameters, f)
        finally:
            f.close()

    def reset_buttons_cb(self):
#.........这里部分代码省略.........
开发者ID:icarito,项目名称:read-activity,代码行数:103,代码来源:speechtoolbar.py


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