This repository was archived by the owner on Mar 31, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +7
-15
lines changed Expand file tree Collapse file tree 3 files changed +7
-15
lines changed Original file line number Diff line number Diff line change @@ -19,14 +19,8 @@ class ImageCache:
1919 )
2020 ratelimit = 0.1
2121
22- def __init__ (self , master , cachesize ):
23- self .master = master
24- self .cachesize = cachesize
25- self .screen_x = self .master .winfo_screenwidth ()
26- self .screen_y = self .master .winfo_screenheight ()
27-
28- self .queue = Queue (self .cachesize )
29- self .active = False
22+ def __init__ (self , size ):
23+ self .queue = Queue (size )
3024 self .worker = None
3125
3226 def __del__ (self ):
@@ -65,15 +59,13 @@ def mainloop(self, queue):
6559 while True :
6660 if not queue .full ():
6761 queue .put (self .get_profile ())
68- time .sleep (self .ratelimit )
62+ time .sleep (self .ratelimit )
6963
7064 def start (self ):
7165 if self .worker is not None and self .worker .is_alive ():
7266 self .stop ()
73- self .active = True
7467 self .worker = Process (target = self .mainloop , args = (self .queue ,))
7568 self .worker .start ()
7669
7770 def stop (self ):
78- self .active = False
79- self .worker .join ()
71+ self .worker .terminate ()
Original file line number Diff line number Diff line change 99
1010def process_image (image : bytes , width : int , height : int ):
1111 im = Image .open (io .BytesIO (image ))
12- im = im .resize ((height , width ), Image .NEAREST )
12+ im = im .resize ((width , height ), Image .NEAREST )
1313 return ImageTk .PhotoImage (im )
1414
1515
@@ -64,7 +64,7 @@ def init(self):
6464 self .btn_dislike .pack (side = 'left' )
6565 self .btn_like .pack (side = 'right' )
6666
67- self .cache = ImageCache (self .window , self . cachesize )
67+ self .cache = ImageCache (self .cachesize )
6868
6969 def cmd_dislike (self ):
7070 self .__change_image ('right' )
Original file line number Diff line number Diff line change 11import tkinter as tk
22from typing import TypeVar
33from enum import Enum
4+ from PIL import ImageTk
45
56from . import widget
67from .animate import Coord , Animater , Direction
7- from .cache import ImageTk
88
99
1010class ViewType (Enum ):
You can’t perform that action at this time.
0 commit comments