MCPcopy Index your code
hub / github.com/python/cpython / Shelf

Class Shelf

Lib/turtledemo/sorting_animate.py:36–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34
35
36class Shelf(list):
37
38 def __init__(self, y):
39 "create a shelf. y is y-position of first block"
40 self.y = y
41 self.x = -150
42
43 def push(self, d):
44 width, _, _ = d.shapesize()
45 # align blocks by the bottom edge
46 y_offset = width / 2 * 20
47 d.sety(self.y + y_offset)
48 d.setx(self.x + 34 * len(self))
49 self.append(d)
50
51 def _close_gap_from_i(self, i):
52 for b in self[i:]:
53 xpos, _ = b.pos()
54 b.setx(xpos - 34)
55
56 def _open_gap_from_i(self, i):
57 for b in self[i:]:
58 xpos, _ = b.pos()
59 b.setx(xpos + 34)
60
61 def pop(self, key):
62 b = list.pop(self, key)
63 b.glow()
64 b.sety(200)
65 self._close_gap_from_i(key)
66 return b
67
68 def insert(self, key, b):
69 self._open_gap_from_i(key)
70 list.insert(self, key, b)
71 b.setx(self.x + 34 * key)
72 width, _, _ = b.shapesize()
73 # align blocks by the bottom edge
74 y_offset = width / 2 * 20
75 b.sety(self.y + y_offset)
76 b.unglow()
77
78def isort(shelf):
79 length = len(shelf)

Callers 1

init_shelfFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…