diff --git a/mpf/config_players/segment_display_player.py b/mpf/config_players/segment_display_player.py index 37c7e110a..27bfb2e2b 100644 --- a/mpf/config_players/segment_display_player.py +++ b/mpf/config_players/segment_display_player.py @@ -106,14 +106,13 @@ def _remove(self, instance_dict, key, display): del instance_dict[display][key] def clear_context(self, context): + """Remove all texts. Ignore what keys are available, that will be checked later in the segment display code. + Especially important for update_method replace since there are no keys.""" - # Remove all texts. Ignore what keys are available, that will be checked later in the segment display code. - # Especially important for update_method replace since there are no keys. + instance_dict = self._get_instance_dict(context) # key of the dict is the display, the value is another dict - instance_dict = self._get_instance_dict(context) # key of the dict is the display, the value is another dict - - for display, keys_dict in instance_dict.items(): # keys_dict key is the show key, the value is a boolean (with yet unknown usage) - if keys_dict: #depending on the situation the keys_dict might be empty, still need to clear the display + for display, keys_dict in instance_dict.items(): # keys_dict key is the show key, value is bool(unknown usage) + if keys_dict: #depending on the situation the keys_dict might be empty, still need to clear the display for key in dict(keys_dict).keys(): display.clear_segment_display(key) if instance_dict[display][key] is not True: diff --git a/mpf/devices/segment_display/.segment_display.py.kate-swp b/mpf/devices/segment_display/.segment_display.py.kate-swp new file mode 100644 index 000000000..c940cf7df Binary files /dev/null and b/mpf/devices/segment_display/.segment_display.py.kate-swp differ diff --git a/mpf/devices/segment_display/segment_display_text.py b/mpf/devices/segment_display/segment_display_text.py index c18cccc91..8d7188860 100644 --- a/mpf/devices/segment_display/segment_display_text.py +++ b/mpf/devices/segment_display/segment_display_text.py @@ -75,8 +75,9 @@ def _create_characters(cls, text: str, display_size: int, collapse_dots: bool, c use_dots_for_commas: bool, colors: List[Optional[RGBColor]]) -> List[DisplayCharacter]: """Create characters from text and color them. - Dots and commas are embedded on the fly. - - Text will be right aligned on the display, thus if text is shorter than display spaces will be padded before the text - - If list of colors is less than the display size then all white will be used, if only one color is given that will be used for the full display + - Text will be right aligned on the display, if text is shorter than display spaces add on the left + - If list of colors is less than the display size then all white will be used, + - If only one color is given that will be used for the full display """ char_list = [] uncolored_chars = cls._embed_dots_and_commas(text, collapse_dots, collapse_commas, use_dots_for_commas) @@ -88,18 +89,20 @@ def _create_characters(cls, text: str, display_size: int, collapse_dots: bool, c #TODO: Log that colors were adjusted to white as default colors = [RGBColor("white")] * display_size - # ensure list is the same size as the segment display (cut off on left if too long or right justify characters if too short) + # ensure list is the same size as the segment display + # cut off on left if too long or right justify characters if too short current_length = len(uncolored_chars) if current_length > display_size: for _ in range(current_length - display_size): - uncolored_chars.pop(0) # remove very left char of array if too long + uncolored_chars.pop(0) # remove very left char of array if too long elif current_length < display_size: for _ in range(display_size - current_length): uncolored_chars.insert(0, (SPACE_CODE, False, False)) for i, char in enumerate(uncolored_chars): color = colors[i] - char_list.append(DisplayCharacter(char[0], char[1], char[2], color)) #0: char code 1: char_has_dot 2: char_has_comma + #0: char code 1: char_has_dot 2: char_has_comma + char_list.append(DisplayCharacter(char[0], char[1], char[2], color)) return char_list