本文整理汇总了Python中sugar3.graphics.icon.Icon.set_fill_color方法的典型用法代码示例。如果您正苦于以下问题:Python Icon.set_fill_color方法的具体用法?Python Icon.set_fill_color怎么用?Python Icon.set_fill_color使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sugar3.graphics.icon.Icon
的用法示例。
在下文中一共展示了Icon.set_fill_color方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: increase_score
# 需要导入模块: from sugar3.graphics.icon import Icon [as 别名]
# 或者: from sugar3.graphics.icon.Icon import set_fill_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: SlideView
# 需要导入模块: from sugar3.graphics.icon import Icon [as 别名]
# 或者: from sugar3.graphics.icon.Icon import set_fill_color [as 别名]
class SlideView(Gtk.EventBox):
def __init__(self, activity):
Gtk.EventBox.__init__(self)
self._area = Gtk.DrawingArea()
self._area.connect('draw', self._area_draw_cb)
self._boxes = []
self._current_box = None
prev_btn = Gtk.EventBox()
prev_btn.connect('button-press-event', self._prev_slide)
self._prev_icon = Icon(pixel_size=100)
self._prev_icon.props.icon_name = 'go-previous'
prev_btn.add(self._prev_icon)
next_btn = Gtk.EventBox()
next_btn.connect('button-press-event', self._next_slide)
self._next_icon = Icon(pixel_size=100)
self._next_icon.props.icon_name = 'go-next'
next_btn.add(self._next_icon)
hbox = Gtk.Box()
hbox.set_border_width(10)
hbox.pack_start(prev_btn, True, False, 0)
hbox.pack_start(self._area, False, False, 0)
hbox.pack_end(next_btn, True, False, 0)
self.add(hbox)
self.show_all()
def _area_draw_cb(self, widget, context):
if self._current_box is None:
return
box = self._boxes[self._current_box]
self._area.set_size_request(box.width + 1, box.height + 1)
context.move_to(box.width - style.zoom(40),
box.height + style.zoom(25))
context.set_font_size(style.zoom(20))
context.show_text('%s/%s' % (self._current_box + 1,
str(len(self._boxes))))
if self._current_box == len(self._boxes) - 1:
self._next_icon.set_fill_color(style.COLOR_BUTTON_GREY.get_html())
else:
self._next_icon.set_fill_color(None)
if self._current_box == 0:
self._prev_icon.set_fill_color(style.COLOR_BUTTON_GREY.get_html())
else:
self._prev_icon.set_fill_color(None)
box.draw_in_context(context)
def set_boxes(self, boxes):
# Discard the title box
self._boxes = boxes[1:]
def set_current_box(self, box):
self._current_box = box
self._area.queue_draw()
def _next_slide(self, widget, event):
self._current_box += 1
if self._current_box > len(self._boxes) - 1:
self._current_box -= 1
self._area.queue_draw()
def _prev_slide(self, widget, event):
self._current_box -= 1
if self._current_box < 0:
self._current_box += 1
self._area.queue_draw()
def key_press_cb(self, widget, event):
if event.keyval == 65361:
self._prev_slide(None, None)
elif event.keyval == 65363:
self._next_slide(None, None)
示例3: PlayerScoreboard
# 需要导入模块: from sugar3.graphics.icon import Icon [as 别名]
# 或者: from sugar3.graphics.icon.Icon import set_fill_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:
#.........这里部分代码省略.........