本文整理汇总了Python中sugar.graphics.radiotoolbutton.RadioToolButton.set_active方法的典型用法代码示例。如果您正苦于以下问题:Python RadioToolButton.set_active方法的具体用法?Python RadioToolButton.set_active怎么用?Python RadioToolButton.set_active使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sugar.graphics.radiotoolbutton.RadioToolButton
的用法示例。
在下文中一共展示了RadioToolButton.set_active方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_toolbar
# 需要导入模块: from sugar.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar.graphics.radiotoolbutton.RadioToolButton import set_active [as 别名]
def get_toolbar(self):
toolbar = gtk.Toolbar()
radio_adv = RadioToolButton()
radio_adv.set_active(True)
radio_adv.set_label("Avanzada")
radio_adv.set_tooltip("Mostrar biblioteca avanzada")
radio_adv.connect("clicked", self.switch, "advanced")
toolbar.insert(radio_adv, -1)
radio_adv.show()
radio_bas = RadioToolButton(group=radio_adv)
radio_bas.set_label("Simple")
radio_bas.set_tooltip("Mostrar biblioteca sencilla")
radio_bas.connect("clicked", self.switch, "basic")
toolbar.insert(radio_bas, -1)
toolbar.show_all()
return toolbar
示例2: __init__
# 需要导入模块: from sugar.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar.graphics.radiotoolbutton.RadioToolButton import set_active [as 别名]
def __init__(self):
RadioToolButton.__init__(self)
self.props.tooltip = _('Pathway view')
self.props.accelerator = _('<Ctrl>3')
self.props.group = None
favorites_settings = favoritesview.get_settings()
self._layout = favorites_settings.layout
self._update_icon()
# someday, this will be a gtk.Table()
layouts_grid = gtk.HBox()
layout_item = None
for layoutid, layoutclass in sorted(favoritesview.LAYOUT_MAP.items()):
layout_item = RadioToolButton(icon_name=layoutclass.icon_name,
group=layout_item, active=False)
if layoutid == self._layout:
layout_item.set_active(True)
layouts_grid.pack_start(layout_item, fill=False)
layout_item.connect('toggled', self.__layout_activate_cb,
layoutid)
layouts_grid.show_all()
self.props.palette.set_content(layouts_grid)
示例3: Activity
# 需要导入模块: from sugar.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar.graphics.radiotoolbutton.RadioToolButton import set_active [as 别名]
#.........这里部分代码省略.........
# Blank space (separator) and Stop button at the end:
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()
def run_game(self):
spyral.director.init((0,0), fullscreen=False, max_fps=30)
self.game = JUEGO.Juego(self, callback=self.game_ready)
self.box.connect("switch-page", self.redraw)
spyral.director.push(self.game)
self.start()
def run_credits(self, widget):
if not (spyral.director.get_scene()==self.credits):
self.credits = game.credits.Creditos(self.game.size)
spyral.director.push(self.credits)
def start(self):
try:
spyral.director.run(sugar = True)
except AttributeError as detail:
detail2 = traceback.format_exc()
self.box.set_page(0)
self.alert( detail2, "Spyral se ha detenido abruptamente.", 60)
def show_game(self, widget):
self.box.set_page(1)
self.redraw()
def show_editor(self, widget):
if not self.editor:
self.build_editor()
self.box.set_page(2)
self.redraw()
def show_reader(self, widget):
if not self.reader:
self.build_reader()
self.box.set_page(3)
self.redraw()
def restart_game(self, widget):
global JUEGO
import objetos
try:
objetos.reset()
except AttributeError:
pass
self.box.set_page(0)
watch = gtk.gdk.Cursor(gtk.gdk.WATCH)
self.window.set_cursor(watch)
JUEGO = reload(JUEGO)
self.game = JUEGO.Juego(self, callback=self.game_ready)
spyral.director.replace(self.game)
self.start()
def game_ready(self, widget = None):
self.game_button.set_active(True)
self.box.set_page(1)
self._pygamecanvas.grab_focus()
self.window.set_cursor(None)
def read_file(self, file_path):
pass
def write_file(self, file_path):
pass
def can_close(self):
if self.editor:
self.editor.close()
self.box.set_page(0)
try:
spyral.director.quit()
except spyral.exceptions.GameEndException:
pass
finally:
return True
def toggle_console(self, e):
if self._interpreter.props.visible:
self._interpreter.hide()
self._pygamecanvas.grab_focus()
else:
self.p.set_position(160)
self._interpreter.show()
self._interpreter.text.grab_focus()
self.redraw()
def animate_console(self):
easing = spyral.easing.Linear(0,160)
self.p.set_position(0)
示例4: size_allocate_cb
# 需要导入模块: from sugar.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar.graphics.radiotoolbutton.RadioToolButton import set_active [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
示例5: TagStar
# 需要导入模块: from sugar.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar.graphics.radiotoolbutton.RadioToolButton import set_active [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},
#.........这里部分代码省略.........
示例6: SpeakActivity
# 需要导入模块: from sugar.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar.graphics.radiotoolbutton.RadioToolButton import set_active [as 别名]
#.........这里部分代码省略.........
self._face_button = ToolbarButton(
page=self._make_face_bar(),
label=_('Face'),
icon_name='face')
self._face_button.connect('clicked', self._configure_cb)
toolbox.toolbar.insert(self._face_button, -1)
separator = gtk.SeparatorToolItem()
separator.set_draw(False)
separator.set_expand(True)
toolbox.toolbar.insert(separator, -1)
toolbox.toolbar.insert(StopButton(self), -1)
toolbox.show_all()
self.toolbar_box = toolbox
gtk.gdk.screen_get_default().connect('size-changed',
self._configure_cb)
self._first_time = True
self._new_instance()
self._configure_cb()
self._poll_accelerometer()
if self.shared_activity:
# we are joining the activity
self.connect('joined', self._joined_cb)
if self.get_shared():
# we have already joined
self._joined_cb(self)
self._mode_chat.set_active(True)
self._setup_chat_mode()
elif handle.uri:
# XMPP non-sugar3 incoming chat, not sharable
self._activity_button.props.page.share.props.visible = \
False
self._one_to_one_connection(handle.uri)
else:
# we are creating the activity
self.connect('shared', self._shared_cb)
def _toolbar_expanded(self):
if self._activity_button.is_expanded():
return True
if self._voice_button.is_expanded():
return True
if self._face_button.is_expanded():
return True
return False
def _configure_cb(self, event=None):
self._entry.set_size_request(-1, style.GRID_CELL_SIZE)
if self._toolbar_expanded():
self.face.set_size_request(
-1, gtk.gdk.screen_height() - 3 * style.GRID_CELL_SIZE)
self._chat.resize_chat_box(expanded=True)
self._chat.resize_buddy_list()
else:
self.face.set_size_request(
-1, gtk.gdk.screen_height() - 2 * style.GRID_CELL_SIZE)
self._chat.resize_chat_box()
self._chat.resize_buddy_list()
示例7: __init__
# 需要导入模块: from sugar.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar.graphics.radiotoolbutton.RadioToolButton import set_active [as 别名]
def __init__(self, handle):
activity.Activity.__init__(self, handle, True)
self.max_participants = 1
# CHART_OPTIONS
self.x_label = ""
self.y_label = ""
self.chart_color = utils.get_user_fill_color('str')
self.chart_line_color = utils.get_user_stroke_color('str')
self.current_chart = None
self.charts_area = None
self.chart_data = []
# TOOLBARS
toolbarbox = ToolbarBox()
activity_button = ActivityToolbarButton(self)
activity_btn_toolbar = activity_button.page
activity_btn_toolbar.title.connect('changed', self._set_chart_title)
save_as_image = ToolButton("save-as-image")
save_as_image.connect("clicked", self._save_as_image)
save_as_image.set_tooltip(_("Save as image"))
activity_btn_toolbar.insert(save_as_image, -1)
save_as_image.show()
toolbarbox.toolbar.insert(activity_button, 0)
import_freespace = ToolButton("import-freespace")
import_freespace.connect("clicked", self.__import_freespace_cb)
import_freespace.set_tooltip(_("Read Freespace data"))
toolbarbox.toolbar.insert(import_freespace, -1)
import_freespace.show()
import_journal = ToolButton('import-journal')
import_journal.connect('clicked', self.__import_journal_cb)
import_journal.set_tooltip(_('Read Journal data'))
toolbarbox.toolbar.insert(import_journal, -1)
import_journal.show()
import_turtle = ToolButton('import-turtle')
import_turtle.connect('clicked', self.__import_turtle_cb)
import_turtle.set_tooltip(_('Read Turtle data'))
toolbarbox.toolbar.insert(import_turtle, -1)
import_turtle.show()
separator = gtk.SeparatorToolItem()
separator.set_draw(True)
separator.set_expand(False)
toolbarbox.toolbar.insert(separator, -1)
add_vbar_chart = RadioToolButton()
add_vbar_chart.connect("clicked", self._add_chart_cb, "vbar")
add_vbar_chart.set_tooltip(_("Vertical Bar Chart"))
add_vbar_chart.props.icon_name = "vbar"
charts_group = add_vbar_chart
toolbarbox.toolbar.insert(add_vbar_chart, -1)
add_hbar_chart = RadioToolButton()
add_hbar_chart.connect("clicked", self._add_chart_cb, "hbar")
add_hbar_chart.set_tooltip(_("Horizontal Bar Chart"))
add_hbar_chart.props.icon_name = "hbar"
add_hbar_chart.props.group = charts_group
toolbarbox.toolbar.insert(add_hbar_chart, -1)
add_pie_chart = RadioToolButton()
add_pie_chart.connect("clicked", self._add_chart_cb, "pie")
add_pie_chart.set_tooltip(_("Pie Chart"))
add_pie_chart.props.icon_name = "pie"
add_pie_chart.props.group = charts_group
add_pie_chart.set_active(True)
toolbarbox.toolbar.insert(add_pie_chart, -1)
self.chart_type_buttons = [add_vbar_chart,
add_hbar_chart,
add_pie_chart]
separator = gtk.SeparatorToolItem()
separator.set_draw(True)
separator.set_expand(False)
toolbarbox.toolbar.insert(separator, -1)
fullscreen_btn = ToolButton('view-fullscreen')
fullscreen_btn.set_tooltip(_('Fullscreen'))
fullscreen_btn.connect("clicked", self.__fullscreen_cb)
toolbarbox.toolbar.insert(fullscreen_btn, -1)
charthelp.create_help(toolbarbox.toolbar)
separator = gtk.SeparatorToolItem()
separator.set_draw(False)
separator.set_expand(True)
toolbarbox.toolbar.insert(separator, -1)
#.........这里部分代码省略.........
示例8: GeoToolbar
# 需要导入模块: from sugar.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar.graphics.radiotoolbutton.RadioToolButton import set_active [as 别名]
#.........这里部分代码省略.........
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.'))
self.radio_show_all_pos_btn.connect('clicked', view.radio_show_all_position_cb)
self.insert(self.radio_show_all_pos_btn, -1)
self.radio_show_all_pos_btn.show_all()
if self.radio_show_own_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)
self.radio_show_all_pos_btn.set_active(True)
def enable_center_current_position(self, on_center_on_current_position):
"""
Enables tool to set the map center to current lon/lat position.
@param on_goto_current_position: The callback function to be called when
user wants to center the map to current position.
"""
goto_current_pos_btn = ToggleToolButton('goto-current-pos')
goto_current_pos_btn.set_tooltip(_('Center map on my position.'))
goto_current_pos_btn.connect('clicked', on_center_on_current_position)
goto_current_pos_btn.set_active(GeoCanvas._CENTER_MAP)
goto_current_pos_btn.show()
self.insert(goto_current_pos_btn, -1)
def enable_toggle_crosslines(self, view):
"""
Enables tool to toggle crosslines.
@param view: The view for which the crosslines shall be displayed.
"""
toggle_crossline_btn = ToggleToolButton('toggle-crosslines')
toggle_crossline_btn.set_tooltip(_('Show crossline.'))
toggle_crossline_btn.set_active(GeoCanvas._CROSSLINES)
toggle_crossline_btn.connect('clicked', view.toggle_crossline_cb)
toggle_crossline_btn.show()
self.insert(toggle_crossline_btn, -1)
def enable_zoom(self, zoom_callbacks):
"""
Enables tools to zoom the map via buttons.
示例9: SensorToolbar
# 需要导入模块: from sugar.graphics.radiotoolbutton import RadioToolButton [as 别名]
# 或者: from sugar.graphics.radiotoolbutton.RadioToolButton import set_active [as 别名]
#.........这里部分代码省略.........
self._freq_stepper_up = ToolButton("freq-high")
self._freq_stepper_up.set_tooltip(_("Zoom out"))
self._freq_stepper_up.connect("clicked", self._freq_stepper_up_cb)
self._freq_stepper_up.show()
self.activity.adjustmentf = gtk.Adjustment(0.5, self.LOWER, self.UPPER, 0.01, 0.1, 0)
self.activity.adjustmentf.connect("value_changed", self.cb_page_sizef)
self._freq_range = gtk.HScale(self.activity.adjustmentf)
self._freq_range.set_inverted(True)
self._freq_range.set_draw_value(False)
self._freq_range.set_update_policy(gtk.UPDATE_CONTINUOUS)
self._freq_range.set_size_request(120, 15)
self._freq_range.show()
self._freq_stepper_down = ToolButton("freq-low")
self._freq_stepper_down.set_tooltip(_("Zoom in"))
self._freq_stepper_down.connect("clicked", self._freq_stepper_down_cb)
self._freq_stepper_down.show()
self._freq_range_tool = gtk.ToolItem()
self._freq_range_tool.add(self._freq_range)
self._freq_range_tool.show()
toolbox.add(self._freq_stepper_up)
toolbox.add(self._freq_range_tool)
toolbox.add(self._freq_stepper_down)
return
def update_trigger_control_cb(self, button, value):
if button is None:
value = self.activity.wave.TRIGGER_NONE
if self.activity.wave.get_fft_mode():
self.trigger_none.set_active(True)
else:
self.activity.wave.set_trigger(value)
def analog_resistance_voltage_mode_cb(self, button=None, mode_to_set="sound"):
""" Callback for Analog/Resistance/Voltage Buttons """
if self._lock_radio_buttons:
logging.debug("mode selector locked")
self._radio_button_pushed = True
return
if self.mode == mode_to_set:
logging.debug("mode already set to %s" % mode_to_set)
return
self._lock_radio_buttons = True
if self.activity.CONTEXT == "sound":
self.sound_context_off()
else:
self.sensor_context_off()
# Force time domain when switching modes
if self.activity.wave.get_fft_mode():
self.activity.timefreq_control()
# Turn off logging when switching modes
if self.activity.audiograb.we_are_logging:
self.record_control_cb()
self.set_mode(mode_to_set)
if mode_to_set == "sound":
self.set_sound_context()
elif mode_to_set == "resistance":
self.set_sensor_context()
elif mode_to_set == "voltage":
self.set_sensor_context()