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

Commit fcf8d75

Browse files
committed
DrawType changes implemented
1 parent 6850a74 commit fcf8d75

File tree

3 files changed

+15
-16
lines changed

3 files changed

+15
-16
lines changed

src/front.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Front(widget.PrimaryFrame):
2424
_last = None
2525

2626
def __next(self, direction: Direction = None):
27-
if self.window.active:
27+
if self.window.active: # Spam protection
2828
return
2929
if self.cache.ready():
3030
data: dict = self.cache.next()
@@ -43,13 +43,13 @@ def __next(self, direction: Direction = None):
4343
width=self.window.winfo_width(),
4444
height=self.window.winfo_height()
4545
)
46-
self.window.change_view(View(self.loadscreen, 'widget'), direction)
47-
self.loadscreen.waitfor(self.cache.ready, self.__next, ('up',))
46+
self.window.change_view(View(self.window, window=self.loadscreen), direction)
47+
self.loadscreen.waitfor(self.cache.ready, cmd=self.__next, args=('up',))
4848

4949
def __load(self, name, image, data):
5050
self.title.config(text=name)
51-
self.image = View(image, 'image')
52-
self.bio = View(Bio(self.window), 'widget')
51+
self.image = View(self.window, image=image)
52+
self.bio = View(self.window, window=Bio(self.window))
5353

5454
self._last = self.image
5555
self.bio.data.load(data)

src/main.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ def __init__(self, *args, **kwds):
2323
self.minsize(400, 500)
2424
self.maxsize(400, 500)
2525

26-
self.splash = Splash(self)
27-
self.splash.pack(expand=True, fill='both')
28-
# self.front = Front(self)
29-
# self.front.pack(fill='both', expand=True)
26+
# self.splash = Splash(self)
27+
# self.splash.pack(expand=True, fill='both')
28+
self.front = Front(self)
29+
self.front.pack(fill='both', expand=True)
3030

3131
def cleanup(self):
3232
with suppress(Exception):

src/view.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,25 +85,24 @@ def origin(self):
8585

8686

8787
class DrawType(Enum):
88-
IMAGE = 'create_image'
89-
WIDGET = 'create_window'
90-
TEXT = 'create_text'
88+
image = 'create_image'
89+
window = 'create_window'
90+
text = 'create_text'
9191

9292

9393
class View:
9494

95-
def __init__(self, window: Window, **kwds):
96-
self.window = window
95+
def __init__(self, master: Window, **kwds):
96+
self.master = master
9797
self.kwds = kwds
9898
self.drawtype = self.data = None
9999
for k, v in self.kwds.items():
100-
k = k.upper()
101100
if hasattr(DrawType, k):
102101
self.drawtype = DrawType[k]
103102
self.data = v
104103
if self.drawtype is None:
105104
raise NotImplementedError
106105

107106
def draw(self, *args, **kwds):
108-
fn = getattr(self.window, self.drawtype.value)
107+
fn = getattr(self.master, self.drawtype.value)
109108
return fn(*args, **{**self.kwds, **kwds})

0 commit comments

Comments
 (0)