Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- import collections
- import wx
- app = wx.App()
- KeyType = collections.namedtuple('KeyType', 'strength weakness')
- POWER_KEY = KeyType('heart', 'shadow')
- DECEIVER_KEY = KeyType('lie', 'truth')
- KeyTemplate = collections.namedtuple(
- 'KeyTemplate',
- 'type flower key_name name_of strength weakness strength_hint '
- 'weakness_bullets')
- POWER_TEMPLATES = ()
- POWER_TEMPLATES += KeyTemplate(
- POWER_KEY, 'Lotus Flower', 'Key of the Descending Angel', None, 'My Power',
- 'My Nature', "how you enact meaningful change in people's lives",
- ('glorious', 'set apart')),
- POWER_TEMPLATES += KeyTemplate(
- POWER_KEY, 'Vervain', 'Key of Something Powerful', None, 'My Identity',
- 'Burdens', 'who you are when you wield power',
- ('bound by duty', 'set apart')),
- POWER_TEMPLATES += KeyTemplate(
- POWER_KEY, 'Acacia', 'Key of Something that Must Be Hidden', None,
- 'A Dangerous Secret', '...That Hurts To Keep',
- 'what you do when dealing with the secret',
- ('painful silence', 'set apart')),
- POWER_TEMPLATES += KeyTemplate(
- POWER_KEY, 'Clematis', 'Key of Something, Given Gifts', None,
- 'I Have Witnessed It', 'Why I Doubt',
- 'who you are when you are witness to grace', ()),
- POWER_TEMPLATES += KeyTemplate(
- POWER_KEY, 'Aconite', 'Key of Rage', None,
- # Not sure how best to represent this.
- "(.*'s )?(Rage|Hatred|Fury)",
- 'What Lets Me Oppose It', 'who you are in this drama', ()),
- POWER_TEMPLATES += KeyTemplate(
- POWER_KEY, 'Wild Oats', 'Key of Destiny Denied', None, 'Hunger',
- 'Why It Feels Empty', 'who you are when indulging in your vice', ()),
- POWER_TEMPLATES += KeyTemplate(
- POWER_KEY, 'Star of Bethlehem', 'Key of Something, Changed Forever', None,
- 'What it Made Me', 'How It Changed the World',
- "who you are when you're thinking about the mystery",
- ("I can't let go", "I'm committed")),
- POWER_TEMPLATES += KeyTemplate(
- POWER_KEY, 'Gorse', 'Key of Something in Thrall', None, 'Held in Thrall',
- 'Entangled with my Enemy', 'how you are held in thrall, and by what',
- ("I can't let go", "I'm weak")),
- POWER_TEMPLATES += KeyTemplate(
- POWER_KEY, 'Honeysuckle', 'Key of Something, Finally, at Rest', None,
- 'My New Life', 'My Old Life', 'who you are and who you were', ()),
- POWER_TEMPLATES += KeyTemplate(
- POWER_KEY, 'Chamomile', 'Key of Something Romantic', None, 'The Dream',
- 'The Cost', 'who you are', ()),
- POWER_TEMPLATES += KeyTemplate(
- POWER_KEY, 'Wild Rose', 'Key of Something Different', None, 'My Nature',
- 'My Struggles', 'who you are compared to others',
- ('self-doubt', 'trying to fit in')),
- POWER_TEMPLATES += KeyTemplate(
- POWER_KEY, 'Hollyhock', 'Key of Destiny in the Balance', None,
- 'My Destiny', 'My Struggles', 'what you are doing as you change',
- ('self-doubt', 'changing hurts')),
- POWER_TEMPLATES += KeyTemplate(
- POWER_KEY, 'Mimulus', 'Key of Something Restless', None, 'My Path',
- 'Why it Feels Empty', 'who you are when you wander',
- ('self-doubt', "the things I've left behind")),
- POWER_TEMPLATES += KeyTemplate(
- POWER_KEY, 'Water Lily', 'Key of Something Spiritual', None, 'My Retreat',
- 'Burdens', 'who you are when you separate yourself from the world',
- ('my duties as a Power',)),
- POWER_TEMPLATES += KeyTemplate(
- POWER_KEY, 'Oak', "Key of Something That Hasn't Changed", None,
- 'My Identity', 'Crisis', 'who you are', ()),
- POWER_TEMPLATES += KeyTemplate(
- POWER_KEY, 'Alyssym', 'Key of Destiny Fulfilled', None, 'My Destiny',
- None, 'who you are, in terms of who you were', ()),
- DECEIVER_TEMPLATES = ()
- DECEIVER_TEMPLATES += KeyTemplate(
- DECEIVER_KEY, 'Lotus Flower', 'Key of the Shepherd', 'I BRING MY FLOCK...',
- None, None, 'what people get out of interacting with you',
- ('I love them', 'I listen to them')),
- DECEIVER_TEMPLATES += KeyTemplate(
- DECEIVER_KEY, 'Vervain', 'Key of the Dragon', 'THE EXCRUCIAN WAR', None,
- None, 'cool stuff that you could do or have done',
- ('I love them', 'I am their enemy')),
- DECEIVER_TEMPLATES += KeyTemplate(
- DECEIVER_KEY, 'Acacia', 'Key of the Crossroads', 'WHY I FALTER', None,
- None, 'your excuse for being kind to mortals and Powers',
- ('I love them', "I've lost sight of what I'm fighting for")),
- DECEIVER_TEMPLATES += KeyTemplate(
- DECEIVER_KEY, 'Clematis', 'Key of the Angel', "I'M REACHING OUT TO YOU",
- None, None, "who you pretend to be when you're reaching out to the Powers",
- ()),
- DECEIVER_TEMPLATES += KeyTemplate(
- DECEIVER_KEY, 'Aconite', 'Key of the Nemesis', 'THE EXCRUCIAN WAR', None,
- None, "who you are when ruining a Power's life", ()),
- DECEIVER_TEMPLATES += KeyTemplate(
- DECEIVER_KEY, 'Wild Oats', 'Key of the Dreamer',
- 'WHO I AM, IN THIS YOUR DREAM', None, None,
- 'the role you take on in this dream', ()),
- DECEIVER_TEMPLATES += KeyTemplate(
- DECEIVER_KEY, 'Star of Bethlehem', 'Key of Burdens', 'IT MARKED ME', None,
- None, "what you do to show you're carrying something with you",
- ("I can't let go", "It's always with me")),
- DECEIVER_TEMPLATES += KeyTemplate(
- DECEIVER_KEY, 'Gorse', 'Key of Promises', 'HELD IN THRALL', None, None,
- "the situation you're trapped in", ("I can't let go", "It's killing me")),
- DECEIVER_TEMPLATES += KeyTemplate(
- DECEIVER_KEY, 'Periwinkle', 'Key of Legends', 'MY LEGEND', None, None,
- 'an impressive thing you did', ()),
- DECEIVER_TEMPLATES += KeyTemplate(
- DECEIVER_KEY, 'Chamomile', 'Key of the Mask',
- 'WHO I AM, IN THIS YOUR DREAM', None, None, 'who you are', ()),
- DECEIVER_TEMPLATES += KeyTemplate(
- DECEIVER_KEY, 'Widow-Rose', 'Key of the Alien', 'MY NATURE', None, None,
- 'why you cannot fit in',
- ("I'm an enemy of the world", 'You cannot keep me away')),
- DECEIVER_TEMPLATES += KeyTemplate(
- DECEIVER_KEY, 'Milkmay', 'Key Unformed', 'THAT WHICH STIRS', None, None,
- "what form you're likely to take when play begins",
- ("I'm an enemy of the world", 'I am truth preceding form')),
- DECEIVER_TEMPLATES += KeyTemplate(
- DECEIVER_KEY, 'Phoenix Posy', 'Self-Creating Key, the',
- 'I HAVE MADE MYSELF...', None, None, 'how you fit into the world',
- ("I'm an enemy of the world", 'from nothing')),
- DECEIVER_TEMPLATES += KeyTemplate(
- DECEIVER_KEY, 'Water Lily', 'Key of Something Spiritual', 'MY NATURE',
- None, None, 'how your holiness expresses itself in the world',
- ('Excrucian Deceiver',)),
- DECEIVER_TEMPLATES += KeyTemplate(
- DECEIVER_KEY, 'Bilberry', 'Key of the Fallen', 'WHAT I BELIEVE', None,
- None, "what you've accepted", ()),
- DECEIVER_TEMPLATES += KeyTemplate(
- DECEIVER_KEY, 'Hemlock', 'Key of the Lie', 'WHO I AM, IN THIS YOUR DREAM',
- None, None, "the story you're trying to tell (often part of another Key)",
- ()),
- MIN_SELECTED = 'min_selected'
- MAX_SELECTED = 'max_selected'
- SELECTED = 'selected'
- class MultiSelect(wx.Panel):
- def __init__(self, parent, min_selected=0, max_selected=None):
- super().__init__(parent)
- self._min_selected = min_selected
- self._max_selected = max_selected
- self._selected = 0
- self._sufficient = min_selected == 0
- self._at_maximum = max_selected == 0
- self.sizer = wx.BoxSizer(orient=wx.VERTICAL)
- self.SetSizer(self.sizer)
- def add(self, child):
- self.sizer.Add(child, 0, wx.EXPAND, 0)
- self.Fit()
- def _emit_sufficient(self):
- new_value = self._selected >= self._min_selected
- if self._sufficient != new_value:
- # Do... something
- self._sufficient = new_value
- def _emit_maximum(self):
- new_value = (
- self._max_selected is not None and
- self._selected == self._max_selected)
- if self._at_maximum != new_value:
- if new_value:
- for child in self.Children:
- if not child.Value:
- child.Disable()
- else:
- for child in self.Children:
- child.Enable()
- self._at_maximum = new_value
- def _set_value(self, value, field):
- min_selected = value if field == MIN_SELECTED else self._min_selected
- max_selected = value if field == MAX_SELECTED else self._max_selected
- selected = value if field == SELECTED else self._selected
- if max_selected is not None:
- if max_selected < selected:
- raise ValueError(
- f'selected ({selected}) cannot exceed maximum '
- f'({max_selected})')
- if max_selected < min_selected:
- raise ValueError(
- f'minimum ({min_selected}) cannot exceed maximum '
- f'({max_selected})')
- setattr(self, f'_{field}', value)
- self._emit_sufficient()
- self._emit_maximum()
- @property
- def selected(self):
- return self._selected
- @selected.setter
- def selected(self, value):
- self._set_value(value, SELECTED)
- @property
- def min_selected(self):
- return self._min_selected
- @min_selected.setter
- def min_selected(self, value):
- self._set_value(value, MIN_SELECTED)
- @property
- def max_selected(self):
- return self._max_selected
- @max_selected.setter
- def max_selected(self, value):
- self._set_value(value, MAX_SELECTED)
- class KeyButton(wx.ToggleButton):
- def __init__(self, parent, label):
- super().__init__(parent, label=label)
- self.Bind(wx.EVT_TOGGLEBUTTON, self.on_push)
- def on_push(self, event):
- if self.Value:
- self.Parent.selected += 1
- else:
- self.Parent.selected -= 1
- def make_power():
- frame = wx.Frame(None, title='New Power')
- splitter = wx.SplitterWindow(frame)
- components = wx.Listbook(splitter, style=wx.LB_LEFT)
- diagram = wx.Panel(splitter)
- keys_tab = wx.Panel(components)
- keys_sizer = wx.FlexGridSizer(2, 2, 0, 0)
- keys_sizer.Add(wx.StaticText(keys_tab, label='Selected'))
- keys_sizer.Add(wx.StaticText(keys_tab, label='SelectedList'))
- keys_sizer.Add(wx.StaticText(keys_tab, label='All'))
- keys_all_choices = MultiSelect(keys_tab, 2, 2)
- keys_sizer.Add(keys_all_choices)
- for choice in ['Lotus Flower', 'Vervain', 'Acacia', 'Clematis', 'Aconite',
- 'Wild Oats', 'Star of Bethlehem', 'Gorse', 'Honeysuckle',
- 'Chamomile', 'Wild Rose', 'Hollyhock', 'Mimulus',
- 'Water Lily', 'Oak', 'Alyssym']:
- keys_all_choices.add(KeyButton(keys_all_choices, choice))
- keys_tab.SetSizerAndFit(keys_sizer)
- components.AddPage(keys_tab, 'Keys')
- components.AddPage(wx.Panel(components), 'Foundation')
- components.AddPage(wx.Panel(components), 'Estate')
- components.AddPage(wx.Panel(components), 'Origins')
- components.AddPage(wx.Panel(components), 'Contacts')
- components.AddPage(wx.Panel(components), 'Affiliation')
- components.AddPage(wx.Panel(components), 'Background')
- splitter.SplitVertically(components, diagram)
- return frame
- FRAME = make_power()
- FRAME.Show()
- app.MainLoop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement