kleine änderungen, funktioniert aber nicht

This commit is contained in:
Sophia S 2026-06-03 12:30:36 +02:00
parent d0a67d5a18
commit bed5776c61

View file

@ -15,18 +15,21 @@ Note: This module is a minimal TUI stub. Many features are not implemented
yet (station lookup, route rendering). Add TODOs where appropriate. yet (station lookup, route rendering). Add TODOs where appropriate.
""" """
import datetime
import time import time
import json
from prompt_toolkit import Application from prompt_toolkit import Application
from prompt_toolkit.buffer import Buffer from prompt_toolkit.buffer import Buffer
from prompt_toolkit.layout.containers import HSplit, VSplit, Window from prompt_toolkit.layout.containers import HSplit, VSplit, Window
from prompt_toolkit.layout.controls import BufferControl from prompt_toolkit.formatted_text import HTML
from prompt_toolkit.layout.controls import BufferControl, FormattedTextControl
from prompt_toolkit.layout.layout import Layout from prompt_toolkit.layout.layout import Layout
from prompt_toolkit.key_binding import KeyBindings from prompt_toolkit.key_binding import KeyBindings
from prompt_toolkit.shortcuts import message_dialog from prompt_toolkit.shortcuts import message_dialog
from prompt_toolkit.shortcuts import yes_no_dialog from prompt_toolkit.shortcuts import yes_no_dialog
from prompt_toolkit.shortcuts import input_dialog from prompt_toolkit.shortcuts import input_dialog
from prompt_toolkit import prompt from prompt_toolkit import prompt
import backend import backend
@ -46,15 +49,18 @@ def run_route_planning(hafas: backend.HafasClient | None = None):
start = prompt("Start: ") start = prompt("Start: ")
end = prompt("Ende: ") end = prompt("Ende: ")
station1 = hafas.getStationNames(start)
station2 = hafas.getStationNames(end)
startBuffer = Buffer() startBuffer = Buffer()
startBuffer.text = start startBuffer.text = start
etdBuffer = Buffer()
etdBuffer.text = "13:00" #testweise, später mit tatsächlicher Abfahrtszeit von Hafas ersetzen
#etdBuffer.text = (ungefähre abfahrtszeit)
#departure = #current time, muss noch abgesprochen werden.
etdBuffer = Buffer()
etdBuffer.text = "etd" #muss noch alles definiert werden
@ -62,8 +68,7 @@ def run_route_planning(hafas: backend.HafasClient | None = None):
endBuffer.text = end endBuffer.text = end
etaBuffer = Buffer() etaBuffer = Buffer()
etaBuffer.text = "13:45" #testweise, später mit tatsächlicher Ankunftszeit von Hafas ersetzen etaBuffer.text = "eta" #--//--
#etaBuffer.text = (ungefähre ankunftszeit)
@ -71,7 +76,14 @@ def run_route_planning(hafas: backend.HafasClient | None = None):
#drivetimeBuffer.text = Fahrzeit von Hafas. #drivetimeBuffer.text = Fahrzeit von Hafas.
infoBuffer = Buffer() infoBuffer = Buffer()
infoBuffer.text = f"Routenplanung von {start} nach {end}" infoBuffer.text = f"Routenplanung von {station1.name} nach {station2.name}"
def get_clock_text():
now = datetime.datetime.now()
return HTML(
f'<b> 🕐 {now.strftime("%H:%M:%S")} </b>'
f'<style fg="#aaddff"> {now.strftime("%A, %d. %B %Y")} </style>'
)
root_container = HSplit(children=[ root_container = HSplit(children=[
@ -83,13 +95,13 @@ def run_route_planning(hafas: backend.HafasClient | None = None):
Window(width = 1, height = 2, char= ".", style= "fg:#A86FD6"), #Trennlinie Window(width = 1, height = 2, char= ".", style= "fg:#A86FD6"), #Trennlinie
Window(content=BufferControl(buffer=endBuffer, focusable=True)), #end Station Window(content=BufferControl(buffer=endBuffer, focusable=True)), #end Station
Window(content=BufferControl(buffer=etaBuffer, focusable=False)), #ankunftszeit Window(content=BufferControl(buffer=etaBuffer, focusable=False)), #ankunftszeit
#Window(content=BufferControl(buffer=drivetimeBuffer, focusable=False)),
#Window(Content)
]), ]),
Window(height=1, char=' ', style="bg:#2A71D5 fg:black"), Window(height=1, char=' ', style="bg:#2A71D5 fg:black"),
Window(
content=FormattedTextControl(get_clock_text),
height=1,
style="bg:#163D7A fg:#aaddff",),
]) ])