-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
54 lines (38 loc) · 1.23 KB
/
app.py
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
import os
from textual import events
from textual.app import App
from textual.widgets import Header, Footer
from utils import generate_slide
directory: str = "slides"
class HeyIMadeThisWithPython(App):
screen_title = 'Prezi'
CSS_PATH = "styles/prezi.tcss"
SCREENS = {}
slide_number = 0
for file in sorted(os.listdir(directory)):
if file == '__init__.py':
continue
if file.split('.')[-1] not in ('py', 'MD', 'md'):
continue
slide = generate_slide(file)
SCREENS[file] = slide
def on_key(self, event: events.Key) -> None:
screen_list = list(self.SCREENS.keys())
try:
if event.key == "right" and self.slide_number < len(self.SCREENS.keys()):
self.slide_number += 1
elif event.key == "left" and self.slide_number > 0:
self.slide_number -= 1
else:
# Do nothing
pass
screen = screen_list[self.slide_number]
self.push_screen(screen)
except Exception:
pass
def compose(self):
yield Header(name="Prezi")
yield Footer()
if __name__ == "__main__":
app = HeyIMadeThisWithPython()
app.run()