@@ -20,8 +20,8 @@ def __init__(self, topic: str):
2020 self .root .title ("Focus Blocker" )
2121
2222 # Make it 700x600 and center it
23- window_width = 700
24- window_height = 600
23+ window_width = 750
24+ window_height = 650
2525 screen_width = self .root .winfo_screenwidth ()
2626 screen_height = self .root .winfo_screenheight ()
2727 center_x = int (screen_width / 2 - window_width / 2 )
@@ -35,9 +35,9 @@ def __init__(self, topic: str):
3535 self .root .protocol ("WM_DELETE_WINDOW" , self .disable_event )
3636
3737 # Fonts & Colors
38- self .title_font = ("Consolas " , 32 , "bold " )
39- self .body_font = ("Arial " , 16 )
40- self .btn_font = ("Arial " , 14 , "bold" )
38+ self .title_font = ("Impact " , 34 , "normal " )
39+ self .body_font = ("Segoe UI " , 16 )
40+ self .btn_font = ("Segoe UI " , 14 , "bold" )
4141 self .color_danger = "#ff3b3b"
4242 self .color_primary = "#FF9800"
4343 self .color_bg = "#111827"
@@ -55,14 +55,19 @@ def build_ui_loading(self):
5555 """Displays a loading screen while Gemini generates the 3 questions."""
5656 self .clear_ui ()
5757
58- title_lbl = tk .Label (self .root , text = "DISTRACTION DETECTED!" , font = self .title_font , fg = self .color_danger , bg = self .color_bg )
59- title_lbl .pack (pady = (100 , 20 ))
58+ self .canvas = tk .Canvas (self .root , highlightthickness = 0 )
59+ self .canvas .place (x = 0 , y = 0 , relwidth = 1 , relheight = 1 )
60+ colors = ["#171e2e" , "#131926" ]
61+ for i in range (30 ):
62+ y = i * 30
63+ self .canvas .create_rectangle (0 , y , 1000 , y + 30 , fill = colors [i % 2 ], outline = "" )
64+
65+ self .canvas .create_text (375 , 150 , text = "DISTRACTION DETECTED!" , font = self .title_font , fill = self .color_danger )
6066
61- info_lbl = tk . Label ( self . root , text = f"You must answer 3 questions about '{ self .topic } ' to unlock." , font = self . body_font , fg = "#fff" , bg = self . color_bg )
62- info_lbl . pack ( )
67+ txt = f"You must answer 3 questions about '{ self .topic } ' to unlock."
68+ self . canvas . create_text ( 375 , 250 , text = txt , font = self . body_font , fill = "#fff" , width = 600 , justify = "center" )
6369
64- loading_lbl = tk .Label (self .root , text = "Loading questions..." , font = ("Arial" , 14 ), fg = self .color_primary , bg = self .color_bg )
65- loading_lbl .pack (pady = 20 )
70+ self .canvas .create_text (375 , 350 , text = "Loading questions..." , font = ("Segoe UI" , 14 ), fill = self .color_primary )
6671
6772 def fetch_questions (self ):
6873 """Runs concurrently to fetch questions from Gemini."""
@@ -97,32 +102,30 @@ def build_ui_question(self):
97102
98103 current_mcq = self .mcqs [self .current_q_index ]
99104
100- # Top Banner
101- header = tk .Frame (self .root , bg = "#000" , height = 100 )
102- header .pack (fill = "x" , side = "top" )
103-
104- title_lbl = tk .Label (header , text = "FOCUS PENALTY" , font = ("Helvetica" , 24 , "bold" ), fg = self .color_danger , bg = "#000" )
105- title_lbl .pack (pady = 30 )
105+ self .canvas = tk .Canvas (self .root , highlightthickness = 0 )
106+ self .canvas .place (x = 0 , y = 0 , relwidth = 1 , relheight = 1 )
107+ colors = ["#171e2e" , "#131926" ]
108+ for i in range (30 ):
109+ y = i * 30
110+ self .canvas .create_rectangle (0 , y , 1000 , y + 30 , fill = colors [i % 2 ], outline = "" )
111+
112+ # Top banner background
113+ self .canvas .create_rectangle (0 , 0 , 1000 , 80 , fill = "#0f172a" , outline = "" )
114+ self .canvas .create_text (375 , 40 , text = "FOCUS PENALTY" , font = ("Impact" , 28 , "normal" ), fill = self .color_primary )
106115
107- progress_lbl = tk .Label (self .root , text = f"Question { self .current_q_index + 1 } of { self .correct_answers_needed } " , font = ("Arial" , 12 , "bold" ), fg = self .color_primary , bg = self .color_bg )
108- progress_lbl .pack (pady = 20 )
109-
110- # Question Text
111- q_text = tk .Label (self .root , text = current_mcq .question , font = ("Arial" , 16 ), fg = "#fff" , bg = self .color_bg , wraplength = 600 , justify = "center" )
112- q_text .pack (pady = 20 )
113-
114- # Container for evenly spaced buttons
115- btn_frame = tk .Frame (self .root , bg = self .color_bg )
116- btn_frame .pack (pady = 20 )
116+ # Details & text
117+ self .canvas .create_text (375 , 120 , text = f"Question { self .current_q_index + 1 } of { self .correct_answers_needed } " , font = ("Segoe UI" , 12 , "bold" ), fill = self .color_primary )
118+ self .canvas .create_text (375 , 180 , text = current_mcq .question , font = ("Segoe UI" , 16 ), fill = "#fff" , width = 650 , justify = "center" )
117119
118- # Create buttons
119- for opt in current_mcq .options :
120+ # Buttons placed evenly
121+ start_y = 280
122+ for i , opt in enumerate (current_mcq .options ):
120123 btn = tk .Button (
121- btn_frame ,
124+ self . root ,
122125 text = opt ,
123- font = ("Arial " , 11 , "bold" ),
124- bg = "#333 " ,
125- fg = "#fff " ,
126+ font = ("Segoe UI " , 12 , "bold" ),
127+ bg = "#334155 " ,
128+ fg = "#f8fafc " ,
126129 activebackground = self .color_primary ,
127130 activeforeground = "#000" ,
128131 width = 50 ,
@@ -131,10 +134,9 @@ def build_ui_question(self):
131134 cursor = "hand2" ,
132135 command = lambda o = opt : self .check_answer (o , current_mcq )
133136 )
134- btn . pack ( pady = 5 )
137+ self . canvas . create_window ( 375 , start_y + ( i * 65 ), window = btn )
135138
136- self .feedback_lbl = tk .Label (self .root , text = "" , font = self .btn_font , bg = self .color_bg )
137- self .feedback_lbl .pack (pady = 10 )
139+ self .feedback_text = self .canvas .create_text (375 , 570 , text = "" , font = self .btn_font , fill = self .color_danger , width = 650 , justify = "center" )
138140
139141
140142
@@ -143,12 +145,12 @@ def check_answer(self, selected: str, mcq):
143145 if selected == mcq .correct_answer :
144146 self .current_q_index += 1
145147 if self .current_q_index >= self .correct_answers_needed :
146- self .feedback_lbl . config ( text = "Challenge Passed. Unlocking..." , fg = "#00E676" )
148+ self .canvas . itemconfig ( self . feedback_text , text = "Challenge Passed. Unlocking..." , fill = "#00E676" )
147149 self .root .after (1000 , self .unlock_system )
148150 else :
149151 self .build_ui_question ()
150152 else :
151- self .feedback_lbl . config ( text = f"WRONG! { mcq .explanation } " , fg = self .color_danger , wraplength = 800 )
153+ self .canvas . itemconfig ( self . feedback_text , text = f"WRONG! { mcq .explanation } " , fill = self .color_danger )
152154
153155 def unlock_system (self ):
154156 """Destroys the tkinter blocking window entirely."""
0 commit comments