Skip to content

Ability to add logic inside widget #6072

@cyberalt1

Description

@cyberalt1

One of the most important things holding textual back right now is the ability to do python logic inside a widget.

For example, I want to make a repl in textual. As far as I know this is completely impossible without hundreds of lines of code. Where as in plain python you can do this

while True:
  x = input("?: ")
  print(x)

It would be nice to then just take that while loop and just have a widget that can run that code. Like a container widget that just keeps that output prompt inside of the widget. For example:

def run_code():
 pass

class Myapp(App):
 def compose():
  yield CodeContainer(func=run_code)

This would make it so much easier to write things like REPLs and things that have to respond to user input.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions