Skip to content

Commit

Permalink
fix: update deprecated code in the themes.
Browse files Browse the repository at this point in the history
  • Loading branch information
kalekundert committed Feb 27, 2021
1 parent 825ba6f commit 9178939
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
21 changes: 12 additions & 9 deletions glooey/themes/golden.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Gui(glooey.Gui):
custom_cursor = 'gold'

def __init__(self, window, *, batch=None, cursor=None):
super().__init__(window, batch)
super().__init__(window, batch=batch)
self.set_cursor(cursor or self.custom_cursor)

def set_cursor(self, cursor):
Expand Down Expand Up @@ -56,6 +56,9 @@ class Base(glooey.Background):

@autoprop
class RoundButton(glooey.Button):
class Foreground(glooey.Image):
pass

custom_color = 'red'
custom_icon = None

Expand Down Expand Up @@ -83,23 +86,23 @@ def get_icon(self):

def set_icon(self, name):
if name is None:
return self.del_image()
del self.foreground.image
return

try:
self._icon = name
self.set_image(
assets.image(f'buttons/round/icon_{name}.png'),
)
self.foreground.image = assets.image(f'buttons/round/icon_{name}.png')
except pyglet.resource.ResourceNotFoundException:
raise UsageError(f"the Golden theme doesn't have a '{name}' icon.")

def del_icon(self):
self.del_image()
self.del_foreground()


@autoprop
class BasicButton(glooey.Button):

class Label(Label):
class Foreground(Label):
custom_horz_padding = 12
custom_bottom_padding = 3
custom_alignment = 'center'
Expand All @@ -118,7 +121,7 @@ class Down(glooey.Background):
@autoprop
class FancyButton(glooey.Button):

class Label(Label):
class Foreground(Label):
custom_color = '#140c1c'
custom_alignment = 'center'
custom_horz_padding = 30
Expand Down Expand Up @@ -293,7 +296,7 @@ class Backward(RoundButton):
custom_left_padding = 1
custom_right_padding = 5

class Grip(glooey.ImageScrollGrip):
class Grip(glooey.Image):
custom_image = assets.image('scroll_bars/grip.png')
custom_left_padding = 2
custom_right_padding = 6
Expand Down
2 changes: 1 addition & 1 deletion glooey/themes/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ def __init__(self, paths=None):
super().__init__(paths, Path(__file__).parent / 'assets')

def yaml(self, name):
return yaml.load(self.file(name))
return yaml.safe_load(self.file(name))

10 changes: 5 additions & 5 deletions glooey/themes/kenney.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class Button(glooey.Button):
custom_gloss = 'high' # 'low', 'matte'
custom_font_color = 'white'

class Label(Label):
class Foreground(Label):
custom_alignment = 'center'
custom_font_weight = 'bold'
custom_horz_padding = 30
Expand All @@ -247,13 +247,13 @@ def __init__(self, text=None):
self._gloss = self.custom_gloss
self._update_background()

self.label.color = self.custom_font_color
self.foreground.color = self.custom_font_color

def on_rollover(self, widget, new_state, old_state):
if new_state == 'down':
self.label.top_padding = 2 * 4
self.foreground.top_padding = 2 * 4
if old_state == 'down':
self.label.top_padding = 0
self.foreground.top_padding = 0

def get_color(self):
return self._color
Expand Down Expand Up @@ -314,7 +314,7 @@ class RoundButton(glooey.Button):
custom_color = 'red'
custom_icon = 'cross'

class Label(BigLabel):
class Foreground(BigLabel):
custom_color = 'white'
custom_alignment = 'center'
custom_font_size = 16
Expand Down

0 comments on commit 9178939

Please sign in to comment.