Skip to content
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

Can't change a Select widget promt and options #2983

Closed
ShinoNia opened this issue Jul 22, 2023 · 5 comments · Fixed by #3701
Closed

Can't change a Select widget promt and options #2983

ShinoNia opened this issue Jul 22, 2023 · 5 comments · Fixed by #3701

Comments

@ShinoNia
Copy link

ShinoNia commented Jul 22, 2023

yield Select(options = [("Opt 1", 1), ("Opt 2", 2)], id='select', allow_blank=False, prompt="select")
select_widget = self.query_one('#select')

These lines don't have effect:

select_widget._options = [("Opt 3", 1)]
select_widget.options = [("Opt 3", 1)]
select_widget.prompt = "select 2"

For the options, I can use select_widget.set_options([("Opt 3", 1)]), but I can't change the prompt and it's quite inconvenient

@github-actions
Copy link

We found the following entries in the FAQ which you may find helpful:

Feel free to close this issue if you found an answer in the FAQ. Otherwise, please give us a little time to review.

This is an automated reply, generated by FAQtory

@davep
Copy link
Contributor

davep commented Jul 22, 2023

@ShinoNia Your report is a little unclear, so I want to check a couple of things. You say that this doesn't work:

select_widget._options = [("Opt 3", 1)]

You're attempting to access an internal value there (denoted by the leading _); no public interface of Textual will have a heading _ so that wouldn't be the way to do it.

You also say this doesn't work:

select_widget.options = [("Opt 3", 1)]

which is correct. That isn't the documented method of updating the options for a Select.

As you appear to have discovered, set_options is the documented method for setting new options on a Select.

Can I just be clear here that you're not reporting anything to do with this?

Assuming you're not, would I be correct in understanding that the issue you're reporting here is that this:

select_widget.prompt = "select 2"

has no visible effect? If so I agree and that would appear to be a bug that requires addressing.

@rodrigogiraoserrao
Copy link
Contributor

rodrigogiraoserrao commented Jul 22, 2023

@davep related to #2603?

@davep
Copy link
Contributor

davep commented Jul 22, 2023

@rodrigogiraoserrao Not if I'm reading it correctly. Select.prompt is more akin to Input.placeholder.

Copy link

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants