-
import os
from textual import on, work
from textual.app import App, ComposeResult, events
from textual.widgets import *
class ScriptApp(App):
def compose(self) -> ComposeResult:
yield Button("Submit", variant="primary", id="button")
yield Output(highlight=True)
def on_button_pressed(self, event: Button.Pressed) -> None:
self.query_one(RichLog).clear()
self.query_one(RichLog).begin_capture_print()
if event.button.id == "button":
baseSHA = 12345
headSHA = 67890
print(
f"\033[1;31mPlease check if the {baseSHA} and\033[0m{os.linesep}\033[1;31mthe {headSHA} are in the same repository!\033[0m"
)
print("Writing comments...")
print(f"\033[1;32mSuccessful\033[0m")
class Output(RichLog):
@on(events.Print)
def on_print(self, event: events.Print) -> None:
if event.text.strip():
self.write(event.text)
app = ScriptApp()
if __name__ == "__main__":
app.run() |
Beta Was this translation helpful? Give feedback.
Answered by
Tim-Cao
Jan 18, 2024
Replies: 1 comment 3 replies
-
|
Can I just check as I've been down this rabbit hole before: does your logging actually involve some sort of subprocess and this code is just a MRE? |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment


It works. Many thanks @TomJGooding