本文整理汇总了Python中sugar3.graphics.icon.Icon.set_stroke_color方法的典型用法代码示例。如果您正苦于以下问题:Python Icon.set_stroke_color方法的具体用法?Python Icon.set_stroke_color怎么用?Python Icon.set_stroke_color使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sugar3.graphics.icon.Icon
的用法示例。
在下文中一共展示了Icon.set_stroke_color方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: increase_score
# 需要导入模块: from sugar3.graphics.icon import Icon [as 别名]
# 或者: from sugar3.graphics.icon.Icon import set_stroke_color [as 别名]
def increase_score(self):
new_score = Icon(icon_name='score',
pixel_size=style.SMALL_ICON_SIZE)
new_score.set_fill_color(self.fill_color)
new_score.set_stroke_color(self.stroke_color)
self.scores.append(new_score)
new_score.show()
self.score_table.attach(
new_score, self.current_x, self.current_x + 1,
self.current_y, self.current_y + 1, Gtk.AttachOptions.SHRINK,
Gtk.AttachOptions.SHRINK)
self.current_x += 1
if self.current_x == self._score_cols:
self.current_x = 0
self.current_y += 1
self.queue_draw()
示例2: PlayerScoreboard
# 需要导入模块: from sugar3.graphics.icon import Icon [as 别名]
# 或者: from sugar3.graphics.icon.Icon import set_stroke_color [as 别名]
class PlayerScoreboard(Gtk.EventBox):
def __init__(self, nick, fill_color, stroke_color, score=0):
Gtk.EventBox.__init__(self)
self.default_color = '#666666'
self.selected_color = '#818286'
self.current_color = '#666666'
self.status = False
self._score_width = 0
self._score_cols = 0
self._game_size = 16
self.fill_color = fill_color
self.stroke_color = stroke_color
self.connect('size-allocate', self._allocate_cb)
# Set table
self.table = Gtk.Table(2, 2, False)
self.modify_bg(Gtk.StateType.NORMAL,
Gdk.color_parse(self.current_color))
self.table.set_row_spacings(0)
self.table.set_col_spacings(0)
self.table.set_border_width(style.DEFAULT_SPACING / 2)
# Score table
self.score_table = Gtk.Table()
self.score_table.set_row_spacings(style.DEFAULT_SPACING / 2)
self.score_table.set_col_spacings(style.DEFAULT_SPACING / 2)
self.scores = []
self.current_x = 0
self.current_y = 0
# Set buddy icon
self.icon = Icon(icon_name='computer-xo',
pixel_size=style.STANDARD_ICON_SIZE)
self.icon.set_fill_color(fill_color)
self.icon.set_stroke_color(stroke_color)
# Set nick label
self.nick = Gtk.Label(label=nick)
self.nick.modify_fg(Gtk.StateType.NORMAL, Gdk.color_parse('#ffffff'))
self.nick.set_alignment(0, 0.5)
# Set message label
self.msg = Gtk.Label(label='Waiting for next game...')
self.msg.modify_fg(Gtk.StateType.NORMAL, Gdk.color_parse('#ffffff'))
self.msg.set_alignment(0, 0.5)
self.add(self.table)
self.table.attach(self.icon, 0, 1, 0, 3, Gtk.AttachOptions.SHRINK,
Gtk.AttachOptions.SHRINK)
self.table.attach(self.nick, 1, 2, 0, 1)
self.table.attach(self.score_table, 1, 2, 1, 2)
if score != 0:
for i_ in range(score):
self.increase_score()
def _allocate_cb(self, widget, allocation):
self._score_width = allocation.width - style.STANDARD_ICON_SIZE \
- style.DEFAULT_SPACING * 2 - style.DEFAULT_SPACING / 2
self._score_cols = self._score_width / \
(style.SMALL_ICON_SIZE + style.DEFAULT_SPACING / 2)
self.change_game(self._game_size)
def change_game(self, size):
self._game_size = size
if self._score_cols == 0:
return
rows = int(math.ceil(float(size / 2) / self._score_cols))
self.score_table.resize(rows, self._score_cols)
self.score_table.set_size_request(
-1,
(style.SMALL_ICON_SIZE + style.DEFAULT_SPACING / 2) * rows -
style.DEFAULT_SPACING / 2)
def increase_score(self):
new_score = Icon(icon_name='score',
pixel_size=style.SMALL_ICON_SIZE)
new_score.set_fill_color(self.fill_color)
new_score.set_stroke_color(self.stroke_color)
self.scores.append(new_score)
new_score.show()
self.score_table.attach(
new_score, self.current_x, self.current_x + 1,
self.current_y, self.current_y + 1, Gtk.AttachOptions.SHRINK,
Gtk.AttachOptions.SHRINK)
self.current_x += 1
if self.current_x == self._score_cols:
self.current_x = 0
self.current_y += 1
self.queue_draw()
def set_selected(self, sel):
self.status = sel
if sel:
#.........这里部分代码省略.........