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

Commit e6ff599

Browse files
committed
Spash page resources
1 parent 3af66e1 commit e6ff599

File tree

9 files changed

+69
-10
lines changed

9 files changed

+69
-10
lines changed

res/docs/intro.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Welcome to the "Always one-hundred percent correct, never wrong in any way, completely correct"
2+
personality quiz. Through this quiz you will achieve new levels of spiritual insight, of not only
3+
yourself, but the very fabric of reality.
4+
5+
However, first I'd like to get to know you a little. Please answer these very important questions
6+
with the utmost honesty, they are crucial to achieving enlightenment.

res/docs/questions.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"What is your least favorite color?": ["#0801d5", "#ee018d", "#03a130", "#db0013", "#fd9501"],
3+
4+
}

res/images/checkbox.png

5.4 KB
Loading

src/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@
99
IMAGES: Path = RES / 'images'
1010
SOUNDS: Path = RES / 'sounds'
1111
API: Path = RES / 'api.json'
12+
DOCS: Path = RES / 'docs'

src/__main__.py

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

33
if __name__ == "__main__":
44
root = App()
5-
root.protocol('WM_DELETE_WINDOW', root.cleanup)
5+
# root.protocol('WM_DELETE_WINDOW', root.cleanup)
66
root.mainloop()

src/front.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,3 @@ def load(self, data: dict):
140140
hobbies = self.__build_hobbies(data['hobbies'])
141141
info.pack(expand=True, fill='both')
142142
hobbies.pack(expand=True, fill='both')
143-
144-
145-
class Splash(widget.PrimaryFrame):
146-
147-
def init(self):
148-
self.window = Window(self)

src/main.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66

77
from .front import Front
8+
from .splash import Splash
89
from . import SETTINGS
910

1011

@@ -25,8 +26,10 @@ def __init__(self, *args, **kwds):
2526
self.minsize(400, 500)
2627
self.maxsize(400, 500)
2728

28-
self.front = Front(self)
29-
self.front.pack(fill='both', expand=True)
29+
self.splash = Splash(self)
30+
self.splash.pack()
31+
# self.front = Front(self)
32+
# self.front.pack(fill='both', expand=True)
3033

3134
def cleanup(self):
3235
with suppress(Exception):

src/splash.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import tkinter as tk
2+
import json
3+
4+
from .view import Window
5+
from . import widget, DOCS, IMAGES
6+
7+
8+
class Question(widget.PrimaryFrame):
9+
10+
def init(self):
11+
self.title = widget.PrimaryLabel(self)
12+
self.choices = widget.SecondaryFrame(self)
13+
14+
self.options = []
15+
16+
def load(self, choices):
17+
for question in questions:
18+
frame = widget.SecondaryFrame(self.choices)
19+
check = widget.PrimaryCheckbutton(frame)
20+
val = widget.SecondaryLabel(frame, text=question)
21+
22+
frame.pack()
23+
check.pack(side='left')
24+
val.pack(side='left')
25+
26+
self.title.pack(fill='both', expand=True)
27+
self.choices.pack(fill='both', expand=True)
28+
29+
30+
class Splash(widget.PrimaryFrame):
31+
32+
intro = (DOCS / 'intro.txt').read_text().replace('\n', ' ').split(' ')
33+
34+
def init(self):
35+
self.window = Window(self)
36+
Question(self)
37+
38+

src/widget.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import tkinter as tk
22
from configparser import ConfigParser
3-
from . import THEME
3+
from . import THEME, IMAGES
44

55
parser = ConfigParser()
66
parser.read(THEME)
@@ -96,3 +96,16 @@ def __init__(self, *args, **kwds):
9696
super().__init__(*args, **{**self.DEFAULT, **kwds})
9797
if hasattr(self, 'init'):
9898
self.init()
99+
100+
101+
class PrimaryCheckbutton(tk.Checkbutton):
102+
DEFAULT = {
103+
'bg': 'black'
104+
}
105+
img = IMAGES / 'checkbox.png'
106+
107+
def __init__(self, *args, **kwds):
108+
img = tk.PhotoImage(file=self.img)
109+
super().__init__(*args, image=img, **{**self.DEFAULT, **kwds})
110+
if hasattr(self, 'init'):
111+
self.init()

0 commit comments

Comments
 (0)