Skip to content
This repository was archived by the owner on Mar 31, 2020. It is now read-only.

Commit a9df697

Browse files
committed
Bio animation
1 parent 1a5badf commit a9df697

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

src/animate.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ def run(self):
143143
for motion in self._motions:
144144
try:
145145
next(motion)()
146+
self.canvas.update()
146147
except StopIteration:
147148
self._motions.remove(motion)
148149
break
@@ -241,8 +242,8 @@ def __eq__(self):
241242

242243
class Window(widget.PrimaryCanvas):
243244
animation_speed = 4
244-
_current = None
245-
_views = {}
245+
current = None
246+
views = {}
246247

247248
def init(self):
248249
self.animater = Animater(self)
@@ -265,12 +266,12 @@ def __set(self, view, coord, viewtype):
265266
wid = self.__set_image(view, coord)
266267
else:
267268
wid = self.__set_widget(view, coord)
268-
self._views[view] = wid
269+
self.views[view] = wid
269270
return wid
270271

271272
def set_view(self, view: tk.Widget, viewtype='image'):
272-
self._current = view
273-
self.__set(self._current, self.origin, viewtype)
273+
self.current = view
274+
self.__set(self.current, self.origin, viewtype)
274275

275276
def move_view(self, wid, end):
276277
self.animater.add_motion(
@@ -285,22 +286,22 @@ def move_in(self, view, direction: Direction, viewtype='image'):
285286
return wid
286287

287288
def move_out(self, view, direction, viewtype='image'):
288-
wid = self._views[view]
289+
wid = self.views[view]
289290
distance = self.get_distance(direction)
290291
end = self.origin + distance
291292
self.move_view(wid, end)
292-
del self._views[view]
293+
del self.views[view]
293294

294295
def change_view(self, view: tk.Widget, direction: Direction, viewtype='image'):
295296
if not isinstance(direction, Direction):
296297
direction = Direction[direction.upper()] # Cast string for convenience
297298
self.animater.clear()
298299

299-
self.move_out(self._current, direction, viewtype=viewtype)
300+
self.move_out(self.current, direction, viewtype=viewtype)
300301
self.move_in(view, direction.flip(), viewtype=viewtype)
301302

302303
self.animater.start()
303-
self._current = view
304+
self.current = view
304305

305306
def get_distance(self, direction: Direction):
306307
if not isinstance(direction, Direction):

src/front.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,12 @@ def cmd_like(self):
7171
self.__change_image('RIGHT')
7272

7373
def cmd_bio(self):
74-
self.window.change_view(self.bio, 'UP', 'widget')
74+
if self.bio in self.window.views:
75+
self.window.move_out(self.bio, 'DOWN', viewtype='widget')
76+
else:
77+
self.window.move_in(self.bio, 'DOWN', viewtype='widget')
78+
79+
self.window.animater.start()
7580

7681
@property
7782
def cache(self):

0 commit comments

Comments
 (0)