本文整理汇总了Python中sugar3.profile.get_color函数的典型用法代码示例。如果您正苦于以下问题:Python get_color函数的具体用法?Python get_color怎么用?Python get_color使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_color函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, handle):
""" Initialize the toolbars and the game board """
super(PathsActivity, self).__init__(handle)
self.nick = profile.get_nick_name()
if profile.get_color() is not None:
self.colors = profile.get_color().to_string().split(',')
else:
self.colors = ['#A0FFA0', '#FF8080']
self._setup_toolbars()
self._setup_dispatch_table()
# Create a canvas
canvas = Gtk.DrawingArea()
canvas.set_size_request(Gdk.Screen.width(), Gdk.Screen.height())
self.set_canvas(canvas)
canvas.show()
self.show_all()
self._game = Game(canvas, parent=self, colors=self.colors)
self._setup_presence_service()
# Restore game state from Journal or start new game
if 'deck' in self.metadata:
self._restore()
else:
self._game.new_game()
示例2: __init__
def __init__(self, handle):
""" Initialize the toolbars and the game board """
try:
super(FlipActivity, self).__init__(handle)
except dbus.exceptions.DBusException as e:
_logger.error(str(e))
self.nick = profile.get_nick_name()
if profile.get_color() is not None:
self.colors = profile.get_color().to_string().split(',')
else:
self.colors = ['#A0FFA0', '#FF8080']
self._setup_toolbars()
self._setup_dispatch_table()
# Create a canvas
canvas = Gtk.DrawingArea()
canvas.set_size_request(Gdk.Screen.width(),
Gdk.Screen.height())
self.set_canvas(canvas)
canvas.show()
self.show_all()
self._game = Game(canvas, parent=self, colors=self.colors)
self._setup_presence_service()
if 'dotlist' in self.metadata:
self._restore()
else:
self._game.new_game()
示例3: __init__
def __init__(self, handle):
""" Initialize the toolbars and the game board """
try:
super(XOEditorActivity, self).__init__(handle)
except dbus.exceptions.DBusException as e:
_logger.error(str(e))
self.nick = profile.get_nick_name()
if profile.get_color() is not None:
self.colors = profile.get_color().to_string().split(',')
else:
self.colors = ['#A0FFA0', '#FF8080']
self.level = 0
self._setup_toolbars(_have_toolbox)
# Create a canvas
canvas = Gtk.DrawingArea()
canvas.set_size_request(Gdk.Screen.width(),
Gdk.Screen.height())
self.set_canvas(canvas)
canvas.show()
self.show_all()
self._game = Game(canvas, parent=self, mycolors=self.colors)
# Read the dot positions from the Journal
for i in range(len(colors)):
if 'x%d' % (i) in self.metadata and 'y%d' % (i) in self.metadata:
self._game.move_dot(i, int(self.metadata['x%d' % (i)]),
int(self.metadata['y%d' % (i)]))
if 'xox' in self.metadata and 'xoy' in self.metadata:
self._game.move_xo_man(int(self.metadata['xox']),
int(self.metadata['xoy']))
示例4: __init__
def __init__(self, handle):
""" Initialize the toolbars and the game board """
super(RecallActivity, self).__init__(handle)
self.path = activity.get_bundle_path()
self.nick = profile.get_nick_name()
if profile.get_color() is not None:
self.colors = profile.get_color().to_string().split(",")
else:
self.colors = ["#A0FFA0", "#FF8080"]
self._restoring = False
self._setup_toolbars(True)
self._setup_dispatch_table()
# Create a canvas
canvas = Gtk.DrawingArea()
canvas.set_size_request(Gdk.Screen.width(), Gdk.Screen.height())
self.set_canvas(canvas)
canvas.show()
self.show_all()
self._game = Game(canvas, parent=self, path=self.path, colors=self.colors)
self._setup_presence_service()
if "dotlist" in self.metadata:
self._restore()
else:
self._game.new_game()
示例5: __init__
def __init__(self, title, url, owner_document):
Palette.__init__(self)
self._title = title
self._url = url
self._owner_document = owner_document
self.props.primary_text = title
self.props.secondary_text = url
menu_item = MenuItem(_('Keep image'))
icon = Icon(icon_name='document-save', xo_color=profile.get_color(),
icon_size=Gtk.IconSize.MENU)
menu_item.set_image(icon)
menu_item.connect('activate', self.__download_activate_cb)
self.menu.append(menu_item)
menu_item.show()
menu_item = MenuItem(_('Copy image'))
icon = Icon(icon_name='edit-copy', xo_color=profile.get_color(),
icon_size=Gtk.IconSize.MENU)
menu_item.set_image(icon)
menu_item.connect('activate', self.__copy_activate_cb)
self.menu.append(menu_item)
menu_item.show()
示例6: __init__
def __init__(self, handle):
''' Initiate activity. '''
super(FractionBounceActivity, self).__init__(handle)
self.nick = profile.get_nick_name()
if profile.get_color() is not None:
self._colors = profile.get_color().to_string().split(',')
else:
self._colors = ['#A0FFA0', '#FF8080']
self.max_participants = 4 # sharing
self._playing = True
self._setup_toolbars()
self._setup_dispatch_table()
canvas = self._setup_canvas()
# Read any custom fractions from the project metadata
if 'custom' in self.metadata:
custom = self.metadata['custom']
else:
custom = None
self._current_ball = 'soccerball'
self._toolbar_was_expanded = False
# Initialize the canvas
self._bounce_window = Bounce(canvas, activity.get_bundle_path(), self)
Gdk.Screen.get_default().connect('size-changed', self._configure_cb)
# Restore any custom fractions
if custom is not None:
fractions = custom.split(',')
for f in fractions:
self._bounce_window.add_fraction(f)
if self.shared_activity:
# We're joining
if not self.get_shared():
xocolors = XoColor(profile.get_color().to_string())
share_icon = Icon(icon_name='zoom-neighborhood',
xo_color=xocolors)
self._joined_alert = NotifyAlert()
self._joined_alert.props.icon = share_icon
self._joined_alert.props.title = _('Please wait')
self._joined_alert.props.msg = _('Starting connection...')
self._joined_alert.connect('response', self._alert_cancel_cb)
self.add_alert(self._joined_alert)
self._label.set_label(_('Wait for the sharer to start.'))
# Wait for joined signal
self.connect("joined", self._joined_cb)
self._setup_sharing()
示例7: _get_colors
def _get_colors(self):
colors = None
if self._tw.running_sugar:
if profile.get_color() is not None:
colors = profile.get_color().to_string()
else:
colors = self._activity.get_colors()
if colors is None:
colors = '%s,%s' % (DEFAULT_TURTLE_COLORS[0],
DEFAULT_TURTLE_COLORS[1])
return colors.split(',')
示例8: __members_changed_cb
def __members_changed_cb(self, adhoc_manager, channel, has_members):
if channel == self._channel:
if has_members is True:
self._state_color = profile.get_color()
else:
color = '%s,%s' % (profile.get_color().get_stroke_color(),
style.COLOR_TRANSPARENT.get_svg())
self._state_color = XoColor(color)
if not self._filtered:
self.props.base_color = self._state_color
self._palette_icon.props.xo_color = self._state_color
self.alpha = 1.0
else:
self.alpha = _FILTERED_ALPHA
示例9: _update
def _update(self):
state = self._device_state
if (state >= network.NM_DEVICE_STATE_PREPARE) and \
(state <= network.NM_DEVICE_STATE_IP_CONFIG):
self._icon.props.base_color = self._inactive_color
self._icon.props.pulse_color = profile.get_color()
self._palette.set_connecting()
self._icon.props.pulsing = True
elif state == network.NM_DEVICE_STATE_ACTIVATED:
address = self._device_props.Get(network.NM_DEVICE_IFACE, 'Ip4Address')
self._palette.set_connected_with_channel(self._channel, address)
self._icon.props.base_color = profile.get_color()
self._icon.props.pulsing = False
self._update_text()
示例10: __init__
def __init__(self, cb_object, group):
RadioToolButton.__init__(self, group=group)
self.props.palette_invoker = FrameWidgetInvoker(self)
self.palette_invoker.props.toggle_palette = True
self._cb_object = cb_object
self.owns_clipboard = False
self.props.sensitive = False
self.props.active = False
self._notif_icon = None
self._current_percent = None
self._icon = Icon()
color = profile.get_color()
self._icon.props.xo_color = color
self.set_icon_widget(self._icon)
self._icon.show()
cb_service = clipboard.get_instance()
cb_service.connect('object-state-changed',
self._object_state_changed_cb)
cb_service.connect('object-selected', self._object_selected_cb)
child = self.get_child()
child.connect('drag_data_get', self._drag_data_get_cb)
self.connect('notify::active', self._notify_active_cb)
示例11: read_file
def read_file(self, file_path):
if 'icon-color' in self.metadata:
color = self.metadata['icon-color']
else:
color = profile.get_color().to_string()
self.change_game(None, file_path, 4, 'file',
self.metadata['title'], color)
示例12: export_font
def export_font(self):
"""
Export the current font loaded in globals.FONT as a .otf file.
The file will be saved in the activity data folder
"""
# create the file path
file_path =\
os.path.join(self.get_activity_root(),
'data', '%s.otf' % self.get_title)
# save the otf
globals.FONT.export_binary(file_path)
# create a journal entry
jobject = datastore.create()
jobject.metadata['icon-color'] = profile.get_color().to_string()
jobject.metadata['mime_type'] = 'application/x-font-opentype'
jobject.metadata['title'] = '%s.otf' % self.get_title
jobject.file_path = file_path
datastore.write(jobject, transfer_ownership=True)
self._object_id = jobject.object_id
success_title = 'Success'
success_msg = 'A OTF Font file was created in the Journal'
self._show_journal_alert(_(success_title), _(success_msg))
示例13: _comment_activate_cb
def _comment_activate_cb(self, entry):
text = entry.props.text
if not 'comments' in self._reflection.data:
self._reflection.data['comments'] = []
data = {'nick': profile.get_nick_name(),
'color': self._reflection.activity.fg_color.get_html(),
'comment': text}
self._reflection.data['comments'].append(data)
self.add_new_comment(data)
# Send the comment
if self._reflection.activity.sharing:
send_data = data.copy()
send_data["obj_id"] = self._reflection.data["obj_id"]
self._reflection.activity.send_event(COMMENT_CMD, send_data)
entry.set_text('')
# Update journal entry
dsobj = datastore.get(self._reflection.data['obj_id'])
if 'comments' in dsobj.metadata:
data = json.loads(dsobj.metadata['comments'])
else:
data = []
data.append({'from': profile.get_nick_name(),
'message': text,
'icon-color': profile.get_color().to_string()})
dsobj.metadata['comments'] = json.dumps(data)
datastore.write(dsobj,
update_mtime=False,
reply_handler=self.datastore_write_cb,
error_handler=self.datastore_write_error_cb)
示例14: load_object
def load_object(self, full_path, filename):
if self.set_to_page_like(full_path):
return
scrollwnd = Gtk.ScrolledWindow()
scrollwnd.set_policy(Gtk.PolicyType.AUTOMATIC,
Gtk.PolicyType.AUTOMATIC)
page = GtkSourceview2Page(full_path)
page.set_theme(self.theme_state)
page.set_font_size(self.font_size)
vbox = Gtk.VBox()
if full_path.endswith('.svg'):
icon = Icon(file=full_path, pixel_size=100,
xo_color=profile.get_color())
vbox.pack_start(icon, False, False, 0)
vbox.pack_start(scrollwnd, True, True, 0)
scrollwnd.add(page)
vbox.page = page
label = filename
page.text_buffer.connect('changed', self.__text_changed_cb)
tablabel = TabLabel(scrollwnd, label)
tablabel.connect(
'tab-close',
lambda widget, child: self.remove_page(self.page_num(child)))
tablabel.page = page
self.append_page(vbox, tablabel)
self.__text_changed_cb(page.text_buffer)
self.show_all()
self.set_current_page(-1)
示例15: _comment_activate_cb
def _comment_activate_cb(self, entry):
text = entry.props.text
if not "comments" in self._reflection.data:
self._reflection.data["comments"] = []
data = {
"nick": profile.get_nick_name(),
"color": self._reflection.activity.fg_color.get_html(),
"comment": text,
}
self._reflection.data["comments"].append(data)
self.add_new_comment(data)
# Send the comment
if self._reflection.activity.sharing:
self._reflection.activity.send_event(
"%s|%s|%s|%s|%s"
% (COMMENT_CMD, self._reflection.data["obj_id"], data["nick"], data["color"], data["comment"])
)
entry.set_text("")
# Update journal entry
dsobj = datastore.get(self._reflection.data["obj_id"])
if "comments" in dsobj.metadata:
data = json.loads(dsobj.metadata["comments"])
else:
data = []
data.append({"from": profile.get_nick_name(), "message": text, "icon-color": profile.get_color().to_string()})
dsobj.metadata["comments"] = json.dumps(data)
datastore.write(
dsobj,
update_mtime=False,
reply_handler=self.datastore_write_cb,
error_handler=self.datastore_write_error_cb,
)