From bed5776c6106997e3693107e592a66a8aa644e91 Mon Sep 17 00:00:00 2001 From: Sophia S Date: Wed, 3 Jun 2026 12:30:36 +0200 Subject: [PATCH] =?UTF-8?q?kleine=20=C3=A4nderungen,=20funktioniert=20aber?= =?UTF-8?q?=20nicht?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- route_planning.py | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/route_planning.py b/route_planning.py index 126cfd8..1465e8f 100644 --- a/route_planning.py +++ b/route_planning.py @@ -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. """ + +import datetime import time +import json from prompt_toolkit import Application from prompt_toolkit.buffer import Buffer 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.key_binding import KeyBindings from prompt_toolkit.shortcuts import message_dialog from prompt_toolkit.shortcuts import yes_no_dialog from prompt_toolkit.shortcuts import input_dialog from prompt_toolkit import prompt - import backend @@ -46,15 +49,18 @@ def run_route_planning(hafas: backend.HafasClient | None = None): start = prompt("Start: ") end = prompt("Ende: ") - + station1 = hafas.getStationNames(start) + station2 = hafas.getStationNames(end) startBuffer = Buffer() 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 etaBuffer = Buffer() - etaBuffer.text = "13:45" #testweise, später mit tatsächlicher Ankunftszeit von Hafas ersetzen - #etaBuffer.text = (ungefähre ankunftszeit) + etaBuffer.text = "eta" #--//-- @@ -71,7 +76,14 @@ def run_route_planning(hafas: backend.HafasClient | None = None): #drivetimeBuffer.text = Fahrzeit von Hafas. 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' 🕐 {now.strftime("%H:%M:%S")} ' + f'' + ) 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(content=BufferControl(buffer=endBuffer, focusable=True)), #end Station 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( + content=FormattedTextControl(get_clock_text), + height=1, + style="bg:#163D7A fg:#aaddff",), ])