-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft: Implement command widgets to textual CLI #8
base: main
Are you sure you want to change the base?
Conversation
7919ee0
to
f4752f7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm really excited about this PR.
I've left some comments and questions.
for widget in WIDGETS.keys(): | ||
yield Button(widget, id=widget) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could take these two lines of code and write them directly inside WidgetsApp.compose
, instead of yield WidgetButtons()
.
This would also mean you have to adjust the CSS and put it in widgets.css
.
for widget_name, widget in WIDGETS.items(): | ||
yield from widget(id=widget_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please use a clearer/more verbose name instead of widget
?
Something like widget_composer
, or something of the sorts.
src/textual_dev/previews/widgets.py
Outdated
# TabbedContatn missing | ||
# Tabs missing | ||
# TextLog missing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are still some widgets missing, as you note here.
Do you need help with those?
Will you add those in an upcoming commit?
id=id, | ||
) | ||
|
||
yield Footer() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this footer here? Is it showing any relevant bindings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent work with the missing widgets.
There's still ListView
missing, right? Are you working on it? Do you need help?
.github/workflows/pythonpackage.yml
Outdated
push: | ||
paths: | ||
- '.github/workflows/pythonpackage.yml' | ||
- '**.py' | ||
- '**.pyi' | ||
- '**.css' | ||
- '**.lock' | ||
- 'Makefile' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this change do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to run pipeline on each git push
to investigate possible problems quickly. This way I can run pipelines in my fork after each commit.
I tried to use YAML anchors to prevent code duplication, but they are not supported on Github so they were removed in later commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you are right. Sorry.
Maybe the button should say "ListView / ListItem" or something similar.
bar = ProgressBar(total=100, show_eta=False) | ||
bar.advance(50) | ||
yield Container(Center(Middle(bar)), id=id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that the progress bar is static, which makes sense, maybe create it as ProgressBar()
and don't advance it. That way, the user can see the indeterminate animation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do I understand it correctly that you want to remove bar.advance(50)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove bar.advance(50)
and also total=100
.
TabPane, | ||
Markdown, | ||
Tabs, | ||
TextLog, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unused import.
TextLog, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After I added remaining widgets, Windows builds started failing. Probably some added widget is not compatible with Windows?
Removing some widgets was an attempt to investigate which one started causing those problems.
Sorry, this Pull request is still WIP 🙈
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me the biggest blockers are those failing Windows tests. Do you know what could be behind that error?
Otherwise I will disable all newly added widgets one by one and see when tests start passing again.
def test_cli_widgets():
runner = CliRunner()
result = runner.invoke(run, ["widgets"])
> assert result.exit_code == 0
E AssertionError: assert 1 == 0
E + where 1 = <Result AssertionError('Driver must be in application mode')>.exit_code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tried disabling new widgets. I have no idea why Windows builds fail, I think it is unrelated to my changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All widgets work on all platforms. Maybe the test is flakey?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to be constantly failing.
Do you know what could Driver must be in application mode
mean?
@rodrigogiraoserrao This PR was rushed during the EuroPython sprint. I'm changing it to draft so I can finish it properly. |
9b4b9f4
to
bb57f01
Compare
Feel free to finish the PR as far as the functionality goes, with all the widgets, and remove the test you added because it is not the correct way of testing a Textual app. |
This PR closes this issue.
Example: