comparison frontends/src/primitivus/card_game.py @ 1158:c0f15e52695a

primitivus: use of new keys modules from Urwid SàText
author Goffi <goffi@goffi.org>
date Thu, 04 Sep 2014 19:05:57 +0200
parents e2e1e27a3680
children
comparison
equal deleted inserted replaced
1157:c4b62e6b7377 1158:c0f15e52695a
21 import urwid 21 import urwid
22 from urwid_satext import sat_widgets 22 from urwid_satext import sat_widgets
23 from sat_frontends.tools.games import TarotCard 23 from sat_frontends.tools.games import TarotCard
24 from sat_frontends.quick_frontend.quick_card_game import QuickCardGame 24 from sat_frontends.quick_frontend.quick_card_game import QuickCardGame
25 from sat_frontends.primitivus import xmlui 25 from sat_frontends.primitivus import xmlui
26 from sat_frontends.primitivus.keys import action_key_map as a_key
26 27
27 28
28 class CardDisplayer(urwid.Text): 29 class CardDisplayer(urwid.Text):
29 """Show a card""" 30 """Show a card"""
30 signals = ['click'] 31 signals = ['click']
36 37
37 def selectable(self): 38 def selectable(self):
38 return True 39 return True
39 40
40 def keypress(self, size, key): 41 def keypress(self, size, key):
41 if key == ' ': 42 if key == a_key['CARD_SELECT']:
42 self.select(not self.__selected) 43 self.select(not self.__selected)
43 self._emit('click') 44 self._emit('click')
44 return key 45 return key
45 46
46 def mouse_event(self, size, event, button, x, y, focus): 47 def mouse_event(self, size, event, button, x, y, focus):
93 94
94 if CardDisplayer in [wid.__class__ for wid in self.columns.widget_list]: 95 if CardDisplayer in [wid.__class__ for wid in self.columns.widget_list]:
95 return self.columns.keypress(size, key) 96 return self.columns.keypress(size, key)
96 else: 97 else:
97 #No card displayed, we still have to manage the clicks 98 #No card displayed, we still have to manage the clicks
98 if key == ' ': 99 if key == a_key['CARD_SELECT']:
99 self._emit('click', None) 100 self._emit('click', None)
100 return key 101 return key
101 102
102 def getSelected(self): 103 def getSelected(self):
103 """Return a list of selected cards""" 104 """Return a list of selected cards"""