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

feat: Widget.ScrollingLabel #46

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Bavalionprolate
Copy link

ScrollingLabel Class

The ScrollingLabel class is a widget for displaying text that automatically scrolls if its length exceeds a specified maximum. It inherits from the Label class and adds scrolling functionality with customizable parameters.

Key Features:

  • Text Scrolling: If the text is too long, it will scroll at a specified speed.
  • Maximum Text Length: You can specify the maximum length of the text before it starts scrolling.
  • Scrolling Speed: You can set the speed of scrolling in milliseconds.
  • CSS Class Support: CSS classes can be applied for styling.
  • Text Alignment and Wrapping: Text alignment (e.g., left) and text wrapping can be configured.

Parameters:

  • label: The text to be displayed.
  • max_length: The maximum length of text before scrolling begins (default is 10 characters).
  • scroll_speed: The speed of the scrolling (default is 500 milliseconds).
  • css_classes: A list of CSS classes for styling.
  • justify: The alignment of the text (default is 'left').
  • wrap: Whether to wrap the text (default is True).
  • wrap_mode: The text wrapping mode (default is 'word').

Important Methods:

  • _get_display_text: Generates the current text for display, considering scrolling.
  • _scroll_text: Updates the scrolling index and updates the displayed text.
  • _start_scrolling: Starts a timer to scroll the text.
  • _scroll_text_and_continue: Updates the text and continues scrolling.

This class is useful for displaying long strings of text, such as news feeds, announcements, etc., where dynamic scrolling of information is needed.

@linkfrg linkfrg self-requested a review November 24, 2024 07:14
Copy link
Owner

@linkfrg linkfrg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Use Google style of docstrings, dev docs
  2. CSS classes will be applied by Label (BaseWidget) constructor, no need to repeat code
  3. Do not describe label, wrap, justify properties, just indicate that "Bases: :class:~ignis.widgets.Widget.Label", this class will inherit them from Label anyway
  4. use mypy and ruff

In general, please read the developer guide

@Bavalionprolate
Copy link
Author

Okey, I apologize, I'll be sure to read it and send a pull request with corrections

@linkfrg linkfrg changed the title Scrolling label feat: Widget.ScrollingLabel Nov 26, 2024
@linkfrg linkfrg added the enhancement New feature or request label Nov 26, 2024
@linkfrg linkfrg added this to the v0.4 milestone Dec 1, 2024
@linkfrg linkfrg removed this from the v0.4 milestone Dec 9, 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

Successfully merging this pull request may close these issues.

2 participants