From ad96915f0eacda8080606a28b9a68c191137b5ea Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Mon, 20 Jan 2014 00:17:44 +0000 Subject: work-around radio button selection issue --- diff --git a/activity.py b/activity.py index 2c01ed4..bde2e81 100644 --- a/activity.py +++ b/activity.py @@ -270,6 +270,7 @@ class PhysicsActivity(activity.Activity): if tool.palette_mode == tools.PALETTE_MODE_ICONS: grid = Gtk.Grid() for s, settings in enumerate(tool.palette_settings): + self.game.toolList[tool.name].buttons.append([]) firstButton = None for i, icon_value in enumerate(settings['icon_values']): if i == 0: @@ -281,19 +282,33 @@ class PhysicsActivity(activity.Activity): button.connect('clicked', self._palette_icon_clicked, tool.name, + s, settings['name'], icon_value) grid.attach(button, i, s, 1, 1) + self.game.toolList[tool.name].buttons[s].append(button) button.show() - if settings['active'] == icon_value: - button.set_active(True) + # Radio buttons are not highlighting in the palette + # so adding highlight by hand + if settings['active'] == settings['icons'][i]: + button.set_icon_name(settings['icons'][i] + \ + '-selected') + button.set_active(True) # Why doesn't this work? return grid + else: + return None - return None - - def _palette_icon_clicked(self, button, toolname, value_name, value): + def _palette_icon_clicked(self, widget, toolname, s, value_name, value): for tool in tools.allTools: if tool.name == toolname: + setting = self.game.toolList[tool.name].palette_settings[s] + for i, button in enumerate( + self.game.toolList[tool.name].buttons[s]): + icon_name = setting['icons'][i] + if button == widget: + button.set_icon_name(icon_name + '-selected') + else: + button.set_icon_name(icon_name) if hasattr(tool, 'palette_data_type'): tool.palette_data_type = value else: diff --git a/icons/anvil-selected.svg b/icons/anvil-selected.svg new file mode 100644 index 0000000..24cd61a --- /dev/null +++ b/icons/anvil-selected.svg @@ -0,0 +1,29 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/icons/anvil.svg b/icons/anvil.svg index 322c89e..2025019 100644 --- a/icons/anvil.svg +++ b/icons/anvil.svg @@ -11,12 +11,12 @@ width="55" height="55" viewBox="0 571.25 55 55" - id="Layer_1" + id="svg2" xml:space="preserve">image/svg+xml \ No newline at end of file + id="defs8" /> \ No newline at end of file diff --git a/icons/basketball-selected.svg b/icons/basketball-selected.svg new file mode 100644 index 0000000..eb65924 --- /dev/null +++ b/icons/basketball-selected.svg @@ -0,0 +1,59 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/icons/basketball.svg b/icons/basketball.svg index 4b9ecfe..4328850 100644 --- a/icons/basketball.svg +++ b/icons/basketball.svg @@ -1,5 +1,5 @@ - + image/svg+xml - - - - - - - - - \ No newline at end of file + xml:space="preserve">image/svg+xml \ No newline at end of file diff --git a/icons/bowling-ball-selected.svg b/icons/bowling-ball-selected.svg new file mode 100644 index 0000000..bd99db3 --- /dev/null +++ b/icons/bowling-ball-selected.svg @@ -0,0 +1,36 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/icons/bowling-ball.svg b/icons/bowling-ball.svg index f18f465..6a6e16f 100644 --- a/icons/bowling-ball.svg +++ b/icons/bowling-ball.svg @@ -1,5 +1,5 @@ - + image/svg+xml - - \ No newline at end of file + xml:space="preserve">image/svg+xml \ No newline at end of file diff --git a/icons/chain-coarse-selected.svg b/icons/chain-coarse-selected.svg new file mode 100644 index 0000000..712b741 --- /dev/null +++ b/icons/chain-coarse-selected.svg @@ -0,0 +1,54 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/icons/chain-fine-selected.svg b/icons/chain-fine-selected.svg new file mode 100644 index 0000000..e9329f9 --- /dev/null +++ b/icons/chain-fine-selected.svg @@ -0,0 +1,62 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/icons/chain-medium-selected.svg b/icons/chain-medium-selected.svg new file mode 100644 index 0000000..d8c5219 --- /dev/null +++ b/icons/chain-medium-selected.svg @@ -0,0 +1,58 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/icons/feather-selected.svg b/icons/feather-selected.svg new file mode 100644 index 0000000..39bc05a --- /dev/null +++ b/icons/feather-selected.svg @@ -0,0 +1,41 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/icons/feather.svg b/icons/feather.svg index e05c446..6fe5988 100644 --- a/icons/feather.svg +++ b/icons/feather.svg @@ -1,55 +1,27 @@ + + image/svg+xml - - - - - - \ No newline at end of file + xml:space="preserve">image/svg+xml \ No newline at end of file diff --git a/icons/ice-skate-selected.svg b/icons/ice-skate-selected.svg new file mode 100644 index 0000000..71198e7 --- /dev/null +++ b/icons/ice-skate-selected.svg @@ -0,0 +1,39 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/icons/ice-skate.svg b/icons/ice-skate.svg index c2215bd..4b155a7 100644 --- a/icons/ice-skate.svg +++ b/icons/ice-skate.svg @@ -1,52 +1,25 @@ + + image/svg+xml - - - - \ No newline at end of file + width="55" + height="55" + viewBox="0 0 55 55" + id="svg3208" + xml:space="preserve">image/svg+xml \ No newline at end of file diff --git a/icons/motor-rabbit-2-selected.svg b/icons/motor-rabbit-2-selected.svg new file mode 100644 index 0000000..5258bb5 --- /dev/null +++ b/icons/motor-rabbit-2-selected.svg @@ -0,0 +1,65 @@ + + + +Slice 1image/svg+xmlSlice 1 \ No newline at end of file diff --git a/icons/motor-rabbit-selected.svg b/icons/motor-rabbit-selected.svg new file mode 100644 index 0000000..1ca390d --- /dev/null +++ b/icons/motor-rabbit-selected.svg @@ -0,0 +1,58 @@ + + + +Slice 1image/svg+xmlSlice 1Created with Sketch (http://www.bohemiancoding.com/sketch) \ No newline at end of file diff --git a/icons/motor-turtle-2-selected.svg b/icons/motor-turtle-2-selected.svg new file mode 100644 index 0000000..c482847 --- /dev/null +++ b/icons/motor-turtle-2-selected.svg @@ -0,0 +1,103 @@ + + + +Slice 1image/svg+xmlSlice 1 \ No newline at end of file diff --git a/icons/motor-turtle-selected.svg b/icons/motor-turtle-selected.svg new file mode 100644 index 0000000..d20d02b --- /dev/null +++ b/icons/motor-turtle-selected.svg @@ -0,0 +1,96 @@ + + + +Slice 1image/svg+xmlSlice 1Created with Sketch (http://www.bohemiancoding.com/sketch) \ No newline at end of file diff --git a/icons/shoe-selected.svg b/icons/shoe-selected.svg new file mode 100644 index 0000000..4f52b8c --- /dev/null +++ b/icons/shoe-selected.svg @@ -0,0 +1,97 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/icons/sneaker-selected.svg b/icons/sneaker-selected.svg new file mode 100644 index 0000000..03b8c3f --- /dev/null +++ b/icons/sneaker-selected.svg @@ -0,0 +1,36 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/icons/tennis-ball-selected.svg b/icons/tennis-ball-selected.svg new file mode 100644 index 0000000..bca0967 --- /dev/null +++ b/icons/tennis-ball-selected.svg @@ -0,0 +1,45 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/icons/tennis-ball.svg b/icons/tennis-ball.svg index fc8d418..c0b881e 100644 --- a/icons/tennis-ball.svg +++ b/icons/tennis-ball.svg @@ -1,60 +1,31 @@ + + image/svg+xml - - - - - - \ No newline at end of file + xml:space="preserve">image/svg+xml \ No newline at end of file diff --git a/icons/wood-selected.svg b/icons/wood-selected.svg new file mode 100644 index 0000000..e219dc3 --- /dev/null +++ b/icons/wood-selected.svg @@ -0,0 +1,267 @@ + + + +image/svg+xmlhttp://thenounproject.com +The Noun Project +Icon Template +Reminders +Strokes +Try to keep strokes at 4px +Minimum stroke weight is 2px +For thicker strokes use even +numbers: 6px, 8px etc. +Remember to expand strokes +before saving as an SVG +Size +Cannot be wider or taller than +100px (artboard size) +Scale your icon to fill as much of +the artboard as possible +Ungroup +If your design has more than one +shape, make sure to ungroup +Save as +Save as .SVG and make sure +“Use Artboards” is checked +100px +.SVG + \ No newline at end of file diff --git a/icons/wood.svg b/icons/wood.svg index 1f0bc6d..85bb593 100644 --- a/icons/wood.svg +++ b/icons/wood.svg @@ -1,398 +1,253 @@ + + image/svg+xml - - - - http://thenounproject.com - - The Noun Project - - Icon Template - - Reminders - - - - - - - - - - - - - - Strokes - - Try to keep strokes at 4px - - Minimum stroke weight is 2px - - For thicker strokes use even - - numbers: 6px, 8px etc. - - Remember to expand strokes - - before saving as an SVG - - - Size - - Cannot be wider or taller than - - 100px (artboard size) - - Scale your icon to fill as much of - - the artboard as possible - - - Ungroup - - If your design has more than one - - shape, make sure to ungroup - - - Save as - - Save as .SVG and make sure - - “Use Artboards” is checked - - 100px - - .SVG - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + xml:space="preserve">image/svg+xmlhttp://thenounproject.com +The Noun Project +Icon Template +Reminders +Strokes +Try to keep strokes at 4px +Minimum stroke weight is 2px +For thicker strokes use even +numbers: 6px, 8px etc. +Remember to expand strokes +before saving as an SVG +Size +Cannot be wider or taller than +100px (artboard size) +Scale your icon to fill as much of +the artboard as possible +Ungroup +If your design has more than one +shape, make sure to ungroup +Save as +Save as .SVG and make sure +“Use Artboards” is checked +100px +.SVG + \ No newline at end of file diff --git a/tools.py b/tools.py index 31c581e..8e6e76f 100644 --- a/tools.py +++ b/tools.py @@ -53,7 +53,7 @@ PALETTE_ICON_OBJECT_SETTINGS = [ 'name': 'friction', 'icons': ['ice-skate', 'shoe', 'sneaker'], 'icon_values': [0.5, 1, 2], - 'active': 'grass' + 'active': 'shoe' }] PALETTE_OBJECT_DATA = { 'density': 1.0, @@ -76,6 +76,7 @@ class Tool(object): def __init__(self, gameInstance): self.game = gameInstance self.name = self.__class__.name + self.buttons = [] def handleEvents(self, event): handled = True -- cgit v0.9.1