-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathQuizMaster
More file actions
executable file
·92 lines (83 loc) · 2.25 KB
/
QuizMaster
File metadata and controls
executable file
·92 lines (83 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env python3
import os
import json
import random
from typing import List
from fuzzywuzzy import fuzz
from glob import glob
from textual.app import App, ComposeResult
from textual.widgets import (
Header, Footer, Button, Static, Input, ListView, ListItem, Label
)
from textual.containers import Vertical, Center
from textual.screen import Screen
from quiz import *
from quizcreator import *
class MainMenu(Screen):
def compose(self):
yield Header()
with Center():
with Vertical(id="menu-vertical"):
yield Static("Welcome to QuizMasterTerminal!", id="heading")
yield Button("Play a Quiz", id="play")
yield Button("Make a Quiz", id="make")
yield Button("Quit", id="quit")
yield Footer()
def on_button_pressed(self, event: Button.Pressed):
if event.button.id == "play":
self.app.push_screen(QuizSearchScreen())
elif event.button.id == "make":
self.app.push_screen(MakeQuizScreen())
elif event.button.id == "quit":
self.app.exit()
class QuizMaster(App):
CSS = """
#heading {
text-align: center;
margin-bottom: 2;
color: cyan;
text-style: bold;
background: black;
height: 5;
content-align: center middle;
border: heavy $accent;
}
#menu-vertical {
width: 50;
height: 26;
padding: 2 4;
margin-top: 5;
background: $panel;
border: thick $accent;
content-align: center middle;
align-horizontal: center;
}
Button {
width: 100%;
min-width: 25;
max-width: 50;
height: 3;
margin-top: 2;
content-align: center middle;
text-align: center;
text-style: bold;
color: $text;
border: round $primary;
transition: background 300ms, color 300ms;
}
Button:hover {
background: $accent;
color: $panel;
}
#quiztitle {
text-style: bold;
}
#qlist {
height: 15;
}
"""
BINDINGS = [("q", "quit", "Quit"), ("b", "back", "Back")]
def on_mount(self):
self.push_screen(MainMenu())
if __name__ == "__main__":
QuizMaster().run()