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

Commit 2811eff

Browse files
committed
Removed cache debugging changes
1 parent cfc034c commit 2811eff

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

src/cache.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def mainloop(self, queue):
7272
profile = self.get_profile()
7373
if profile is not None:
7474
queue.put(profile)
75-
time.sleep(5)
75+
time.sleep(self.ratelimit)
7676

7777
def next(self):
7878
return self.queue.get()

src/front.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,13 @@ def __next(self, direction: Direction = None):
3636
self.window.change_view(self.image, direction)
3737

3838
else:
39-
loadscreen = Loading(
39+
self.loadscreen = Loading(
4040
self.window,
4141
width=self.window.winfo_width(),
4242
height=self.window.winfo_height()
4343
)
44-
self.window.change_view(View(loadscreen, 'widget'), direction)
45-
loadscreen.waitfor(self.cache.ready, self.__next, ('up',))
46-
self.update()
44+
self.window.change_view(View(self.loadscreen, 'widget'), direction)
45+
self.loadscreen.waitfor(self.cache.ready, self.__next, ('up',))
4746

4847
def __load(self, name, image, data):
4948
self.title.config(text=name)
@@ -61,6 +60,7 @@ def init(self):
6160

6261
self.bio = None
6362
self.image = None
63+
self.loading = None
6464

6565
self.btn_dislike = widget.PrimaryButton(
6666
self.commandbar, text='Nope', bg='red', command=self.cmd_dislike
@@ -81,6 +81,7 @@ def init(self):
8181

8282
self.cache = ImageCache(self.cachesize)
8383
self.cache.start()
84+
self.start()
8485

8586
def start(self):
8687
self.after(0, self.__next)

src/loading.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@ def generate_frames(im: Image):
1717

1818
class Loading(PrimaryCanvas):
1919
image = IMAGES / "loading.gif"
20-
last = 0
2120
limit = 1 / 20
21+
active = True
2222

2323
def init(self):
2424
self.frames = generate_frames(Image.open(self.image))
2525

2626
def waitfor(self, condition: Callable, cmd: Callable = None, args=()):
2727
for im in cycle(self.frames):
28+
if not self.active:
29+
break
2830
if condition():
2931
if cmd is not None:
3032
cmd(*args)
3133
break
32-
if self.last:
33-
self.delete(self.last)
34-
self.last = self.create_image(-42, 0, image=im, anchor='nw')
35-
self.update()
34+
self.last = self.create_image(-40.5, 0, image=im, anchor='nw')
35+
self.update_idletasks()
3636
sleep(self.limit)

src/main.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import configparser
22
import tkinter as tk
3+
from contextlib import suppress
34
from pygame import mixer
45

6+
57
from .front import Front
68
from . import SETTINGS
79

@@ -25,8 +27,8 @@ def __init__(self, *args, **kwds):
2527

2628
self.front = Front(self)
2729
self.front.pack(fill='both', expand=True)
28-
self.front.start()
2930

3031
def cleanup(self):
31-
self.front.cleanup()
32-
self.destroy()
32+
with suppress(Exception):
33+
self.front.cleanup()
34+
self.destroy()

0 commit comments

Comments
 (0)