當前位置: 首頁>>代碼示例>>Python>>正文


Python RadioToolButton.set_size_request方法代碼示例

本文整理匯總了Python中sugar.graphics.radiotoolbutton.RadioToolButton.set_size_request方法的典型用法代碼示例。如果您正苦於以下問題:Python RadioToolButton.set_size_request方法的具體用法?Python RadioToolButton.set_size_request怎麽用?Python RadioToolButton.set_size_request使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sugar.graphics.radiotoolbutton.RadioToolButton的用法示例。


在下文中一共展示了RadioToolButton.set_size_request方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: size_allocate_cb

# 需要導入模塊: from sugar.graphics.radiotoolbutton import RadioToolButton [as 別名]
# 或者: from sugar.graphics.radiotoolbutton.RadioToolButton import set_size_request [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

示例2: TagStar

# 需要導入模塊: from sugar.graphics.radiotoolbutton import RadioToolButton [as 別名]
# 或者: from sugar.graphics.radiotoolbutton.RadioToolButton import set_size_request [as 別名]
class TagStar(gtk.HBox):
    """
    A L{gtk.HBox} which arranges togglebuttons around the current position
    within a L{gtk.Fixed} widget.

    This is the central tag element, where a user can either tag his current
    position with a category specified in L{geotagplugin.ECategory}. If
    one of the user's already tagged features is selected in the tree, the
    made change action will be handled as an edit.
    """

    IMG_SIZE = (100, 100)
    BUTTON_SIZE = (100, 100)
    EMPTY_LIST_STORE = gtk.ListStore(gobject.TYPE_STRING)

    toggled = NONE_CATEGORY # selected category
    selected = None # gtk.Image displaying selected category

    def __init__(self, toolbar, control):
        gtk.HBox.__init__(self)
        self._logger = logging.getLogger('TagStar')
        self._logger.setLevel(constants.LOG_LEVEL)
        self.toolbar = toolbar
        self.control = control

        self.size_cb = self.connect('size_allocate', self.size_allocate_cb)

        self.fixed = gtk.Fixed()
        self.pack_start(self.fixed)
        self.show_all()

    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

    def reset_toggled(self, button):
        """
        Resets toggled property and combobox liststore.

        @param button: The reset button (can be omitted by passing None).
        @note: If a tag was selected within the L{geotagmodel.GeotagModel},
#.........這裏部分代碼省略.........
開發者ID:52North,項目名稱:glaps,代碼行數:103,代碼來源:geotagplugin.py


注:本文中的sugar.graphics.radiotoolbutton.RadioToolButton.set_size_request方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。