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

Commit 8621ab8

Browse files
committed
Basics done
1 parent c4f4281 commit 8621ab8

File tree

4 files changed

+58
-59
lines changed

4 files changed

+58
-59
lines changed

res/widgets.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22

33
[primary]
44

5+
56
[secondary]
67

src/front.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ def init(self):
4141
self.btn_like = widget.PrimaryButton(
4242
self.commandbar, text='Yep', bg='green', command=self.cmd_like
4343
)
44-
self.title.pack()
45-
self.window.pack()
46-
self.commandbar.pack()
44+
self.title.pack(fill='x')
45+
self.window.pack(fill='both')
46+
self.commandbar.pack(side='bottom', fill='x')
4747

48+
self.btn_bio.pack()
4849
self.btn_dislike.pack(side='left')
49-
self.btn_bio.pack(side='left')
50-
self.btn_like.pack(side='left')
50+
self.btn_like.pack(side='right')
5151

5252
def cmd_dislike(self):
5353
self.__change_image('LEFT')

src/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def __init__(self, *args, **kwds):
3030
self.maxsize(400, 500)
3131

3232
self.front = Front(self)
33-
self.front.pack(fill='both')
33+
self.front.pack(fill='both', expand=True)
3434

3535
self.__cache()
3636
self.front.cache = self.cache.cats

src/widget.py

Lines changed: 51 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,92 @@
11
import tkinter as tk
22
from configparser import ConfigParser
3-
43
from . import THEME
54

65
parser = ConfigParser()
76
parser.read(THEME)
87

98

10-
class MetaWidget(type):
11-
DEFAULTS = {}
12-
13-
def __new__(cls, name, bases, namespace, **kwds):
14-
for base in (cls,) + bases:
15-
if hasattr(base, 'THEME'):
16-
theme = parser[base.THEME]
17-
kwds.update(theme)
18-
break
19-
20-
kwds.update(cls.DEFAULTS)
21-
return super().__new__(cls, name, bases, namespace, **kwds)
22-
9+
class SecondaryFrame(tk.Frame):
10+
DEFAULT = {}
2311

24-
class Base(metaclass=MetaWidget):
25-
THEME = 'base'
26-
27-
def __init__(self, cls, *args, **kwds):
28-
cls.__init__(*args, **kwds)
12+
def __init__(self, *args, **kwds):
13+
self.DEFAULT.update(kwds)
14+
super().__init__(*args, **self.DEFAULT)
2915
if hasattr(self, 'init'):
3016
self.init()
3117

3218

33-
class Secondary(Base):
34-
THEME = 'secondary'
35-
36-
37-
class Primary(Base):
38-
THEME = 'primary'
39-
19+
class SecondaryButton(tk.Button):
20+
DEFAULT = {
21+
'height': 1,
22+
'width': 10
23+
}
4024

41-
class SecondaryFrame(tk.Frame, Secondary):
42-
def __init__(self, *args, **kwargs):
43-
super().__init__(*args, **kwargs)
25+
def __init__(self, *args, **kwds):
26+
self.DEFAULT.update(kwds)
27+
super().__init__(*args, **self.DEFAULT)
4428
if hasattr(self, 'init'):
4529
self.init()
4630

4731

48-
class SecondaryButton(tk.Button, Secondary):
49-
def __init__(self, *args, **kwargs):
50-
super().__init__(*args, **kwargs)
51-
if hasattr(self, 'init'):
52-
self.init()
32+
class SecondaryLabel(tk.Label):
33+
DEFAULT = {}
5334

54-
55-
class SecondaryLabel(tk.Label, Secondary):
56-
def __init__(self, *args, **kwargs):
57-
super().__init__(*args, **kwargs)
35+
def __init__(self, *args, **kwds):
36+
self.DEFAULT.update(kwds)
37+
super().__init__(*args, **self.DEFAULT)
5838
if hasattr(self, 'init'):
5939
self.init()
6040

6141

62-
class SecondaryCanvas(tk.Canvas, Secondary):
63-
def __init__(self, *args, **kwargs):
64-
super().__init__(*args, **kwargs)
42+
class SecondaryCanvas(tk.Canvas):
43+
DEFAULT = {}
44+
45+
def __init__(self, *args, **kwds):
46+
self.DEFAULT.update(kwds)
47+
super().__init__(*args, **self.DEFAULT)
6548
if hasattr(self, 'init'):
6649
self.init()
6750

6851

69-
class PrimaryFrame(tk.Frame, Primary):
70-
def __init__(self, *args, **kwargs):
71-
super().__init__(*args, **kwargs)
52+
class PrimaryFrame(tk.Frame):
53+
DEFAULT = {}
54+
55+
def __init__(self, *args, **kwds):
56+
self.DEFAULT.update(kwds)
57+
super().__init__(*args, **self.DEFAULT)
7258
if hasattr(self, 'init'):
7359
self.init()
7460

7561

76-
class PrimaryButton(tk.Button, Primary):
77-
def __init__(self, *args, **kwargs):
78-
super().__init__(*args, **kwargs)
62+
class PrimaryButton(tk.Button):
63+
DEFAULT = {
64+
'height': 2,
65+
'width': 10
66+
}
67+
68+
def __init__(self, *args, **kwds):
69+
self.DEFAULT.update(kwds)
70+
super().__init__(*args, **self.DEFAULT)
7971
if hasattr(self, 'init'):
8072
self.init()
8173

8274

83-
class PrimaryLabel(tk.Label, Primary):
84-
def __init__(self, *args, **kwargs):
85-
super().__init__(*args, **kwargs)
75+
class PrimaryLabel(tk.Label):
76+
DEFAULT = {}
77+
78+
def __init__(self, *args, **kwds):
79+
self.DEFAULT.update(kwds)
80+
super().__init__(*args, **self.DEFAULT)
8681
if hasattr(self, 'init'):
8782
self.init()
8883

8984

90-
class PrimaryCanvas(tk.Canvas, Primary):
91-
def __init__(self, *args, **kwargs):
92-
super().__init__(*args, **kwargs)
85+
class PrimaryCanvas(tk.Canvas):
86+
DEFAULT = {}
87+
88+
def __init__(self, *args, **kwds):
89+
self.DEFAULT.update(kwds)
90+
super().__init__(*args, **self.DEFAULT)
9391
if hasattr(self, 'init'):
9492
self.init()

0 commit comments

Comments
 (0)