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


Python ToolbarButton.set_sensitive方法代码示例

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


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

示例1: HistorietaActivity

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

#.........这里部分代码省略.........

        pipeline.set_state(Gst.State.PLAYING)
        pipeline.get_bus().timed_pop_filtered(
            Gst.CLOCK_TIME_NONE, Gst.MessageType.ERROR | Gst.MessageType.EOS)
        pipeline.set_state(Gst.State.NULL)

        jobject = datastore.create()
        jobject.metadata['icon-color'] = profile.get_color().to_string()
        jobject.metadata['mime_type'] = 'video/ogg'
        jobject.metadata['title'] = \
            _('{} as a movie').format(self.metadata['title'])
        jobject.file_path = output_path

        datastore.write(jobject, transfer_ownership=True)
        self._object_id = jobject.object_id

        self._show_journal_alert(_('Success'),
                                 _('A movie was saved in the Journal'))
        shutil.rmtree(directory)

    def _show_journal_alert(self, title, msg):
        _stop_alert = Alert()
        _stop_alert.props.title = title
        _stop_alert.props.msg = msg
        _stop_alert.add_button(Gtk.ResponseType.APPLY,
                               _('Show in Journal'),
                               Icon(icon_name='zoom-activity'))
        _stop_alert.add_button(Gtk.ResponseType.OK, _('Ok'),
                               Icon(icon_name='dialog-ok'))
        # Remove other alerts
        for alert in self._alerts:
            self.remove_alert(alert)

        self.add_alert(_stop_alert)
        _stop_alert.connect('response', self.__stop_response_cb)
        _stop_alert.show_all()

    def __stop_response_cb(self, alert, response_id):
        if response_id is Gtk.ResponseType.APPLY:
            activity.show_object_in_journal(self._object_id)
        self.remove_alert(alert)

    def _get_preview_image(self, file_name):
        preview_width, preview_height = style.zoom(300), style.zoom(225)

        pixbuf = GdkPixbuf.Pixbuf.new_from_file(file_name)
        width, height = pixbuf.get_width(), pixbuf.get_height()

        scale = 1
        if (width > preview_width) or (height > preview_height):
            scale_x = preview_width / float(width)
            scale_y = preview_height / float(height)
            scale = min(scale_x, scale_y)

        pixbuf2 = GdkPixbuf.Pixbuf.new(
            GdkPixbuf.Colorspace.RGB, pixbuf.get_has_alpha(),
            pixbuf.get_bits_per_sample(), preview_width, preview_height)
        pixbuf2.fill(style.COLOR_WHITE.get_int())

        margin_x = int((preview_width - (width * scale)) / 2)
        margin_y = int((preview_height - (height * scale)) / 2)

        pixbuf.scale(pixbuf2, margin_x, margin_y,
                     preview_width - (margin_x * 2),
                     preview_height - (margin_y * 2),
                     margin_x, margin_y, scale, scale,
                     GdkPixbuf.InterpType.BILINEAR)

        succes, preview_data = pixbuf2.save_to_bufferv('png', [], [])
        return dbus.ByteArray(preview_data)

    def _switch_view_mode(self, widget, use_timings):
        if widget.get_active():
            self._notebook.set_current_page(1)
            self._slideview.stop()
            self._slideview.set_boxes(self.page.boxs)
            self._slideview.set_current_box(0)
            self._slideview.start(use_timings)
            # disable edition mode in the globes
            for box in self.page.boxs:
                box.set_globo_activo(None)

            self._key_press_signal_id = self.connect(
                'key_press_event', self._slideview.key_press_cb)
        else:
            self._slideview.stop()
            self._notebook.set_current_page(0)
            if self._key_press_signal_id is not None:
                self.disconnect(self._key_press_signal_id)
        self.globes_manager.set_buttons_sensitive(not widget.get_active())
        self._text_button.set_sensitive(not widget.get_active())

    def __time_button_popup_cb(self, palette):
        self._time_spin.props.value = \
            self.page.get_active_box().slideshow_duration

    def __time_spin_changed_cb(self, button):
        if self.page:
            self.page.get_active_box().slideshow_duration = \
                self._time_spin.props.value
开发者ID:quozl,项目名称:fototoon-activity,代码行数:104,代码来源:historietaactivity.py

示例2: RulerActivity

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

#.........这里部分代码省略.........

        # The ever-present Stop Button
        stop_button = StopButton(self)
        stop_button.props.accelerator = '<Ctrl>Q'
        toolbar_box.toolbar.insert(stop_button, -1)
        stop_button.show()

        self.set_toolbar_box(toolbar_box)
        toolbar_box.show()

        self.show_all()

        # Restore state if previously saved
        self._ready = True
        if 'ruler' in self.metadata and \
           self.metadata['ruler'] in self.button_dict:
            _logger.debug('restoring %s', self.metadata['ruler'])
            self.button_dict[self.metadata['ruler']].set_active(True)
            self.callback_dict[self.metadata['ruler']]
        else:
            self._rulers_cb()
            self.rulers.set_active(True)

        if 'custom_unit' in self.metadata:
            self.custom_unit_entry.set_text(str(self.metadata['custom_unit']))
        else: # set the default
            self.custom_unit_entry.set_text("25.4")

    #
    # Button callbacks
    #
    def _rulers_cb(self, button=None):
        if self._ready:
            self.custom_units_button.set_sensitive(True)
            self._current = self._r
            self._canvas.add_a_ruler(self._current)
            _logger.debug('selecting ruler')
            self.metadata['ruler'] = 'ruler'
        return False

    def custom_unit_change_cb(self, widget):
        try:
            new = float(widget.get_text())
        except ValueError:
            new = MMPERINCH
        new = abs(new)
        if new == 0:
            new = MMPERINCH
            if widget.get_text != '':
                widget.set_text(str(new))
        self._canvas.add_a_ruler(self._r)
        self._r.custom_unit_in_mm = new
        self._r.draw_custom_ruler(self._r.custom_unit_in_mm)
        self.metadata['custom_unit'] = new

    def _grids_cb(self, button=None):
        if self._ready:
            self.custom_units_button.set_sensitive(False)
            self.custom_units_button.set_expanded(False)
            if self._grids_mode == "cm":
                self._current = self._gcm
                if hasattr(self, 'grids'):
                    self.grids.set_icon_name("grid-c")
                self._grids_mode = "mm"
            else:
                self._current = self._gmm
开发者ID:leonardcj,项目名称:ruler,代码行数:70,代码来源:RulerActivity.py


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