peterbrittain / asciimatics

A cross platform package to do curses-like operations, plus higher level APIs and widgets to create text UIs and ASCII art animations

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dropdowns allocate horizontal space poorly

Davidy22 opened this issue · comments

Describe the bug
Current dropdown lists are a little bit ugly when there's too much horizontal space

To Reproduce
Create a dropdown list, make the terminal window very wide

Expected behavior
A setting to choose how wide the clickable region is, or maybe some padding, or an option to add padding between the label and the dropdown.

Screenshots
Untitled
^There's a lot of space between the end of the word and the closing bracket

System details (please complete the following information):

  • OS and version: Mint 20.2
  • Python version: 3.8
  • Python distribution: CPython
  • Asciimatics version latest

I suspect that this is related to your other issue and can be fixed in a similar way...

This is deliberate. Asciimatics tries to make the widgets align in each column of the Layout in order to simplify construction for most use cases. You'll see similar widths used for other widgets - e.g. the text entry widgets.

To get a more aesthetically pleasing form, you can specify relative widths of your columns. The forms demo (https://github.com/peterbrittain/asciimatics/blob/master/samples/forms.py) does this to create a margin on either side of the widgets (and so narrow any widgets in the form).

You can also use the Frame to limit the amount of real estate you actually use on the screen (and asciimatics will automatically centre it for you for free). You can also see that in the forms demo.

Sadly, though, extreme resizing is always going to make things messy - e.g. fixed positioning just leaves excessive blank space, then making the terminal really small truncation issues, etc. At some point we also have to rely on the user to be able to spot when they've done something problematic and pick a reasonably sized terminal.

If none of that works for you, I'd be happy to accept a PR to change the width of the dropdown based on a new parameter. I can give you some quick pointers on how to do that based on existing code.

The hope was for an option, or even default, for a dropdown that fits to the data:

Label [ option ]

Instead of fitting to the column width

Label [ option...............................................]
^full stops added because github minces spaces

Because the excess space on the right looks a little goofy

Cool. I think I've reviewed and submitted the comments for your PR. LMK if you can't see them.