[Joypy-announce] joypy/Joypy: Format lists properly.

Back to archive index
scmno****@osdn***** scmno****@osdn*****
Mon May 11 04:46:47 JST 2020


changeset 13e8a9645d55 in joypy/Joypy
details: http://hg.osdn.jp/view/joypy/Joypy?cmd=changeset;node=13e8a9645d55
user: Simon Forman <sform****@hushm*****>
date: Sun May 10 12:46:33 2020 -0700
description: Format lists properly.

diffstat:

 joy/gui/controllerlistbox.py |  10 ++++++++--
 joy/utils/stack.py           |   4 ++--
 2 files changed, 10 insertions(+), 4 deletions(-)

diffs (45 lines):

diff -r 0f614d4f2d0f -r 13e8a9645d55 joy/gui/controllerlistbox.py
--- a/joy/gui/controllerlistbox.py	Sun May 10 12:18:34 2020 -0700
+++ b/joy/gui/controllerlistbox.py	Sun May 10 12:46:33 2020 -0700
@@ -20,7 +20,7 @@
 '''
 from Tkinter import Listbox, SINGLE
 from Tkdnd import dnd_start
-from joy.utils.stack import iter_stack, list_to_stack
+from joy.utils.stack import iter_stack, list_to_stack, expression_to_string
 
 
 class SourceWrapper:
@@ -135,7 +135,7 @@
 
     def _update(self):
         self.delete(0, 'end')
-        self.insert(0, *self.stack)
+        self.insert(0, *map(self.format, self.stack))
 
     def update_stack(self, stack):
         self.stack = list(iter_stack(stack))
@@ -145,3 +145,9 @@
         ControllerListbox.dnd_commit(self, source, event)
         self._update()
         self.world.stack = list_to_stack(self.stack)
+
+    @staticmethod
+    def format(item):
+        if isinstance(item, tuple):
+            return '[%s]' % expression_to_string(item)
+        return str(item)
diff -r 0f614d4f2d0f -r 13e8a9645d55 joy/utils/stack.py
--- a/joy/utils/stack.py	Sun May 10 12:18:34 2020 -0700
+++ b/joy/utils/stack.py	Sun May 10 12:46:33 2020 -0700
@@ -25,8 +25,8 @@
 
 There is no "Stack" Python class, instead we use the  `cons list`_, a 
 venerable two-tuple recursive sequence datastructure, where the
-empty tuple ``()`` is the empty stack and ``(head, rest)`` gives the recursive
-form of a stack with one or more items on it::
+empty tuple ``()`` is the empty stack and ``(head, rest)`` gives the
+recursive form of a stack with one or more items on it::
 
     stack := () | (item, stack)
 



More information about the Joypy-announce mailing list
Back to archive index