11import json
22
33from .view import Window , View
4+ from .animate import Direction , BounceBall
45from . import widget , DOCS
56
67
7- class Question (widget .PrimaryFrame ):
8+ class Splash (widget .PrimaryFrame ):
89
9- def init (self ):
10- self .title = widget .PrimaryLabel (self )
11- self .choices = widget .SecondaryFrame (self )
10+ with (DOCS / 'questions.json' ).open () as fp :
11+ questions = json .load (fp )
1212
13- self .options = []
13+ def init (self ):
14+ self .intro = Intro (self , bg = 'gray' )
1415
15- def load (self , choices ):
16- for question in questions :
17- frame = widget .SecondaryFrame (self .choices )
18- check = widget .PrimaryCheckbutton (frame )
19- val = widget .SecondaryLabel (frame , text = question )
16+ self .btn_confirm = widget .PrimaryButton (
17+ self .intro .window , command = self .switch , text = 'Okay'
18+ )
19+ self .update ()
20+
21+ def build (self ):
22+ self .update ()
23+ self .intro .pack (fill = 'both' , expand = True )
24+ self .intro .build ()
25+ self .bounce (
26+ View (self .intro .window , window = self .btn_confirm )
27+ )
2028
21- frame .pack ()
22- check .pack (side = 'left' )
23- val .pack (side = 'left' )
29+ def bounce (self , view ):
30+ self .update ()
31+ start = view .master .center + (Direction .LEFT * 175 ) + (Direction .DOWN * 100 )
32+ wid = view .master .set_view (view , start )
33+ motion = BounceBall (view .master , wid , view .master .origin , speed = 6 )
34+ motion .kick (Direction .UP )
35+ self .after (0 , view .master .run , motion )
2436
25- self . title . pack ( fill = 'both' , expand = True )
26- self .choices . pack ( fill = 'both' , expand = True )
37+ def switch ( self ):
38+ self .master . master . switch ( )
2739
40+ def cleanup (self ):
41+ self .intro .cleanup ()
2842
29- class Splash (widget .PrimaryFrame ):
3043
44+ class Intro (widget .PrimaryFrame ):
3145 intro = (DOCS / 'intro.txt' ).read_text ()
32- with (DOCS / 'questions.json' ).open () as fp :
33- questions = json .load (fp )
3446
3547 def init (self ):
36- self .title = widget .PrimaryLabel (
37- self , text = self .master .master .title (),
38- font = ('Courier' , 14 ), wraplength = 300
39- )
48+ self .window = Window (self )
49+ self .window .pack (expand = True , fill = 'both' )
50+ self .update ()
4051
41- self .window = Window (self , bg = 'gray' )
52+ width = self .winfo_reqwidth ()
53+ self .title = View (
54+ self .window ,
55+ text = self .master .master .master .title (), # yikes
56+ font = ('Courier' , 17 ),
57+ width = width , justify = 'center'
58+ )
4259 self .intro = View (
4360 self .window ,
4461 text = self .intro ,
45- width = self . window . winfo_reqwidth () ,
46- font = ('sys' , 10 ), justify = 'center'
62+ width = width ,
63+ font = ('sys' , 12 ), justify = 'center'
4764 )
48- self .window .set_view (self .intro )
4965
50- self .btn_confirm = widget .PrimaryButton (self , command = self .begin , text = 'Okay' )
66+ def build (self ):
67+ self .update ()
68+ adjust = (Direction .LEFT * 175 ) + (Direction .DOWN * 100 )
69+
70+ self .window .set_view (self .title )
71+ self .window .set_view (self .intro , self .window .center + adjust )
72+ self .update ()
73+
74+ def cleanup (self ):
75+ self .window .animater .clear ()
76+
77+
78+ class Question (widget .PrimaryFrame ):
79+
80+ def init (self ):
81+ self .title = widget .PrimaryLabel (self )
82+ self .choices = widget .SecondaryFrame (self )
5183
52- self .title .pack (fill = 'x' , pady = 20 )
53- self .btn_confirm .pack (side = 'bottom' , expand = True )
84+ self .options = []
5485
55- def begin (self ):
56- pass
86+ def load (self , choices ):
87+ for question in questions :
88+ frame = widget .SecondaryFrame (self .choices )
89+ check = widget .PrimaryCheckbutton (frame )
90+ val = widget .SecondaryLabel (frame , text = question )
91+
92+ frame .pack ()
93+ check .pack (side = 'left' )
94+ val .pack (side = 'left' )
95+
96+ self .title .pack (fill = 'both' , expand = True )
97+ self .choices .pack (fill = 'both' , expand = True )
0 commit comments