diff --git a/pygameMenu/selector.py b/pygameMenu/selector.py index 405c2e72..a590eef0 100644 --- a/pygameMenu/selector.py +++ b/pygameMenu/selector.py @@ -4,7 +4,7 @@ Selector class, manage elements and adds entries to menu. The MIT License (MIT) -Copyright 2017-2018 Pablo Pizarro R. @ppizarror +Copyright 2017-2019 Pablo Pizarro R. @ppizarror Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -54,6 +54,9 @@ def __init__(self, title, elements, onchange=None, onreturn=None, default=0, **k self._title = title self._total_elements = len(elements) + # Selection format + self._sformat = '{0} < {1} >' + # Apply default item default %= self._total_elements for k in range(0, default): @@ -109,6 +112,16 @@ def change(self): else: self._on_change(*paraml) + def format_selection(self, s): + """ + Change the selection text. + + :param s: Selection text + :type s: basestring + :return: + """ + self._sformat = s + def get(self): """ Return element text. @@ -116,7 +129,7 @@ def get(self): :return: Element text :rtype: str """ - return '{0} < {1} >'.format(self._title, self._elements[self._index][0]) + return self._sformat.format(self._title, self._elements[self._index][0]) def left(self): """ diff --git a/pygameMenu/textmenu.py b/pygameMenu/textmenu.py index 5a8ab03f..d7f5b892 100644 --- a/pygameMenu/textmenu.py +++ b/pygameMenu/textmenu.py @@ -4,7 +4,7 @@ Menu with text and buttons. The MIT License (MIT) -Copyright 2017-2018 Pablo Pizarro R. @ppizarror +Copyright 2017-2019 Pablo Pizarro R. @ppizarror Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -50,8 +50,7 @@ def __init__(self, text_color=_cfg.TEXT_FONT_COLOR, text_fontsize=_cfg.MENU_FONT_TEXT_SIZE, text_margin=_cfg.TEXT_MARGIN, - **kwargs - ): + **kwargs): """ TextMenu constructor.