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

Wishlist of Features and QOL Improvements #177

Closed
16 tasks done
UmbralReaper opened this issue Dec 15, 2020 · 4 comments
Closed
16 tasks done

Wishlist of Features and QOL Improvements #177

UmbralReaper opened this issue Dec 15, 2020 · 4 comments
Labels
enhancement New feature or request
Milestone

Comments

@UmbralReaper
Copy link

UmbralReaper commented Dec 15, 2020

First off, thanks for making such a great library. 👍 This is one of, if not the most complete gui library for pygame I have seen. However, there are a few major and a couple minor issues that make the library rather unintuitive to use.

Issues

Long import statement

  • Resolved in comment below
    The import statement is huge, and, as you can't do multiple imports, requires a dedicated import for every element. The length also makes it virtually impossible (or at least incredibly irritating) to create an object without a dedicated import statement.
from pygame_gui.elements.ui_text_entry_line import UITextEntryLine
data_entry = pygame_gui.elements.ui_text_entry_line.UITextEntryLine(relative_rect=Rect(x, y, w, h), manager=manager)

UITextEntryLine

text_input = UITextEntryLine(relative_rect=Rect(x, y, w, h), manager=manager, text='Input some text.')

UITextBox

  • .clear() method to clear the text, instead of calling .kill(). Add clear() to text box and text line #316
  • .set_text() method to change the contents, rather than the current method.
  • Implicitly initiate empty if no html_text parameter is provided. - this is not possible without API break
  • .get_pos() method to get position. - can do this with text_box.get_abs_rect().topleft etc is generally superior to just one get_pos() as you can get the .right, .centerx etc type attributes which should be familiar to users of pygame.

UIDropDownMenu

Not sure what the reasoning is for these two. It used to work more like this but then somebody asked for it to work the other way.

Implicit UIManager

  • Probably is a way to add a global to module's __init__.py you can 'register' a default manager with. Would need to raise an exception if you didn't supply a manager and also hadn't registered a default manager. I guess we could also just register the first manager created as the default manager... Add global default UIManager option #320

Adding the same boilerplate manager=manager to every object gets tiring quickly. It would be nice to have an option to set a default manager that is used when no explicit manager is declared.

manager = pygame_gui.UIManager((width, height), 'theme.json')
pygame_gui.set_default_manager(manager)
text_box= UITextBox(relative_rect=Rect(x, y, w, h), html_text='This is a text box.')

html_text

Special Effects

  • Method to change the typing speed for fade_appear. (added params to text effects in 0.6.0)

Table ui_element

  • New UITable element feature request. Create a UITable element #317
    Let's say I was in the (not uncommon) situation of wanting to display multiple pieces of information to the user at one time. To keep it simple, let's say I wanted to display name, hp, xp, level, and mana. To do this the traditional way, this would require 5 UITextBoxes, 10 if I wanted to display what the value stood for next to it. Enter the (tentatively named) UITable. With only one ui_element it should be possible to keep track of all those pieces of information.
# Note that this is only an example implementation to show desired features
character_sheet = UITable(relative_rect=Rect(x, y, w, h), manager=manager)
character_sheet.title = 'Character Sheet'
character_sheet.add_column(header=None, rows=['name', 'hp', 'xp', 'level', 'mana'])
character_sheet.add_colum(header=None, rows=['Bob', 10, 0, 1, 10])
@UmbralReaper UmbralReaper added the enhancement New feature or request label Dec 15, 2020
@Snayff
Copy link

Snayff commented Dec 17, 2020

It's not easy to call out the bits I'd support as it's one big list but on the whole, for what it's worth, I think it's a pretty great list.

Two biggies:
UITable sounds extremely useful - I was literally dealing with this use case 20 minutes ago.
Default manager would be a great reduction in boilerplate.

@MyreMylar
Copy link
Owner

The import statement is huge, and, as you can't do multiple imports, requires a dedicated import for every element. The length also makes it virtually impossible (or at least incredibly irritating) to create an object without a dedicated import statement.

from pygame_gui.elements.ui_text_entry_line import UITextEntryLine
data_entry = pygame_gui.elements.ui_text_entry_line.UITextEntryLine(relative_rect=Rect(x, y, w, h), manager=manager)

Can this not be re-written as:

from pygame_gui.elements import UITextEntryLine, UIButton, UILabel

data_entry = UITextEntryLine(Rect(x, y, w, h), manager)

?

UITextEntryLine

Having initial text/default text is a good idea. I guess it'd need also need an option for the different behaviour, because I'm sure someone else will want default text that stays set when the user starts to edit the text line. Multi-line text entry should be much more possible once I've finished refactoring & unifying the underlying text rendering code, something that is currently underway. The height of the line is slightly fiddly, I wanted the behaviour where the line just grows to the height of whatever font size is used by the line, so that's what it always does right now by default. Probably I should allow an override option so it respects the value set in the rect, even if it's is too short/too tall for the text. The other things sound fairly straightforward.

UITextBox

All this sounds fairly straightforward. The text box should get quite a few changes from the general text refactor anyway.

Clicking the dropdown button (the little arrow) does not also click the main button, and vice-versa
Allow dropdown only when the dropdown button is clicked, and not the main button.

I believe the drop down used to work like this with separate button functionality but there was a request to combine them. It's slightly awkward to make it optional without adding ever more constructor parameters but I may fiddle with it at some point. What was the use case for having the main button not do a drop down/up action? Just aesthetics/preference?

Implicit UIManager
Adding the same boilerplate manager=manager to every object gets tiring quickly. It would be nice to have an option to set a default manager that is used when no explicit manager is declared.

I think this is a good idea and something that should be fairly straight forward to add as a global setter/getter function with some error handling. It it likely also possible to add a default, default manager for the cases where no manager is created, or set that just uses the default theming and the size of the screen/window. 👍

html_text
Currently, the font option does not appear to work.

This works in the examples, so I'm not sure what issue you are having.

Automatic conversion from \n to
would be nice.

Yeah, this could likely be added to the html parser. I'd like to support multiple formatting parsers one day too, but finding the time :)

Method to change the typing speed for fade_appear.

I believe the attribute for this is called time_per_letter in the current version. So just set it to less than 0.05 to speed it up and greater than 0.05 to slow it down.

UITable

Sounds like a decent idea for a new element.

@UmbralReaper
Copy link
Author

Thanks for the reply!

Can this not be re-written as:

from pygame_gui.elements import UITextEntryLine, UIButton, UILabel
data_entry = UITextEntryLine(Rect(x, y, w, h), manager)

?

uh, yes. Don't know how I missed that 😅.

I believe the attribute for this is called time_per_letter in the current version. So just set it to less than 0.05 to speed it up and greater than 0.05 to slow it down.

Cool, I'll try that!

@MyreMylar
Copy link
Owner

Closing this now as all tasks have been completed, separated out into new issues or were currently unable to be implemented. Or I lost them along the way because there was a lot to digest in this issue.

If you feel there is something missing after 0.6.5 is released (other than the UITable which won't make it yet), feel free to return and add these as separate issues.

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

No branches or pull requests

3 participants