[Joypy-announce] joypy/Joypy: 3 new changesets

Back to archive index
scmno****@osdn***** scmno****@osdn*****
Mon May 11 00:39:00 JST 2020


changeset 37ccf2402d11 in joypy/Joypy
details: http://hg.osdn.jp/view/joypy/Joypy?cmd=changeset;node=37ccf2402d11
user: Simon Forman <sform****@hushm*****>
date: Sun May 10 08:28:49 2020 -0700
description: Connect it up.

Inelegant but functional.
changeset 9166e74e30ef in joypy/Joypy
details: http://hg.osdn.jp/view/joypy/Joypy?cmd=changeset;node=9166e74e30ef
user: Simon Forman <sform****@hushm*****>
date: Sun May 10 08:36:05 2020 -0700
description: Update view of stack at start.
changeset 6a58e176e9ea in joypy/Joypy
details: http://hg.osdn.jp/view/joypy/Joypy?cmd=changeset;node=6a58e176e9ea
user: Simon Forman <sform****@hushm*****>
date: Sun May 10 08:38:37 2020 -0700
description: Remove listbox try out script.

diffstat:

 joy/gui/controllerlistbox.py |  22 +++++++++++++++++++++-
 joy/gui/main.py              |  13 +++++++++++--
 joy/gui/world.py             |  15 +++++++++++++++
 3 files changed, 47 insertions(+), 3 deletions(-)

diffs (102 lines):

diff -r c174cb0018d8 -r 6a58e176e9ea joy/gui/controllerlistbox.py
--- a/joy/gui/controllerlistbox.py	Sat May 09 19:09:23 2020 -0700
+++ b/joy/gui/controllerlistbox.py	Sun May 10 08:38:37 2020 -0700
@@ -20,6 +20,7 @@
 '''
 from Tkinter import Listbox, SINGLE
 from Tkdnd import dnd_start
+from joy.utils.stack import iter_stack, list_to_stack
 
 
 class SourceWrapper:
@@ -28,7 +29,7 @@
     '''
     def __init__(self, source, widget, index=None):
         '''
-        source is the object being dragged, widget is the container thats
+        source is the object being dragged, widget is the container that's
         initialing the drag operation, and index s thu index of the item
         in the widget's model object (which presumably is a ListModel
         containing the source object.)
@@ -125,3 +126,22 @@
         finally:
             self.clear()
 
+
+class StackListbox(ControllerListbox):
+
+    def __init__(self, world, master=None, **kw):
+        ControllerListbox.__init__(self, master, **kw)
+        self.world = world
+
+    def _update(self):
+        self.delete(0, 'end')
+        self.insert(0, *self.stack)
+
+    def update_stack(self, stack):
+        self.stack = list(iter_stack(stack))
+        self._update()
+
+    def dnd_commit(self, source, event):
+        ControllerListbox.dnd_commit(self, source, event)
+        self._update()
+        self.world.stack = list_to_stack(self.stack)
diff -r c174cb0018d8 -r 6a58e176e9ea joy/gui/main.py
--- a/joy/gui/main.py	Sat May 09 19:09:23 2020 -0700
+++ b/joy/gui/main.py	Sun May 10 08:38:37 2020 -0700
@@ -47,7 +47,8 @@
 # Now that logging is set up, continue loading the system.
 
 from joy.gui.textwidget import TextViewerWidget, tk, get_font
-from joy.gui.world import StackDisplayWorld
+from joy.gui.world import StackWorld
+from joy.gui.controllerlistbox import StackListbox
 from joy.library import initialize, DefinitionWrapper
 from joy.utils.stack import stack_to_string
 
@@ -142,7 +143,7 @@
 D.update(commands())
 DefinitionWrapper.load_definitions(DEFS_FN, D)
 
-world = StackDisplayWorld(repo, STACK_FN, REL_STACK_FN, dictionary=D)
+world = StackWorld(repo, STACK_FN, REL_STACK_FN, dictionary=D)
 
 t = TextViewerWidget(world, **VIEWER_DEFAULTS)
 
@@ -155,6 +156,14 @@
 
 FONT = get_font('Iosevka', size=14)  # Requires Tk root already set up.
 
+stack_window = tk.Toplevel()
+stack_window.title("Stack")
+stack_window.protocol("WM_DELETE_WINDOW", log_window.withdraw)
+stack_viewer = StackListbox(world, stack_window, items=[])
+stack_viewer.pack(expand=True, fill=tk.BOTH)
+world.set_viewer(stack_viewer)
+
+
 log.init('Log', LOG_FN, repo_relative_path(LOG_FN), repo, FONT)
 t.init('Joy - ' + JOY_HOME, JOY_FN, repo_relative_path(JOY_FN), repo, FONT)
 
diff -r c174cb0018d8 -r 6a58e176e9ea joy/gui/world.py
--- a/joy/gui/world.py	Sat May 09 19:09:23 2020 -0700
+++ b/joy/gui/world.py	Sun May 10 08:38:37 2020 -0700
@@ -152,3 +152,18 @@
 		if os.path.exists(self.filename):
 			with open(self.filename, 'rb') as f:
 				return pickle.load(f)
+
+
+class StackWorld(StackDisplayWorld):
+
+	viewer = None
+
+	def set_viewer(self, viewer):
+		self.viewer = viewer
+		self.viewer.update_stack(self.stack)
+
+	def print_stack(self):
+		StackDisplayWorld.print_stack(self)
+		if self.viewer:
+			self.viewer.update_stack(self.stack)
+



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