Replies: 3 comments
-
any ideas here? I'm sure I'm missing something simple... much appreciated! |
Beta Was this translation helpful? Give feedback.
-
NOTE: I posted this to stackoverflow as well, with a bounty of 200, to see if someone could see how this is possible, fyi: |
Beta Was this translation helpful? Give feedback.
-
I found a solution that works here: https://github.com/jspv/spotbot/blob/main/spotbot/Widgets/footer.py#L70 I do this: text = Text.from_markup("https://textualize.io")
text.apply_meta(
meta={
"@mouse.down": f"app.press('b')",
"link_id": my_link_id
}
) and in the parent widget:: async def on_mouse_down(self, event: events.MouseDown) -> None:
self.link_id = event.style.meta.get("link_id") This emulates a "b" press when the text is clicked. |
Beta Was this translation helpful? Give feedback.
-
I'm trying to get it so I can add links in text rendered by Textual, as discussed in this thread in rich discussions which led me to textual (great!).
but... I don't seem to be able to get it to work. So I built this little sample to try it out.
Anyone know what I'm doing wrong here?
In this sample, clicking on the word "World" should change the background color to red.
NOTE: I also bound the "b" key to do pretty much the same thing, so I could see it work
It should change the background color, and the subtitle of the app.
Thanks for any pointers!
Beta Was this translation helpful? Give feedback.
All reactions