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

Allow user to force multi-line text #20

Open
KenyonPrater opened this issue Nov 5, 2024 · 1 comment
Open

Allow user to force multi-line text #20

KenyonPrater opened this issue Nov 5, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@KenyonPrater
Copy link

KenyonPrater commented Nov 5, 2024

For instance, if I want to toast a pretty-printed dictionary:

toast = Toast()
toast.setTitle("User data")
my_data = {'id': 42, 'username': 'alice', 'role': 'user'}
toast.setText(json.dumps(my_data, indent=2))
toast.show()

Right now, only the first line of the text will be visible in the toast. It seems like the solution would be like this:

def __setup_ui(self):
    [...]
    if self.__title == '' or self.__text == '':
        text_section_spacing = 0

    # NEW CODE
    if self.__multiline:
        self.__text_label.setWordWrap(True)
        text_height = self.__text_label.sizeHint().height()
        text_width = self.__text_label.sizeHint().width()
    # END OF NEW CODE

    text_section_height = (self.__text_section_margins.top()
                           + title_height + text_section_spacing
                           + text_height + self.__text_section_margins.bottom())
    [...]

This gives:

image

Alright if I create a PR to this effect?

@niklashenning
Copy link
Owner

This looks like a very nice addition, definitely feel free to create a PR for it 👍🏻
We'll have to make sure everything is backwards compatible but I think that shouldn't be a problem with this feature

@niklashenning niklashenning added the enhancement New feature or request label Nov 6, 2024
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

2 participants