Finish Widget.update_groups method.
@@ -97,15 +97,14 @@ class PushButton(WidgetBase):
# TODO: add `draw` method or make Batch required.
self._batch = batch or pyglet.graphics.Batch()
- self._group = OrderedGroup(0, parent=group)
self._user_group = group
- self._sprite = pyglet.sprite.Sprite(self._depressed_img, x, y, batch=batch, group=self._group)
+ bg_group = OrderedGroup(0, parent=group)
+ self._sprite = pyglet.sprite.Sprite(self._depressed_img, x, y, batch=batch, group=bg_group)
self._pressed = False
def update_groups(self, order):
- self._group = OrderedGroup(order + 1, self._user_group)
- self._sprite.group = self._group
+ self._sprite.group = OrderedGroup(order + 1, self._user_group)
def on_mouse_press(self, x, y, buttons, modifiers):
if not self._check_hit(x, y):
@@ -171,6 +170,7 @@ class Slider(WidgetBase):
self._min_knob_x = x + edge
self._max_knob_x = x + base.width - knob.width - edge
+ self._user_group = group
bg_group = OrderedGroup(0, parent=group)
fg_group = OrderedGroup(1, parent=group)
self._base_spr = pyglet.sprite.Sprite(self._base_img, x, y, batch=batch, group=bg_group)
@@ -179,6 +179,10 @@ class Slider(WidgetBase):
self._value = 0
self._in_update = False
+ def update_groups(self, order):
+ self._base_spr.group = OrderedGroup(order + 1, self._user_group)
+ self._knob_spr.group = OrderedGroup(order + 2, self._user_group)
+
@property
def _min_x(self):
return self._x + self._edge
