@@ -516,6 +516,7 @@ def handle_readonly(instance, value):
516
516
fbind ('font_name' , update_text_options )
517
517
fbind ('size' , update_text_options )
518
518
fbind ('password' , update_text_options )
519
+ fbind ('password_mask' , update_text_options )
519
520
520
521
fbind ('pos' , self ._trigger_update_graphics )
521
522
fbind ('readonly' , handle_readonly )
@@ -1226,8 +1227,8 @@ def _update_selection(self, finished=False):
1226
1227
self ._selection_finished = finished
1227
1228
_selection_text = self ._get_text (encode = False )[a :b ]
1228
1229
self .selection_text = ("" if not self .allow_copy else
1229
- (('*' * (b - a )) if self . password else
1230
- _selection_text ))
1230
+ ((self . password_mask * (b - a )) if
1231
+ self . password else _selection_text ))
1231
1232
if not finished :
1232
1233
self ._selection = True
1233
1234
else :
@@ -1709,7 +1710,8 @@ def _get_text_width(self, text, tab_width, _label_cached):
1709
1710
if not self .password :
1710
1711
width = _label_cached .get_extents (text )[0 ]
1711
1712
else :
1712
- width = _label_cached .get_extents ('*' * len (text ))[0 ]
1713
+ width = _label_cached .get_extents (
1714
+ self .password_mask * len (text ))[0 ]
1713
1715
Cache_append ('textinput.width' , cid , width )
1714
1716
return width
1715
1717
@@ -2078,7 +2080,7 @@ def _create_line_label(self, text, hint=False):
2078
2080
# Create a label from a text, using line options
2079
2081
ntext = text .replace (u'\n ' , u'' ).replace (u'\t ' , u' ' * self .tab_width )
2080
2082
if self .password and not hint : # Don't replace hint_text with *
2081
- ntext = u'*' * len (ntext )
2083
+ ntext = self . password_mask * len (ntext )
2082
2084
kw = self ._get_line_options ()
2083
2085
cid = '%s\0 %s' % (ntext , str (kw ))
2084
2086
texture = Cache_get ('textinput.label' , cid )
@@ -2430,14 +2432,24 @@ def _refresh_hint_text(self):
2430
2432
'''
2431
2433
2432
2434
password = BooleanProperty (False )
2433
- '''If True, the widget will display its characters as the character '*'.
2435
+ '''If True, the widget will display its characters as the character
2436
+ set in :attr:`password_mask`.
2434
2437
2435
2438
.. versionadded:: 1.2.0
2436
2439
2437
2440
:attr:`password` is a :class:`~kivy.properties.BooleanProperty` and
2438
2441
defaults to False.
2439
2442
'''
2440
2443
2444
+ password_mask = StringProperty ('*' )
2445
+ '''Sets the character used to mask the text when :attr:`password` is True.
2446
+
2447
+ .. versionadded:: 1.9.2
2448
+
2449
+ :attr:`password_mask` is a :class:`~kivy.properties.StringProperty` and
2450
+ defaults to `'*'`.
2451
+ '''
2452
+
2441
2453
keyboard_suggestions = BooleanProperty (True )
2442
2454
'''If True provides auto suggestions on top of keyboard.
2443
2455
This will only work if :attr:`input_type` is set to `text`.
0 commit comments