本文整理汇总了Python中sugar.graphics.radiotoolbutton.RadioToolButton.show_all方法的典型用法代码示例。如果您正苦于以下问题:Python RadioToolButton.show_all方法的具体用法?Python RadioToolButton.show_all怎么用?Python RadioToolButton.show_all使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sugar.graphics.radiotoolbutton.RadioToolButton
的用法示例。
在下文中一共展示了RadioToolButton.show_all方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TagStar
# 需要导入模块: from sugar.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar.graphics.radiotoolbutton.RadioToolButton import show_all [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},
#.........这里部分代码省略.........
示例2: size_allocate_cb
# 需要导入模块: from sugar.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar.graphics.radiotoolbutton.RadioToolButton import show_all [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
示例3: GeoToolbar
# 需要导入模块: from sugar.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar.graphics.radiotoolbutton.RadioToolButton import show_all [as 别名]
class GeoToolbar(gtk.Toolbar):
"""
Tools which interacts with the currently chosen view.
This toolbar is meant general: General map tools can be enabled. The
toolbar serves as controller. Because you use a specific geo you have
to wire specific functionality to the common tools offered by this toolbar.
Tools you may want to enable:
=========== ==========================
enable_goto_current_position
User wants to center map over current
position.
toggle_crosslines
User wants to show crosslines.
navigation
User wants to navigate the map. Includes
buttons for NESW.
zoom-in
User wants to zoom-in the current map view.
zoom-out
User wants to zoom-out the current map view.
zoom-bestfit
User wants to zoom-in the current map view.
=========== ==========================
Enable one of these tools by calling the appropriate method with your
custom callback method before adding the toolbar to the toolbox.
"""
title = _('Map tools')
radio_show_own_pos_btn = None
radio_show_all_pos_btn = None
def __init__(self, view, name=None):
"""
Creates general toolbar where general map tools can be enabled.
@param name: The name of the toolbar.
"""
gtk.Toolbar.__init__(self)
self.set_property('can-focus', False)
self.view = view
if name:
self.name = name
self._logger = logging.getLogger(name)
else:
self._logger = logging.getLogger('geo.GeoToolbar')
self._logger.setLevel(constants.LOG_LEVEL)
# remove predefined key bindings
gtk.binding_entry_remove(self, gtk.keysyms.Left, 0)
gtk.binding_entry_remove(self, gtk.keysyms.Right, 0)
gtk.binding_entry_remove(self, gtk.keysyms.Up, 0)
gtk.binding_entry_remove(self, gtk.keysyms.Down, 0)
gtk.binding_entry_remove(self, gtk.keysyms.plus, 0)
gtk.binding_entry_remove(self, gtk.keysyms.minus, 0)
self.callbacks = {}
self.connect('key-press-event', self.key_pressed_cb, self.callbacks)
self.show_no_positions = RadioToolButton()
icon_name = os.path.join(constants.ICON_PATH, "show-no-positions.svg")
icon = utils.load_svg_image(icon_name, None, None, BTN_ICON_SIZE)
img = gtk.image_new_from_pixbuf(icon)
self.show_no_positions.set_icon_widget(img)
self.show_no_positions.set_tooltip(_('Show no players.'))
def enable_show_own_position(self, view):
"""
Shows the only the own position on the map.
"""
self.radio_show_own_pos_btn = RadioToolButton(group=self.show_no_positions)
(fill, stroke) = ('#ffffff', '#000000') # black/white explicit
buddy_icon = utils.get_xo_icon(stroke, fill, BTN_ICON_SIZE)
img = gtk.image_new_from_pixbuf(buddy_icon)
self.radio_show_own_pos_btn.set_icon_widget(img)
self.radio_show_own_pos_btn.set_tooltip(_('Show only me.'))
self.radio_show_own_pos_btn.connect('clicked', view.radio_show_own_position_cb)
self.insert(self.radio_show_own_pos_btn, -1)
self.radio_show_own_pos_btn.show_all()
if self.radio_show_all_pos_btn:
self.show_no_positions.connect("clicked", view.radio_show_no_positions_cb)
self.show_no_positions.show_all()
self.insert(self.show_no_positions, -1)
def enable_show_all_positions(self, view):
"""
Shows the position of all players participating the game.
"""
self.radio_show_all_pos_btn = RadioToolButton(group=self.show_no_positions)
icon_name = os.path.join(constants.ICON_PATH , 'show-all-players.svg')
icon = utils.load_svg_image(icon_name, None, None, BTN_ICON_SIZE)
img = gtk.image_new_from_pixbuf(icon)
self.radio_show_all_pos_btn.set_icon_widget(img)
self.radio_show_all_pos_btn.set_tooltip(_('Show all players.'))
#.........这里部分代码省略.........