本文整理汇总了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
示例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},
#.........这里部分代码省略.........